hierarchical-agents
Generate hierarchical AGENTS.md structure for codebases to optimize AI agent token usage. Use when creating AGENTS.md files, documenting codebase structure, setting up agent guidance, organizing project documentation for AI tools, implementing JIT indexing, or working with monorepos that need lightweight root guidance with detailed sub-folder documentation. Covers repository analysis, root AGENTS.md generation, sub-folder AGENTS.md creation, and token-efficient documentation patterns.
What this skill does
# Hierarchical Agents Documentation Generator ## Purpose Create a **hierarchical AGENTS.md system** for codebases that enables AI coding agents to work efficiently with minimal token usage. Generates lightweight root documentation with detailed sub-folder guidance following the "nearest-wins" principle. ## When to Use - Creating AGENTS.md documentation for a new project - Setting up AI agent guidance for a monorepo - Optimizing existing documentation for token efficiency - Implementing JIT (Just-In-Time) indexing patterns ## Process Follow these phases in order. See [references/generation-process.md](references/generation-process.md) for complete details. ### Phase 1: Repository Analysis Analyze the codebase: 1. Repository type (monorepo, multi-package, simple) 2. Technology stack (languages, frameworks, tools) 3. Major directories (apps, services, packages) 4. Build system and testing setup 5. Key patterns, conventions, anti-patterns **Output**: Structured map of the repository before generating any files. ### Phase 2: Generate Root AGENTS.md Root must be lightweight: ~100-200 lines maximum, universal guidance only. Acts as index and navigation hub. Agents read the closest AGENTS.md to the file being edited — sub-folder files override root (nearest-wins). Create root file with these sections: 1. **Project Snapshot** (3-5 lines) - Repo type - Primary tech stack - Note about sub-package AGENTS.md files 2. **Root Setup Commands** (5-10 lines) - Install dependencies, build all, typecheck all, test all 3. **Universal Conventions** (5-10 lines) - Code style (TypeScript strict? Prettier? ESLint?) - Commit format (Conventional Commits?) - Branch strategy - PR requirements 4. **Implementation Rules** (2-3 lines) — see example below 5. **Development Workflow** (5-7 lines) — see example below 6. **Security & Secrets** (3-5 lines) - Never commit tokens - Where secrets go (.env patterns) - PII handling 7. **JIT Index - Directory Map** (10-20 lines) — see example below - Reference files by path, not content - Provide search commands that agents can execute 8. **Acceptance Criteria** (3-5 lines) - Pre-PR checklist - What must pass **Example Implementation Rules**: ```markdown ## Implementation Rules Before adding ANY external dependency (gems, npm packages, GitHub Actions, Docker images, APIs, CDN links): - Use WebSearch to verify the latest stable version BEFORE implementation - Never trust training data for version numbers ``` **Example JIT Index**: ```markdown ## JIT Index (what to open, not what to paste) ### Package Structure - Web UI: `apps/web/` -> [see apps/web/AGENTS.md](apps/web/AGENTS.md) - API: `apps/api/` -> [see apps/api/AGENTS.md](apps/api/AGENTS.md) - Shared packages: `packages/**/` -> [see packages/README.md] ### Quick Find Commands - Search function: `rg -n "functionName" apps/** packages/**` - Find component: `rg -n "export.*ComponentName" apps/web/src` - Find API routes: `rg -n "export const (GET|POST)" apps/api` ``` **Example Development Workflow**: ```markdown ## Development Workflow - Before coding -> describe approach -> wait for approval - Ambiguous requirements -> ask first - If task touches >3 files -> decompose first - After coding -> list breakage risks + suggest tests - Bug fix -> write failing test -> fix until green - When corrected -> add lesson to .agents/lessons/ ``` ### Phase 3: Generate Sub-Folder AGENTS.md Files Sub-folders have MORE detail than root — specific patterns, technology-specific conventions, real file examples from the codebase. For EACH major package/directory, create detailed AGENTS.md: 1. **Package Identity** (2-3 lines) 2. **Setup & Run** (5-10 lines) 3. **Patterns & Conventions** (10-20 lines) - MOST IMPORTANT 4. **Touch Points / Key Files** (5-10 lines) 5. **JIT Index Hints** (5-10 lines) 6. **Common Gotchas** (3-5 lines) 7. **Pre-PR Checks** (2-3 lines) **Key**: Patterns & Conventions must include real file paths with DO/DON'T examples. ### Phase 4: Special Considerations Adapt templates for specific package types (Design System, Database, API, Testing). See [references/generation-process.md](references/generation-process.md) for specialized templates. ## Directory Structures ### Monorepo ``` AGENTS.md # Root (lightweight) apps/ web/AGENTS.md # Frontend details api/AGENTS.md # Backend details packages/ ui/AGENTS.md # Design system details shared/AGENTS.md # Shared code details ``` ### Simple Project ``` AGENTS.md # Root (can be more detailed) src/ components/AGENTS.md # Component patterns services/AGENTS.md # Service patterns ``` ## Quality Checklist - [ ] Root AGENTS.md is under 200 lines - [ ] Root links to all sub-AGENTS.md files - [ ] Each sub-file has concrete examples (actual file paths) - [ ] Commands are copy-paste ready - [ ] No duplication between root and sub-files - [ ] Every DO has a real file example - [ ] Every DON'T references real anti-pattern - [ ] All paths are relative and verified to exist - [ ] Only major packages/domains have AGENTS.md — not every directory ## Maintenance Update AGENTS.md when: - Adding new packages or major directories - Changing build/test commands - Establishing new conventions - Refactoring project structure ## Related Resources - [references/generation-process.md](references/generation-process.md) - Complete step-by-step generation process with templates
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.