/install agent-init-skill
Agent Init
Two-phase workflow for generating a comprehensive AGENTS.md (or updating an existing CLAUDE.md) for any project:
- Phase 1 — Run
/initto produce raw project intelligence - Phase 2 — Restructure that output into the 9-section universal template, adapting all tech-specific references to what the project actually uses
Why This Structure
A well-structured AGENTS.md is the "onboarding doc" for AI agents. The 9-section template ensures every agent gets consistent context: what the project is, how to build and run it, what conventions to follow, and where to find deeper docs. Raw /init output tends to be uneven — it lists files well but misses conventions, workflows, and cross-references. Phase 2 fixes that.
Phase 1: Base Analysis
Run /init in the project root. This analyzes the codebase and writes a preliminary CLAUDE.md.
- If a CLAUDE.md or AGENTS.md already exists,
/initincorporates existing content - The output is a starting point — expectations: file tree, dependency list, build file detection
- Do not skip this phase even if the project looks simple; the analysis provides useful raw material
Phase 2: Restructure into Universal Template
Read the CLAUDE.md that /init produced, then rewrite it into the target AGENTS.md following the template below.
Information Sources (use all three)
- From
/initoutput — file tree, dependencies, detected frameworks - From project inspection — read key config files, source layouts, existing docs to verify and supplement
- From inference — conventions implied by the stack (e.g., Maven →
mvn test, npm →npm test)
Core Principle
Adapt the template to the project, not the project to the template. If the template says "Spotless" but the project uses ESLint, write ESLint. If the template assumes a backend but the project is frontend-only, merge the architecture sections.
Target Filename
AGENTS.mdalready exists → update it in-place- Only
CLAUDE.mdexists → update it in-place (preserve filename to avoid breaking existing references) - Neither exists → create
AGENTS.md
Language
Match the language of the project's existing documentation (README, comments). For Chinese projects, write in Chinese. When uncertain, default to Chinese.
When Information Is Missing
Mark genuinely unavailable sections with \x3C!-- TODO: 待补充 — \x3Creason> -->. Never fabricate doc links, command names, or conventions. An honest TODO is better than a wrong instruction.
9-Section Universal Template
1. 项目概述 (Project Overview)
One paragraph: what the project does, the detected tech stack (real frameworks, not template placeholders), and repository structure (monorepo with subproject list, or single-project with key directories).
Fill from: README, package.json/pom.xml/build.gradle, top-level directory listing.
2. 快速命令 (Quick Commands)
Quick-reference table:
| 操作 | 命令 |
|---|---|
| 构建 | (from Makefile / package.json scripts / mvnw / gradlew) |
| 启动 | (dev server or application start command) |
| 测试 | (test runner command) |
| 格式化 | (formatter command, or "N/A") |
| Lint | (linter command, or "N/A") |
Environment variables (only if the project uses them): document ~/.\x3Cproject>_env or .env file loading priority. If the project has no env file convention, skip this subsection entirely.
Fill from: package.json scripts, Makefile, pom.xml plugins, build.gradle tasks, CI workflow files.
3. 后端架构 (Backend Architecture)
If the project has no backend: rename to "项目架构" and describe the single codebase.
- ASCII package tree — indent-based tree of key source directories (not every file, just meaningful packages)
- Package annotations — one-line purpose comment per package
- Core subsystems — 2-3 sentences each for major modules (auth, data layer, API, etc.)
- Pointer:
→ 详见 docs/architecture.mdonly if that file exists
Fill from: /init file tree + spot-reading key source files in each package.
4. 前端架构 (Frontend Architecture)
If the project has no frontend, omit this section entirely.
- Tech stack: framework, state management, build tool (detected, not assumed)
- Routing scheme: file-based or config-based, with an example route
- API layer: how the frontend calls the backend (axios instance, base URL config, error interceptor)
- Component library: which UI library is used (or "无,使用原生组件")
- Pointer:
→ 详见 docs/design-docs/frontend-architecture.mdonly if that file exists
Fill from: package.json dependencies, grep for router setup and API client initialization.
5. 关键约定 (Key Conventions)
Bullet list of enforced conventions. Each convention must be verifiable in the codebase — search for the actual pattern, don't copy from the template blindly.
Template examples (replace with detected equivalents):
- Error handling: search for custom exception base classes (
BusinessException,AppException, etc.). If found → document. If the project throws rawRuntimeException→ note that as a finding, not a convention. - Response wrapping: search for
ApiResponse,R,Result\x3CT>, or global response advice/controller. If a unified wrapper exists → document it. - Layering rules: check for ArchUnit tests,
lint-archMakefile targets, or package structure conventions that enforce layer boundaries. If none → omit. - Code style: detect from
.editorconfig,.prettierrc,checkstyle.xml,spotlessconfig,.eslintrc. Document the actual tooling. - Auth: detect JWT, session, OAuth2 from code. Document the actual mechanism.
Every convention needs a doc link (only if the doc exists):
→ 详见 docs/conventions/\x3Ctopic>.md
6. 本地开发及验证流程 (Local Development)
Complete "edit → build → start → verify" loop:
1. 改 (Edit) — source directories to modify
2. 构建 (Build) — exact command
3. 启动 (Start) — how to start the dev server
4. 验证 (Verify) — curl example or browser URL
Include (if applicable):
- Token acquisition — how to get an auth token for API testing
- Log paths — where application logs are written
- Pointer:
→ 详见 docs/design-docs/api-verification.mdonly if that file exists
Fill from: README, CONTRIBUTING.md, docker-compose.yml. Construct a realistic curl example based on an actual API route found in the code.
7. 质量检查 (Quality Checks)
Single line listing available check commands:
make lint-arch / make lint-format / make format / make build / make test
Replace with the project's actual equivalents. If no formal checks exist, list the closest equivalents (e.g., npm run lint && npm test && npm run build).
8. 参考项目约定 (Reference Projects)
If the project references sibling repos or template projects for conventions, list them with priority rules. If none exist, omit this section entirely.
9. 文档导航 (Document Navigation)
Index table of existing detailed docs, grouped by category:
| 类别 | 文档路径 | 说明 |
|---|---|---|
| architecture | docs/architecture.md | 架构设计 |
| design-docs | docs/design-docs/* | 设计文档 |
| conventions | docs/conventions/* | 编码约定 |
Fill from: Glob for docs/**/*.md, ref-*/, and any *.md files outside the root. Only include files that actually exist — never fabricate paths.
Preserving Existing Content
If the project already has a hand-written CLAUDE.md or AGENTS.md, /init incorporates it. During Phase 2:
- Preserve hand-written insights that can't be discovered from code (historical context, team decisions, gotchas)
- Reorganize them into the matching template section
- Don't discard content just because it doesn't fit neatly — add it to the most relevant section, or create an additional subsection
Verification Checklist
After writing, verify:
- Every command in section 2 actually runs (at minimum, confirm the build and test commands work)
- Every file path in section 9 exists on disk
- Every convention in section 5 is observable in the codebase
- No fabricated doc links or guessed commands
Self-Evolution Mechanism
After each execution of this Skill:
- Evaluate whether the output achieved the intended goal: pass / fail.
- If it fails, reflect on the cause of failure and append a “failure case + improvement suggestion” to
diary/YYYY-MM-DD.md. - If a certain improvement suggestion is repeatedly mentioned in the most recent three executions, refine it into a formal rule and submit a PR to modify this
SKILL.md.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install agent-init-skill - 安装完成后,直接呼叫该 Skill 的名称或使用
/agent-init-skill触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
agent-init 是什么?
Initialize or update AGENTS.md/CLAUDE.md for a project. Use this skill whenever the user wants to create, initialize, generate, setup, or update a project-le... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 37 次。
如何安装 agent-init?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-init-skill」即可一键安装,无需额外配置。
agent-init 是免费的吗?
是的,agent-init 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
agent-init 支持哪些平台?
agent-init 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 agent-init?
由 orbisz(@orbisz)开发并维护,当前版本 v1.0.0。