Install
openclaw skills install agent-init-skillInitialize 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-level AGENTS.md or CLAUDE.md file. Triggers on requests like "initialize AGENTS.md", "create CLAUDE.md", "generate project doc for AI", "setup agent guidelines", "create project rules", or any mention of AGENTS.md/CLAUDE.md creation or initialization.
openclaw skills install agent-init-skillTwo-phase workflow for generating a comprehensive AGENTS.md (or updating an existing CLAUDE.md) for any project:
/init to produce raw project intelligenceA 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.
Run /init in the project root. This analyzes the codebase and writes a preliminary CLAUDE.md.
/init incorporates existing contentRead the CLAUDE.md that /init produced, then rewrite it into the target AGENTS.md following the template below.
/init output — file tree, dependencies, detected frameworksmvn test, npm → npm test)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.
AGENTS.md already exists → update it in-placeCLAUDE.md exists → update it in-place (preserve filename to avoid breaking existing references)AGENTS.mdMatch the language of the project's existing documentation (README, comments). For Chinese projects, write in Chinese. When uncertain, default to Chinese.
Mark genuinely unavailable sections with <!-- TODO: 待补充 — <reason> -->. Never fabricate doc links, command names, or conventions. An honest TODO is better than a wrong instruction.
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.
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 ~/.<project>_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.
If the project has no backend: rename to "项目架构" and describe the single codebase.
→ 详见 docs/architecture.md only if that file existsFill from: /init file tree + spot-reading key source files in each package.
If the project has no frontend, omit this section entirely.
→ 详见 docs/design-docs/frontend-architecture.md only if that file existsFill from: package.json dependencies, grep for router setup and API client initialization.
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):
BusinessException, AppException, etc.). If found → document. If the project throws raw RuntimeException → note that as a finding, not a convention.ApiResponse, R, Result<T>, or global response advice/controller. If a unified wrapper exists → document it.lint-arch Makefile targets, or package structure conventions that enforce layer boundaries. If none → omit..editorconfig, .prettierrc, checkstyle.xml, spotless config, .eslintrc. Document the actual tooling.Every convention needs a doc link (only if the doc exists):
→ 详见 docs/conventions/<topic>.md
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):
→ 详见 docs/design-docs/api-verification.md only if that file existsFill from: README, CONTRIBUTING.md, docker-compose.yml. Construct a realistic curl example based on an actual API route found in the code.
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).
If the project references sibling repos or template projects for conventions, list them with priority rules. If none exist, omit this section entirely.
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.
If the project already has a hand-written CLAUDE.md or AGENTS.md, /init incorporates it. During Phase 2:
After writing, verify:
After each execution of this Skill:
diary/YYYY-MM-DD.md.SKILL.md.