// Generate hierarchical documentation structures (AGENTS.md, agent.d, and custom docs) for codebases. Use when user asks to create documentation files, analyze codebase for AI agent documentation, set up AI-friendly project documentation, or generate context files for AI coding assistants. Triggers on "create documentation", "generate docs", "analyze codebase for AI", "documentation setup", "hierarchical docs".
| name | docs-generator |
| description | Generate hierarchical documentation structures (AGENTS.md, agent.d, and custom docs) for codebases. Use when user asks to create documentation files, analyze codebase for AI agent documentation, set up AI-friendly project documentation, or generate context files for AI coding assistants. Triggers on "create documentation", "generate docs", "analyze codebase for AI", "documentation setup", "hierarchical docs". |
Generate hierarchical documentation structures optimized for AI coding agents with minimal token usage. Supports AGENTS.md, agent.d, and custom documentation formats.
Before generating, confirm with user:
Analyze and report:
apps/web, apps/api, apps/mobile)services/auth, services/transcribe)packages/ui, packages/shared)workers/queue, workers/cron)Present as structured map before generating files.
Create lightweight root (~100-200 lines):
# Project Name
## Project Snapshot
[3-5 lines: repo type, tech stack, note about sub-documentation files]
## Root Setup Commands
[5-10 lines: install, build all, typecheck all, test all]
## Universal Conventions
[5-10 lines: code style, commit format, branch strategy, PR requirements]
## Security & Secrets
[3-5 lines: never commit tokens, .env patterns, PII handling]
## JIT Index
### 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)
### 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`
## Definition of Done
[3-5 lines: what must pass before PR]
# Project Name
## project_snapshot
repo_type: "monorepo"
tech_stack: ["typescript", "react", "node"]
note: "See subdirectories for agent.d files"
## root_setup
install: "pnpm install"
build: "pnpm build"
test: "pnpm test"
typecheck: "pnpm typecheck"
## conventions
code_style: "prettier + eslint"
commit_format: "conventional"
branch_strategy: "gitflow"
## jit_index
packages = {
web_ui = "apps/web/agent.d"
api = "apps/api/agent.d"
}
## quick_find
search_function = "rg -n \"functionName\" apps/** packages/**"
find_component = "rg -n \"export.*ComponentName\" apps/web/src"
find_api = "rg -n \"export const (GET|POST)\" apps/api"
# Project Documentation
## Overview
[Brief project description and architecture]
## Getting Started
[Setup instructions for new developers]
## Architecture
[High-level system design and patterns]
## Development Guidelines
[Coding standards and best practices]
## Module Index
[Links to detailed documentation for each module]
For each major package, create detailed documentation:
# Package Name
## Package Identity
[2-3 lines: what it does, primary tech]
## Setup & Run
[5-10 lines: install, dev, build, test, lint commands]
## Patterns & Conventions
[10-20 lines - MOST IMPORTANT SECTION]
- File organization rules
- Naming conventions
- Examples with actual file paths:
- DO: Use pattern from `src/components/Button.tsx`
- DON'T: Class components like `src/legacy/OldButton.tsx`
- Forms: Copy `src/components/forms/ContactForm.tsx`
- API calls: See `src/hooks/useUser.ts`
## Key Files
[5-10 lines: important files to understand package]
- Auth: `src/auth/provider.tsx`
- API client: `src/lib/api.ts`
- Types: `src/types/index.ts`
## JIT Index Hints
[5-10 lines: search commands for this package]
- Find component: `rg -n "export function .*" src/components`
- Find hook: `rg -n "export const use" src/hooks`
- Find tests: `find . -name "*.test.ts"`
## Common Gotchas
[3-5 lines if applicable]
- "Auth requires NEXT_PUBLIC_ prefix for client-side"
- "Always use @/ imports for absolute paths"
## Pre-PR Checks
[2-3 lines: copy-paste command]
pnpm --filter @repo/web typecheck && pnpm --filter @repo/web test
# Package Name
## package_identity
purpose = "React web application"
tech = ["react", "typescript", "tailwind"]
## setup
install = "pnpm install"
dev = "pnpm dev"
build = "pnpm build"
test = "pnpm test"
lint = "pnpm lint"
## patterns
file_organization = """
src/
components/ # React components
hooks/ # Custom hooks
lib/ # Utilities
types/ # TypeScript types
"""
naming = "PascalCase for components, camelCase for functions"
examples = [
{ do = "Use pattern from src/components/Button.tsx" }
{ dont = "Class components like src/legacy/OldButton.tsx" }
{ forms = "Copy src/components/forms/ContactForm.tsx" }
{ api = "See src/hooks/useUser.ts" }
]
## key_files
auth = "src/auth/provider.tsx"
api_client = "src/lib/api.ts"
types = "src/types/index.ts"
## jit_hints
find_component = "rg -n \"export function .*\" src/components"
find_hook = "rg -n \"export const use\" src/hooks"
find_tests = "find . -name \"*.test.ts\""
## gotchas
[
"Auth requires NEXT_PUBLIC_ prefix for client-side"
"Always use @/ imports for absolute paths"
]
## pre_pr_checks
command = "pnpm --filter @repo/web typecheck && pnpm --filter @repo/web test"
## Design System
- Components: `packages/ui/src/components/**`
- Use design tokens from `packages/ui/src/tokens.ts`
- Component gallery: `pnpm --filter @repo/ui storybook`
- Examples:
- Buttons: `packages/ui/src/components/Button/Button.tsx`
- Forms: `packages/ui/src/components/Input/Input.tsx`
## Database
- ORM: Prisma / Drizzle / TypeORM
- Schema: `prisma/schema.prisma`
- Migrations: `pnpm db:migrate`
- Connection: via `src/lib/db.ts` singleton
- NEVER run migrations in tests
## API Patterns
- REST routes: `src/routes/**/*.ts`
- Auth middleware: `src/middleware/auth.ts`
- Validation: Zod schemas in `src/schemas/**`
- Errors: `ApiError` from `src/lib/errors.ts`
- Example: `src/routes/users/get.ts`
## Testing
- Unit: `*.test.ts` colocated
- Integration: `tests/integration/**`
- E2E: `tests/e2e/**` (Playwright)
- Single test: `pnpm test -- path/to/file.test.ts`
- Mocks: `src/test/mocks/**`
Provide files in order:
Format:
---
File: `AGENTS.md` (root)
---
[content]
---
File: `apps/web/AGENTS.md`
---
[content]
Or for agent.d:
---
File: `agent.d` (root)
---
[content]
---
File: `apps/web/agent.d`
---
[content]
Or for custom documentation:
---
File: `README.dev.md` (root)
---
[content]
---
File: `apps/web/README.dev.md`
---
[content]
Before generating, verify: