From ai-eng-plugin-dev
Recursively initializes AGENTS.md files in monorepo subdirectories with smart detection of packages and services. Creates hierarchical agent context linking to root CLAUDE.md and parents. For multi-package projects and microservices.
npx claudepluginhub v1truv1us/ai-eng-system --plugin ai-eng-plugin-devThis skill uses the workspace's default tool permissions.
Systematically initialize AGENTS.md files throughout a monorepo, creating a hierarchical context system where:
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Systematically initialize AGENTS.md files throughout a monorepo, creating a hierarchical context system where:
This enables large projects to maintain clear, navigable agent guidance without overwhelming token budgets.
Without structured AGENTS.md hierarchy:
With this skill:
Script automatically scans for:
Scoring heuristic:
Project file present: +10 points
src/lib/components dir: +5 points
Config file present: +3 points
>10 source files: +3 points
README/docs present: +2 points
Threshold: > 5 points = initialize
Create root AGENTS.md containing:
Example:
# Project Agents
## Directory Structure
| Package | Level | Purpose | Key Files |
|---------|-------|---------|-----------|
| `packages/api` | API Services | REST backend | src/routes/, src/models/ |
| `packages/web` | Frontend | React UI | src/components/, src/pages/ |
## Hierarchy Linking
Each package maintains its own AGENTS.md with:
- **Hierarchy Level**: Role in system (e.g., "API Services")
- **Parent**: Link to this AGENTS.md
- **Philosophy**: Link to CLAUDE.md
See individual AGENTS.md files for package-specific guidance.
For each important subdirectory, create localized AGENTS.md (~20 lines):
Metadata (Required per Anthropic hierarchy docs):
---
hierarchy:
level: "API Services"
parent: "../AGENTS.md"
philosophy: "../../CLAUDE.md"
---
# API Service Agents
Content:
Example for API package:
# API Service Agents
**Hierarchy Level**: API Services (REST backend, database layer)
**Parent**: [../AGENTS.md](../AGENTS.md)
**Philosophy**: [CLAUDE.md](../../CLAUDE.md)
## Tech Stack
- Express.js (server framework)
- TypeScript (type safety)
- Prisma (ORM)
- PostgreSQL (database)
## Key Commands
```bash
# Development
npm run dev # Start dev server on :3000
npm run build # Compile TypeScript
npm run test # Run Jest tests
npm run test:watch # Watch mode
# Single test example
npm test -- routes.test.ts
# Linting & formatting
npm run lint # ESLint check
npm run format # Prettier format
Imports: Absolute paths from src/, relative for same package
import { UserService } from '@api/services' // Cross-package
import { helper } from '../utils' // Local
Naming: camelCase functions, PascalCase classes, UPPER_SNAKE_CASE constants
Types: Explicit return types for all functions, use Zod for runtime validation
/services, thin controllers/prisma/schema.prisma/api/* routes via fetch/prisma/migrationsFor Claude/GPT working in this package:
any)/shared for shared types/utilities
### Phase 4: Root CLAUDE.md Update
Update (or create) root CLAUDE.md to document the hierarchy:
```markdown
# Project Philosophy
[Your guiding principles and vision...]
## Agent Coordination
See **[AGENTS.md](./AGENTS.md)** for:
- Agents and their modes (plan/build/review)
- Available commands and skills
- Directory context index
This CLAUDE.md defines **philosophy**. AGENTS.md documents **agents and tools**.
## Agent Contexts (Hierarchical)
Each package/service maintains specialized agent context:
| Directory | AGENTS.md | Level | Purpose |
|-----------|-----------|-------|---------|
| Root | [AGENTS.md](./AGENTS.md) | Coordination | Project overview, cross-package agents |
| `packages/api` | [packages/api/AGENTS.md](./packages/api/AGENTS.md) | API Services | REST backend, database layer |
| `packages/web` | [packages/web/AGENTS.md](./packages/web/AGENTS.md) | Frontend | React UI, styling, client logic |
| `packages/shared` | [packages/shared/AGENTS.md](./packages/shared/AGENTS.md) | Shared Utilities | Types, helpers, common code |
Each subdirectory's AGENTS.md includes hierarchy metadata:
- **Hierarchy Level**: Role in system architecture
- **Parent**: Link to parent AGENTS.md for coordination
- **Philosophy**: Link to this CLAUDE.md for guiding principles
This three-tier system (philosophy → coordination → specialization) allows AI agents to:
1. Understand project vision and values (CLAUDE.md)
2. Understand cross-package structure (root AGENTS.md)
3. Get specialized guidance for their specific package (package AGENTS.md)
Verify all links work:
✓ Root AGENTS.md exists and links to all packages
✓ Root CLAUDE.md lists all AGENTS.md files
✓ Each package AGENTS.md has hierarchy metadata
✓ No broken relative paths
✓ Build commands are tested (where applicable)
Cleanup:
git add .
git commit -m "chore: initialize monorepo AGENTS.md hierarchy"
# Initialize entire project (interactive)
/monorepo-initialization
# Dry-run: preview without changes
/monorepo-initialization --dry-run
# Initialize with specific depth
/monorepo-initialization --depth=3
# Re-initialize (overwrite existing)
/monorepo-initialization --preserve=false
# Initialize specific directory
/monorepo-initialization packages/my-new-service
use_skill("monorepo-initialization", {
"depth": 2,
"dry_run": False,
"preserve": False
})
Use monorepo-initialization skill to set up AGENTS.md hierarchy for new packages
| Flag | Description | Default |
|---|---|---|
--depth N | Maximum recursion depth | 2 |
--dry-run | Preview without making changes | false |
--preserve | Keep existing AGENTS.md files | false |
--batch-size N | Process N directories at a time | 3 |
--min-score N | Minimum importance score to initialize | 5 |
--include <pattern> | Additional patterns to scan | - |
--exclude <pattern> | Skip matching directories | node_modules,.git,dist,build |
Automatically scores directories to determine importance:
| Indicator | Points |
|---|---|
| Has package.json/go.mod/Cargo.toml/etc | +10 |
| Has src/, lib/, components/, or services/ | +5 |
| Has .cursorrules or copilot-instructions.md | +3 |
| Has >10 source files (.ts,.js,.py,.go,.rs) | +3 |
| Has README.md or docs/ | +2 |
Only directories scoring > 5 are initialized (configurable via --min-score).
🔍 Scanning monorepo structure...
📊 Found 8 directories above threshold (score > 5)
📁 Root
✓ AGENTS.md created (project coordination, 8 packages)
✓ CLAUDE.md updated (hierarchy linking)
📦 Batch 1/3: [packages/api, packages/web, packages/shared]
✓ packages/api: AGENTS.md (Express.js, TypeScript, Prisma)
✓ packages/web: AGENTS.md (Next.js 14, React, Tailwind)
✓ packages/shared: AGENTS.md (TypeScript utilities, types)
📦 Batch 2/3: [packages/cli, packages/docs, services/worker]
✓ packages/cli: AGENTS.md (TypeScript CLI, Yargs)
✓ packages/docs: AGENTS.md (MDX docs site, Nextra)
✓ services/worker: AGENTS.md (Bull queue, async jobs)
📦 Batch 3/3: [.claude, scripts]
✓ .claude: AGENTS.md (custom Claude Code hooks)
✓ scripts: AGENTS.md (utility scripts, Bash)
✅ Summary: 1 root + 8 packages initialized
📚 All packages linked hierarchically to CLAUDE.md
🔗 Cross-package dependencies documented
💾 Git commit ready: "chore: initialize monorepo AGENTS.md hierarchy"
For each important directory:
my-monorepo/
├── AGENTS.md ← Root coordination
├── CLAUDE.md ← Updated with hierarchy
├── packages/
│ ├── api/
│ │ ├── AGENTS.md ← New (API Services level)
│ │ └── src/
│ ├── web/
│ │ ├── AGENTS.md ← New (Frontend level)
│ │ └── src/
│ ├── shared/
│ │ ├── AGENTS.md ← New (Shared Utilities level)
│ │ └── src/
│ └── cli/
│ ├── AGENTS.md ← New (CLI Tools level)
│ └── src/
Each AGENTS.md includes:
Before running this skill, verify:
After running, verify:
# Add your new package directory
mkdir -p packages/my-service/src
# Re-run monorepo-initialization
/monorepo-initialization
# Verifies all links still work, updates root AGENTS.md
# Run on project with existing AGENTS.md files
/monorepo-initialization --preserve=true
# Won't overwrite existing files, just adds missing ones
# Increase recursion depth, process in batches
/monorepo-initialization --depth=3 --batch-size=5 --min-score=7
# Higher score = fewer but more important directories initialized
After running:
This transforms your monorepo from "confusing structure" to "clear, navigable context for AI agents and humans alike."