AGENTS.md Generation Capability
This skill enables the agent to analyze any repository and generate a comprehensive AGENTS.md file that serves as a contributor guide for AI agents working on the codebase.
When to Use This Skill
Activate this skill when asked to:
- •"Generate AGENTS.md"
- •"Create a contributor guide for AI agents"
- •"Analyze the repository structure"
- •"Document the codebase for AI assistants"
- •"Create documentation for this project"
- •"Help AI understand this repository"
Workflow Overview
- •Measure Repository Size: Use
tokeito count LOC and determine character limits - •Analyze Structure: Inspect directory tree, key files, and code patterns
- •Extract Patterns: Review code samples to identify conventions and behaviors
- •Generate Document: Create AGENTS.md with 5 standardized sections
- •Validate: Ensure output meets character limits and includes all required sections
Core Capability
- •Function: Analyze repository structure and generate a standardized
AGENTS.mddocument - •Output Format: Markdown file with structured sections
- •Character Limit: Dynamic, based on repository LOC (Lines of Code)
- •Analysis Method: Read-only commands only (no execution, testing, or building)
Output Sections
The generated AGENTS.md consists of exactly 5 sections:
| # | Section | Purpose |
|---|---|---|
| 1 | Overview | 1-2 sentence project description (abstract, no tool/framework lists) |
| 2 | Folder Structure | Key directories and their contents |
| 3 | Core Behaviors & Patterns | Logging, error handling, control flow patterns observed in code |
| 4 | Conventions | Naming, comments, code style derived from analysis |
| 5 | Working Agreements | Rules for agent behavior and communication |
Domain Knowledge
- •LOC Measurement: Capability to measure repository size and determine character limits. See ./references/loc_measurement.md
- •Repository Analysis: Capability to inspect and understand codebase structure. See ./references/read_only_commands.md
- •Output Template: Standardized AGENTS.md structure specification. See ./references/agents_md_template.md
- •Working Agreements: Agent behavior rules for generated documents. See ./references/working_agreements.md
Constraints & Safety
- •Read-Only Analysis: Repository inspection uses only non-destructive commands
- •No Run/Test/Build/Deploy: Generated AGENTS.md excludes execution instructions
- •Files to Ignore: Lock files (
pnpm-lock.yaml,package-lock.json,yarn.lock, etc.) - •Respect .gitignore: Exclude build artifacts, node_modules, and generated files
- •Character Limits: Strictly enforce limits based on repository size
Step-by-Step Generation Process
Step 1: Measure Repository Size
- •Run
tokeito count LOC (see ./references/loc_measurement.md) - •Determine character limit based on total LOC:
- •≤ 10K LOC: 10,000 chars
- •10K-50K LOC: 10,000 chars
- •50K-100K LOC: 10,000 chars
- •100K-500K LOC: 15,000 chars
- •500K-1M LOC: 20,000 chars
- •
1M LOC: 30,000 chars
Step 2: Analyze Repository Structure
- •Use
treeto visualize directory hierarchy (ignore node_modules, .git, build artifacts) - •Identify key directories and their architectural roles
- •Read configuration files (.editorconfig, eslintrc, prettierrc, etc.)
- •Review README.md and documentation for context
Step 3: Extract Code Patterns
- •Use
rg(ripgrep) to search for common patterns (preferred over grep) - •Sample up to 800 lines per file (excluding imports)
- •Identify:
- •Logging and debugging patterns
- •Error handling approaches
- •Control flow conventions
- •Module organization
Step 4: Identify Conventions
- •Analyze naming patterns (camelCase, PascalCase, snake_case)
- •Review comment styles and documentation patterns
- •Note code organization and file structure preferences
- •Identify testing frameworks if present
Step 5: Generate AGENTS.md
- •Write 5 sections in order (see ./references/agents_md_template.md):
- •Overview (1-2 sentences)
- •Folder Structure (hierarchical, role-focused)
- •Core Behaviors & Patterns (from code analysis)
- •Conventions (naming, comments, style)
- •Working Agreements (compressed format)
- •Validate total character count
- •Write file to repository root
Example Output Quality
Good Overview Example
markdown
## 1. Overview A Groovy-based IntelliJ IDEA plugin providing AI-assisted code generation and refactoring capabilities.
Bad Overview Example (Too Detailed)
markdown
## 1. Overview This is an IntelliJ IDEA plugin written in Groovy using Gradle 8.5 and JDK 17. It uses Micronaut for dependency injection, Spock for testing, and integrates with OpenAI's API. The plugin provides features like code generation, refactoring suggestions, and natural language processing.
Common Mistakes to Avoid
- •Flat folder structure: Always show hierarchy with nested bullets
- •Generic descriptions: Explain roles, not just names ("UI components" not "UI folder")
- •Missing conventions: Always analyze actual code patterns, don't assume
- •Character overflow: Validate final output against limits
- •Execution instructions: Never include build/run/test commands