agents-md-generator
NewGenerate and optimize AGENTS.md project documentation for AI coding agents. Scans project structure, detects tech stacks, extracts build/test/lint commands, and produces ready-to-use AGENTS.md files. Also audits existing AGENTS.md for completeness, accuracy, and best practices. Supports multi-editor output including TRAE, OpenCode, Cursor, Claude Code, and more. Use when the user asks to create, generate, update, or review AGENTS.md, or mentions project documentation for AI agents.
Overview
AGENTS.md Generator & Auditor
Generate, optimize, and audit AGENTS.md documentation for AI coding agents. Supports 30+ agent platforms.
When to Use
- •User asks to "create AGENTS.md", "generate AGENTS.md", or "write AGENTS.md"
- •User wants to "update" or "optimize" an existing AGENTS.md
- •User asks to "review" or "audit" their AGENTS.md
- •User mentions project documentation for AI agents or coding assistants
- •User wants to generate agent config files for specific editors (TRAE, Cursor, etc.)
Workflow Selection
Creating or regenerating AGENTS.md? -> Follow "Generator Workflow" Improving an existing AGENTS.md? -> Follow "Auditor Workflow" Need editor-specific configs? -> Follow "Multi-Editor Export" after generating
Generator Workflow
Step 1: Scan the Project
Run the scan script to detect the tech stack:
python scripts/scan-project.py /path/to/projectThis outputs a JSON summary with:
- •
language: Primary language(s) detected - •
frameworks: Frameworks and libraries - •
package_manager: npm/pnpm/yarn/pip/go/cargo etc. - •
commands: Build, test, lint, start, dev commands - •
test_framework: Testing tools detected - •
ci_cd: CI/CD platform if detected - •
directory_structure: Key directories and their purposes - •
has_existing_agents_md: Whether AGENTS.md already exists
Step 2: Read Existing Context
Check for existing project documentation:
- •Read existing AGENTS.md, README.md, CONTRIBUTING.md
- •Read configuration files (package.json, tsconfig.json, pyproject.toml, etc.)
- •Check for .env.example, docker-compose.yml, Makefile
Step 3: Generate AGENTS.md
Use the scan results and context to generate AGENTS.md following the standard template. See reference.md for the full template and section definitions.
Required sections (always include):
- Project Overview - what the project is, its purpose
- Commands - build, test, lint, format, start, dev
- Architecture - directory structure with descriptions
- Code Style - formatting rules, naming conventions
- Key Constraints - security rules, forbidden actions
Optional sections (include when relevant):
- Development Workflow - PR process, branching strategy
- Testing Strategy - test commands, coverage requirements
- Environment Setup - required tools, env variables
- API Reference - key endpoints or interfaces
- Common Pitfalls - known issues, debugging tips
Step 4: Validate the Output
After generating, verify:
- •All commands are accurate (check against package.json scripts, Makefile, etc.)
- •Directory structure matches actual project layout
- •No placeholder text remains (e.g., "TODO", "INSERT HERE")
- •Security constraints are appropriate for the project type
Auditor Workflow
Step 1: Run the Audit Script
python scripts/audit-agents.py /path/to/project/AGENTS.md --project-root /path/to/projectThis outputs:
- •
score: Quality score 0-100 - •
issues: List of problems found (critical/warning/info) - •
suggestions: Specific improvement recommendations - •
missing_sections: Required sections not present
Step 2: Review Audit Results
Evaluate each issue by severity:
Critical - Must fix:
- •Missing project overview or commands section
- •Commands that don't actually work in the project
- •Missing security constraints (e.g., "never modify .env files")
- •Incorrect directory structure descriptions
Warning - Should fix:
- •Vague descriptions that could mislead the AI agent
- •Missing optional but valuable sections
- •Outdated information not matching current project state
- •Commands without descriptions
Info - Nice to have:
- •Formatting inconsistencies
- •Missing examples in sections
- •Sections that could be more concise
Step 3: Apply Fixes
For each issue, make targeted edits to the AGENTS.md file. Prioritize critical issues first.
Step 4: Re-audit
Run the audit script again to confirm the score has improved and critical issues are resolved.
Multi-Editor Export
After generating AGENTS.md, export to editor-specific formats when requested.
Supported Editors and File Paths
| Editor | File | Project Location | Global Location |
|---|---|---|---|
| Universal | AGENTS.md | Project root | - |
| Claude Code | CLAUDE.md | Project root | ~/.claude/CLAUDE.md |
| Cursor | .cursorrules | Project root | - |
| TRAE | .trae/rules.md | Project root | ~/.trae/rules.md |
| TRAE CN | .trae/rules.md | Project root | ~/.trae-cn/rules.md |
| OpenCode | AGENTS.md | .agents/skills/ | ~/.config/opencode/ |
| Windsurf | .windsurfrules | Project root | - |
| Qoder | AGENTS.md | Project root | ~/.qoder/ |
| Cline | .clinerules | Project root | - |
| Roo Code | .roo/rules.md | Project root | - |
| Augment | .augment/rules.md | Project root | - |
| Gemini CLI | GEMINI.md | Project root | ~/.gemini/ |
Export Process
- Generate the universal AGENTS.md first
- For each requested editor, apply format adaptations from reference.md
- Write each file to the appropriate location
- Report which files were created
Format Adaptations by Editor
AGENTS.md (universal): Standard markdown, all sections.
CLAUDE.md: Same as AGENTS.md. No format changes needed.
.cursorrules: Flatten markdown - use plain text rules instead of headers. Remove table formatting. Use --- separators between sections.
.trae/rules.md: Same as AGENTS.md format.
.windsurfrules: Concatenate all sections into a single rules block. Use RULE: prefix for each rule.
.clinerules: Plain text, one rule per line. Use # comments for section headers.
Generation Best Practices
Writing Effective Commands
Always specify the exact command, not a description:
# Bad
Run the tests
# Good
pnpm testFor multi-language projects, show all relevant commands:
# Frontend tests
pnpm --filter frontend test
# Backend tests
cd backend && go test ./...Architecture Section
Keep directory trees shallow (2-3 levels max). Focus on directories the AI agent will need to modify:
src/
components/ # React components
services/ # API service layer
utils/ # Shared utilitiesSecurity Constraints
Always include a security section for projects with:
- •Environment variables (never modify .env, .env.local, etc.)
- •Database migrations (always review before running)
- •Production deployments (never deploy without approval)
- •Sensitive data handling (PII, credentials, tokens)
Tone and Style
Write AGENTS.md in a direct, imperative style:
- •"Run
pnpm testbefore committing" not "You should run pnpm test before committing" - •"Never modify files in generated/" not "Please don't modify files in generated/"
Troubleshooting
| Problem | Solution |
|---|---|
| Scan script finds wrong language | Check for monorepo structure; may need to specify subdirectory |
| Commands not detected | Manually check package.json scripts, Makefile, or justfile |
| Audit score very low | Focus on adding missing required sections first |
| Export to editor fails | Check file permissions and that the target directory exists |
Install & Usage
mkdir -p .claude/agentsAdd the configuration to .claude/agents/agents-md-generator.md
@agents-md-generatorSecurity Audits
Frequently Asked Questions
What is agents-md-generator?
Generate and optimize AGENTS.md project documentation for AI coding agents. Scans project structure, detects tech stacks, extracts build/test/lint commands, and produces ready-to-use AGENTS.md files. Also audits existing AGENTS.md for completeness, accuracy, and best practices. Supports multi-editor output including TRAE, OpenCode, Cursor, Claude Code, and more. Use when the user asks to create, generate, update, or review AGENTS.md, or mentions project documentation for AI agents.
How to install agents-md-generator?
To install agents-md-generator: create the agents directory (mkdir -p .claude/agents), then add the config to .claude/agents/agents-md-generator.md. Finally, @agents-md-generator in Claude Code.
What is agents-md-generator best for?
agents-md-generator is a agent categorized under General. It is designed for: testing, code-review, documentation, agent. Created by wsjwu58-cmd.