| name | ctx-init |
| description | Analyze the project and scaffold a layered context architecture made of CLAUDE.md, subdirectory CLAUDE.md, .claude/rules/, and AGENTS.md. Preserve and augment existing files. Triggers โ ์ปจํ
์คํธ ์ด๊ธฐํ, ์ปจํ
์คํธ ์ํคํ
์ฒ, CLAUDE.md ์์ฑ, ์ค์บํด๋ฉ. |
| argument-hint | [target directory (defaults to project root if omitted)] |
Context Architecture Init
Initialize the project's layered context architecture. Preserve and augment existing files.
Claude Code context loading model: Claude Code auto-loads CLAUDE.md and .claude/rules/. The root CLAUDE.md loads at session start, subdirectory CLAUDE.md loads on-demand when files in that directory are accessed, and .claude/rules/ applies automatically on glob-pattern match. CONTEXT.md and AGENTS.md are not auto-loaded.
Execution Steps
Step 1: Project analysis
Detect the following from the project root:
-
Build tool detection โ scan these files in order:
package.json โ extract npm/yarn/pnpm scripts
Makefile โ extract make targets
Cargo.toml โ extract cargo commands
pyproject.toml โ extract poetry/pip scripts
build.gradle / build.gradle.kts โ extract gradle tasks
CMakeLists.txt โ extract cmake build commands
*.xcodeproj / Package.swift โ extract xcodebuild/swift commands
go.mod โ extract go commands
-
Directory structure analysis โ survey the directory tree at 1โ2 levels deep to identify subsystem candidates. Use these patterns as a guide:
src/, lib/, app/ โ source code root
api/, server/, routes/ โ API/server layer
components/, pages/, views/ โ frontend layer
services/, domain/, core/ โ business logic
tests/, __tests__/, spec/ โ tests
infra/, deploy/, terraform/ โ infrastructure
-
Existing context files โ check whether CLAUDE.md, CONTEXT.md, AGENTS.md already exist.
Step 2: User confirmation
Summarize the analysis for the user.
Respond to the user in Korean.
## ํ๋ก์ ํธ ๋ถ์ ๊ฒฐ๊ณผ
**๋น๋ ๋๊ตฌ**: [๊ฐ์ง๋ ๋๊ตฌ]
**์ฃผ์ ์๋ธ์์คํ
**: [์๋ณ๋ ์๋ธ์์คํ
๋ชฉ๋ก]
**๊ธฐ์กด ์ปจํ
์คํธ ํ์ผ**: [์์/์์]
### ์์ฑ ๊ณํ
- [ ] /CLAUDE.md (์ ๊ท ์์ฑ / ๋ณด๊ฐ)
- [ ] /AGENTS.md (์ ๊ท ์์ฑ / ๋ณด๊ฐ)
- [ ] ์๋ธ์์คํ
์ปจํ
์คํธ (CLAUDE.md / .claude/rules/ / CONTEXT.md ์ค ์ ํ)
...
์ด ๊ณํ์ผ๋ก ์งํํ ๊น์?
Proceed to the next steps only after the user approves the plan.
Step 3: Create/augment CLAUDE.md
If no file exists: create a new one.
Reference: check the CLAUDE.md authoring standard in the guide skill's references/file-standards.md.
Core rules:
- Keep it concise (split long content into
@ imports or subdirectory CLAUDE.md files)
- Use the build/test commands detected in Step 1
- Infer architecture decisions from the code structure
- Write in Korean (comments, descriptions)
If a file exists: preserve existing content and augment with:
- Missing build/test commands
- A suggestion to split long content into
@ imports or subdirectory CLAUDE.md
Step 4: Create/augment AGENTS.md
Note: Claude Code does not auto-load AGENTS.md. It is created for compatibility with other AI tools such as Cursor and Aider. To use it in Claude Code, add @AGENTS.md to CLAUDE.md.
If no file exists: convert the core content of CLAUDE.md into generic markdown and create it.
If a file exists: preserve existing content and augment only the missing sections.
Step 5: Create subsystem context
Guide the user to choose how context is distributed.
Option A: Subdirectory CLAUDE.md (recommended โ Claude Code auto-loads)
- Create a
CLAUDE.md in each subsystem directory
- Loads on-demand when files in that directory are accessed
Option B: .claude/rules/ (recommended โ glob-pattern-based auto-apply)
- Create rule files under the
.claude/rules/ directory
- Applies automatically based on file path patterns
Option C: CONTEXT.md (for other-tool compatibility)
- Create a
CONTEXT.md in each subsystem directory
- Not auto-loaded in Claude Code (requires explicit Read or
@ import)
- Compatible with tools that recognize CONTEXT.md, such as Cursor and Windsurf
Common content:
- Describe the purpose and role of the directory
- List key files in a Key Files section
- Describe unique patterns or caveats
Skip directories that already contain a context file.
Step 6: Result summary
Output the list of created/augmented files and the next steps.
Respond to the user in Korean.
## ์ปจํ
์คํธ ์ํคํ
์ฒ ์ด๊ธฐํ ์๋ฃ
### ์์ฑ๋ ํ์ผ
- /CLAUDE.md
- /AGENTS.md
- /src/CLAUDE.md (๋๋ .claude/rules/src.md)
- /src/api/CLAUDE.md (๋๋ .claude/rules/api.md)
### ๋ค์ ๋จ๊ณ
1. ์์ฑ๋ ์ปจํ
์คํธ ํ์ผ์ ๋ด์ฉ์ ๊ฒํ ํ๊ณ ํ๋ก์ ํธ ํน์ฑ์ ๋ง๊ฒ ์์ ํ์ธ์.
2. `/agent-context:ctx-verify`๋ก ๊ฒ์ฆ์ ์คํํ์ธ์.
3. `/agent-context:ctx-audit`๋ก ํ ํฐ ํจ์จ์ฑ์ ํ์ธํ์ธ์.