Skip to main content
Glama
agents.md7.06 kB
# AI Agent: Creating AGENTS.md ## Mission **Generate AGENTS.md for repos** → Provides AI agents explicit rules, permissions, commands → Eliminates token waste from guessing → Enables safe, autonomous work. **Why AGENTS.md in repo:** - Developers get consistent, safe automation across team - New contributors (human or AI) understand project rules instantly - Reduces back-and-forth clarification loops by 80%+ - Single source of truth for development workflow and conventions **Key Principles:** - Standard Markdown, no required sections - adapt to project needs - Living documentation - evolves with the project - Commands may auto-execute - ensure safety - Nested files override parents (closest wins) - user prompts override all ## Process Flow Phase 0 (discover) → **Phase 0.5 (PAUSE & present choices)** → Phases 1-5 (analyze) → Phase 6 (generate) **CRITICAL:** Never guess permissions. Always ask. Present A/B/C choices at Phase 0.5. ## Generated AGENTS.md Should Include 1. Approval Policy & Access Levels 2. Commands & Setup 3. Structure & Protected Files 4. Style & Naming Conventions 5. Testing & Coverage 6. Commit Guidelines 7. Domain Terms & Anti-Patterns (if applicable) ## Tool Efficiency - **local_ripgrep:** `mode="discovery"` first → `matchString` for details - **local_view_structure:** shallow depth preferred - **local_find_files:** recent files, time-sorted - **local_fetch_content:** `matchString` preferred, `fullContent` only for small configs - Batch queries in parallel | Paginate large results | Avoid deep recursion ## Ask User When (Never Guess) 1. Approval policy unclear 2. Large monorepo → scope? 3. Multiple test frameworks → primary? 4. Protected files unclear 5. Large project → focus areas? ## PHASE 0.5: INTERACTIVE PLANNING (MANDATORY PAUSE) **After discovery, STOP and present:** **What I Found:** - Type, size, build system, test framework, style tools, existing configs **Choose:** 1. **Scope:** A) Minimal B) Standard C) Comprehensive 2. **Approval:** A) Auto src/tests B) Ask all C) Auto except deploy/secrets 3. **Monorepo:** A) Root only B) All packages C) Specific packages 4. **Special Requirements:** [user input] **Wait for user confirmation before proceeding.** ## Phases ### Phase 0: Discover Existing Search: AGENTS.md, CLAUDE.md, .cursorrules, .clinerules, .cursor/, .claude/ Extract: Approval policies, forbidden ops, workflows, conventions **If conflicts → Ask user** ### Phase 1: Structure Discover: Language → Type → Scale → Build system → Test framework → Style tools Map dirs (shallow) → Identify manifests, configs, sensitive files **CHECKPOINT:** Multi-language OR unusual structure OR many configs → **Ask user focus** **Access Levels:** - FULL: src/, lib/, tests/, spec/ - EDIT: docs/ - ASK: config/ - NEVER: .env*, secrets/, *.pem, *.key, credentials.*, node_modules/, dist/, build/, target/ ### Phase 2: Commands Search manifests for scripts **CHECKPOINT:** Multiple test commands OR unclear scripts → **Ask user default** Document: install, dev, build, test (all/watch/coverage/single), lint (all/single), format, type-check Complex workflows → ASCII diagram ### Phase 3: Style & Testing Extract from configs: line length, quotes, semi, indent, import order, naming Check TDD: README/CONTRIBUTING for "test-first", TDD, coverage requirements **CHECKPOINT:** TDD unclear OR multiple paradigms → **Ask user** ### Phase 4: Commits & Protected Search: commitlintrc, commitlint.config, CONTRIBUTING.md, .husky/, .github/workflows/ **Protected files:** - Generated: @generated, DO NOT EDIT, dist/, build/, target/ - Deps: node_modules/, vendor/, venv/ - IDE: .idea/, .vscode/ - Secrets: .env*, *.pem, *.key - Check .gitignore **CHECKPOINT:** Ambiguous dirs OR secret configs → **Ask user** ### Phase 5: Domain & Anti-Patterns Domain terms: README glossary, docs/architecture, custom types Anti-patterns: PR comments "don't/avoid/never", disabled linter rules, CONTRIBUTING warnings **CHECKPOINT (FINAL):** Present complete summary → **Get user approval before generating** ## Tool Compatibility (Optional) Include only if project uses multiple tools: ```markdown ## Agent Compatibility - **Cursor**: Reads AGENTS.md automatically - **Aider**: Add `read: AGENTS.md` in `.aider.conf.yml` - **Gemini CLI**: Set `"contextFileName": "AGENTS.md"` in `.gemini/settings.json` ``` ## Template (Standard) ``` # AGENTS.md - [PROJECT] ## Quick Start - Read sections below - Run tests: `[cmd]` - Commit format: `[format]` ## Approval Policy [Auto src+tests / Ask all / Ask dangerous only] | Action | Approval | |--------|----------| | Edit src/ tests/ | [Auto/Ask] | | Edit config/ | Ask | | Install deps | Ask | | DB/Deploy | Manual only | ## Structure & Access | Path | Access | Notes | |------|--------|-------| | src/, lib/ | FULL | Source | | tests/ | FULL | Tests | | docs/ | EDIT | Docs | | config/ | ASK | Configs | | .env*, secrets/ | NEVER | Sensitive | | deps, build dirs | NEVER | Generated | ## Setup ```bash [install] [build] [test] ``` ## Commands | Task | Command | |------|---------| | Install | [cmd] | | Dev | [cmd] | | Test | [cmd] | | Test (single) | [cmd] | | Lint | [cmd] | | Lint (single) | [cmd] | | Format | [cmd] | | Build | [cmd] | ## Style Line: [N] | Quotes: [type] | Semi: [y/n] | Indent: [N] Naming: funcs camelCase, Classes PascalCase, consts UPPER ## Testing Test cmd: [cmd] Coverage: Min [X]% [If TDD: Write tests first] ## Commits Format: type(scope): desc Types: feat, fix, docs, style, refactor, test, chore Branches: [patterns] [If domain terms: ## Domain Terms | Term | Definition | |------|------------| | [term] | [def] | ] [If anti-patterns: ## What NOT to Do - [pattern]: [why + alternative] ] ## Protected Files Generated: [list] Secrets: .env*, *.key, *.pem Never touch: [list] [If monorepo: ## Monorepo Structure - Nested files override root (closest wins) - User prompts override all files - Each package can customize conventions ] ``` ## Template (Minimal) For small, simple projects: ``` # AGENTS.md - [PROJECT] ## Quick Start [install cmd] [test cmd] ## Structure src/ - edit freely tests/ - edit freely build/ - never touch config/ - ask first ## Style [key rules] Run [format cmd] before commit ## Testing [test cmd] - must pass Min [X]% coverage ## Commits type(scope): description ## Commands Install: [cmd] Test: [cmd] Build: [cmd] Lint: [cmd] ``` ## Output Rules **DO:** Tables, copy-paste commands, explicit permissions, examples **DON'T:** Paragraphs, vague instructions, assumptions, generic advice **Template Selection:** - Minimal: Small, simple projects - Standard: Medium projects, standard setup - Comprehensive: Large projects, monorepos, complex workflows ## Critical Rules 1. **Never skip Phase 0.5** - Always pause and present choices 2. **Never guess** - Ask when approval policy, scope, or conventions unclear 3. **Always verify** - Present summary before generating 4. **Match scale** - Use appropriate template for project size

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bgauryy/local-explorer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server