(builtin) Initialize hierarchical AGENTS.md knowledge base
Claude Code Harness Tool Compatibility
This skill may include examples copied from the OpenCode or Codex harness. In Claude Code, do not call OpenCode/Codex-only tools such as task(...), call_omo_agent(...), spawn_agent(...), background_output(...), wait_agent(...), team_*(...), send_message(...), followup_task(...), or close_agent(...) literally. Translate those examples to Claude Code native tools:
the Task tool with the planner/reviewer subagent, or the Skill tool
task(category="...", ...)
the Task tool (general-purpose subagent) or run the work inline
background_output(...) / wait_agent(...)
await the subagent's return value / the system completion notification
team_*(...) / send_message/followup_task/
**TodoWrite ALL phases. Mark in_progress → completed in real-time.**
```
TodoWrite([
{ id: "discovery", content: "Fire explore agents + LSP codemap + read existing", status: "pending", priority: "high" },
{ id: "scoring", content: "Score directories, determine locations", status: "pending", priority: "high" },
{ id: "generate", content: "Generate AGENTS.md files (root + subdirs)", status: "pending", priority: "high" },
{ id: "review", content: "Deduplicate, validate, trim", status: "pending", priority: "medium" }
])
```
**DYNAMIC AGENT SPAWNING**: After bash analysis, spawn ADDITIONAL explore agents based on project scale:
**File Writing Rule**: If AGENTS.md already exists at the target path → use `Edit` tool. If it does NOT exist → use `Write` tool.
NEVER use Write to overwrite an existing file. ALWAYS check existence first via `Read` or discovery results.
close_agent
run multiple Task subagents and synthesize their results
When translating load_skills=[...], invoke the requested skills with the Skill tool or pass their names in the spawned subagent's prompt. If a code block below conflicts with this section, this section wins.
## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
## CODE MAP
{From LSP - skip if unavailable or project <10 files}
| Symbol | Type | Location | Refs | Role |
|--------|------|----------|------|------|
## CONVENTIONS
{ONLY deviations from standard}
## ANTI-PATTERNS (THIS PROJECT)
{Explicitly forbidden here}
## UNIQUE STYLES
{Project-specific}
## COMMANDS
```bash
{dev/test/build}
NOTES
{Gotchas}
**Quality gates**: 50-150 lines, no generic advice, no obvious info.
### Subdirectory AGENTS.md (Parallel)
Launch writing tasks for each location:
for loc in AGENTS_LOCATIONS (except root):
task(category="writing", load_skills=[], run_in_background=false, description="Generate AGENTS.md", prompt= Generate AGENTS.md for: ${loc.path} - Reason: ${loc.reason} - 30-80 lines max - NEVER repeat parent content - Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS )
**Wait for all. Mark "generate" as completed.**
---
## Phase 4: Review & Deduplicate
**Mark "review" as in_progress.**
For each generated file:
- Remove generic advice
- Remove parent duplicates
- Trim to size limits
- Verify telegraphic style
**Mark "review" as completed.**
---
## Final Report
---
## Anti-Patterns
- **Static agent count**: MUST vary agents based on project size/depth
- **Sequential execution**: MUST parallel (explore + LSP concurrent)
- **Ignoring existing**: ALWAYS read existing first, even with --create-new
- **Over-documenting**: Not every dir needs AGENTS.md
- **Redundancy**: Child never repeats parent
- **Generic content**: Remove anything that applies to ALL projects
- **Verbose style**: Telegraphic or die