Init Agents
Initialize or update AGENTS.md at project root — the instruction manual that tells AI coding assistants exactly how to work in this project.
What AGENTS.md Is
A vendor-agnostic markdown file that provides persistent, project-specific guidance to AI coding agents. Codex, OpenCode, Cursor, and GitHub Copilot read it. Claude Code uses CLAUDE.md instead — use the same content; the filename differs by tool.
Contains:
- Clear dos and don'ts (tech stack, versions, patterns)
- Executable commands (file-scoped type-check, lint, format, test)
- Project structure hints and key file locations
- Safety and permission boundaries
- Code style examples (good vs bad)
- Git workflow and PR checklist
Does NOT contain:
- Business rules (that belongs in
KNOWLEDGE.md)
- Product roadmap (not included in this document)
Tool Conventions
| Tool |
File |
Location |
| Codex |
AGENTS.md |
Project root, ~/.codex/AGENTS.md global |
| OpenCode |
AGENTS.md |
~/.config/opencode/AGENTS.md global |
| Cursor |
AGENTS.md or .cursor/rules/ |
Project root |
| Claude Code |
CLAUDE.md |
Project root |
| GitHub Copilot |
AGENTS.md |
.github/agents/*.md for specialized agents |
Project root AGENTS.md applies to Codex, Cursor, Copilot. Claude Code expects CLAUDE.md. When user mentions Claude Code specifically, create/update CLAUDE.md; otherwise use AGENTS.md.
Six Core Areas (Best Practice)
Effective agent files cover all six:
- Commands — Executable commands with flags (put early in the file)
- Testing — How to run tests, test-first expectations
- Project structure — Key paths, where things live
- Code style — Naming, formatting, patterns with examples
- Git workflow — Commit format, PR checklist
- Boundaries — Allowed / ask first / never
Format
# AGENTS.md
This file provides guidance to AI coding agents working in this repository.
## Project Overview
[1-2 sentences: what this project is, key stack]
## Commands
# Type-check single file
npm run tsc --noEmit path/to/file.ts
# Lint single file
npm run eslint --fix path/to/file.ts
# Format single file
npm run prettier --write path/to/file.ts
# Run tests (single file or suite)
npm test -- path/to/file.test.ts
## Project Structure
- `src/` — [purpose]
- `docs/` — [purpose]
- [key files that define architecture]
## Do
- [specific rule with versions/libraries]
- [specific rule]
## Don't
- [specific prohibition]
- [specific prohibition]
## Safety and Permissions
**Allowed without prompt:** [read files, run lint/format on single file, run single test]
**Ask first:** [package installs, git push, full build, schema changes]
**Never:** [commit secrets, edit vendor/, modify production configs]
## When Stuck
- Ask a clarifying question or propose a short plan
- Do not push large speculative changes without confirmation
Process
Step 1: Explore Project
Gather in parallel:
- Tech stack (package.json, composer.json, requirements.txt, go.mod, etc.) — versions matter
- Build/lint/test commands from scripts
- Project structure and key entry points
- Existing rules (
.cursorrules, .cursor/rules/, .github/copilot-instructions.md, CONTRIBUTING.md)
KNOWLEDGE.md, if it exists — reference it, don't duplicate
Step 2: Extract Commands
Find file-scoped commands (prefer over full-project builds):
- Type-check:
tsc --noEmit, pyright, etc.
- Lint:
eslint --fix, ruff check --fix, etc.
- Format:
prettier --write, black, etc.
- Test:
vitest run, pytest, jest, etc.
Include exact flags. Put commands early in the file.
Step 3: Define Boundaries
Three tiers:
- Always do — Run lint/test on changed files, follow style examples
- Ask first — Package installs, git push, full builds, schema changes
- Never — Commit secrets, edit vendor/node_modules, modify production configs
Step 4: Add Code Examples
Point to real files that demonstrate good patterns. Call out legacy code to avoid.
Examples beat paragraphs of description.
Step 5: Write or Merge
If AGENTS.md (or CLAUDE.md) exists:
- Read existing content
- Merge new sections (don't duplicate)
- Update outdated commands and structure
- Preserve user customizations
If it doesn't exist:
- Create from template above
- Fill with discovered project context
- Keep it concise — expand over time based on agent mistakes
Companion Documents
| Document |
Use When |
KNOWLEDGE.md |
Business context, domain rules, gotchas — suggest init-knowledge if missing |
When running init-agents, if companion docs exist, reference them in AGENTS.md (e.g. "See KNOWLEDGE.md for business context"). Don't duplicate their content.
Rules
- Just do it — no approval needed, write directly
- Be specific — "React 18 with TypeScript and Vite" not "React project"
- Commands first — put executable commands early, with flags
- Code examples over prose — one real snippet beats three paragraphs
- File-scoped commands — prefer single-file validation over full builds
- Never commit secrets — most common and valuable boundary
- Hierarchy — project
AGENTS.md overrides global; nested AGENTS.override.md for subdirs (Codex)
- Iterate — start minimal, add detail when agents make mistakes
1---2name: init-agents3description: Initialize or update AGENTS.md (or CLAUDE.md for Claude Code) with AI agent guidance. Use when user says 'init agents', 'create AGENTS.md', 'setup agent instructions', or wants project-specific AI coding assistant configuration.4---56# Init Agents78Initialize or update `AGENTS.md` at project root — the instruction manual that tells AI coding assistants exactly how to work in this project.910## What AGENTS.md Is1112A **vendor-agnostic markdown file** that provides persistent, project-specific guidance to AI coding agents. Codex, OpenCode, Cursor, and GitHub Copilot read it. Claude Code uses `CLAUDE.md` instead — use the same content; the filename differs by tool.1314**Contains:**15- Clear dos and don'ts (tech stack, versions, patterns)16- Executable commands (file-scoped type-check, lint, format, test)17- Project structure hints and key file locations18- Safety and permission boundaries19- Code style examples (good vs bad)20- Git workflow and PR checklist2122**Does NOT contain:**23- Business rules (that belongs in `KNOWLEDGE.md`)24- Product roadmap (not included in this document)2526## Tool Conventions2728| Tool | File | Location |29|------|------|----------|30| Codex | `AGENTS.md` | Project root, `~/.codex/AGENTS.md` global |31| OpenCode | `AGENTS.md` | `~/.config/opencode/AGENTS.md` global |32| Cursor | `AGENTS.md` or `.cursor/rules/` | Project root |33| Claude Code | `CLAUDE.md` | Project root |34| GitHub Copilot | `AGENTS.md` | `.github/agents/*.md` for specialized agents |3536Project root `AGENTS.md` applies to Codex, Cursor, Copilot. Claude Code expects `CLAUDE.md`. When user mentions Claude Code specifically, create/update `CLAUDE.md`; otherwise use `AGENTS.md`.3738## Six Core Areas (Best Practice)3940Effective agent files cover all six:41421. **Commands** — Executable commands with flags (put early in the file)432. **Testing** — How to run tests, test-first expectations443. **Project structure** — Key paths, where things live454. **Code style** — Naming, formatting, patterns with examples465. **Git workflow** — Commit format, PR checklist476. **Boundaries** — Allowed / ask first / never4849## Format5051```markdown52# AGENTS.md5354This file provides guidance to AI coding agents working in this repository.5556## Project Overview57[1-2 sentences: what this project is, key stack]5859## Commands60# Type-check single file61npm run tsc --noEmit path/to/file.ts6263# Lint single file64npm run eslint --fix path/to/file.ts6566# Format single file67npm run prettier --write path/to/file.ts6869# Run tests (single file or suite)70npm test -- path/to/file.test.ts7172## Project Structure73- `src/` — [purpose]74- `docs/` — [purpose]75- [key files that define architecture]7677## Do78- [specific rule with versions/libraries]79- [specific rule]8081## Don't82- [specific prohibition]83- [specific prohibition]8485## Safety and Permissions86**Allowed without prompt:** [read files, run lint/format on single file, run single test]87**Ask first:** [package installs, git push, full build, schema changes]88**Never:** [commit secrets, edit vendor/, modify production configs]8990## When Stuck91- Ask a clarifying question or propose a short plan92- Do not push large speculative changes without confirmation93```9495## Process9697### Step 1: Explore Project9899Gather in parallel:100- Tech stack (package.json, composer.json, requirements.txt, go.mod, etc.) — versions matter101- Build/lint/test commands from scripts102- Project structure and key entry points103- Existing rules (`.cursorrules`, `.cursor/rules/`, `.github/copilot-instructions.md`, `CONTRIBUTING.md`)104- `KNOWLEDGE.md`, if it exists — reference it, don't duplicate105106### Step 2: Extract Commands107108Find file-scoped commands (prefer over full-project builds):109- Type-check: `tsc --noEmit`, `pyright`, etc.110- Lint: `eslint --fix`, `ruff check --fix`, etc.111- Format: `prettier --write`, `black`, etc.112- Test: `vitest run`, `pytest`, `jest`, etc.113114Include exact flags. Put commands early in the file.115116### Step 3: Define Boundaries117118Three tiers:119- **Always do** — Run lint/test on changed files, follow style examples120- **Ask first** — Package installs, git push, full builds, schema changes121- **Never** — Commit secrets, edit vendor/node_modules, modify production configs122123### Step 4: Add Code Examples124125Point to real files that demonstrate good patterns. Call out legacy code to avoid.126Examples beat paragraphs of description.127128### Step 5: Write or Merge129130**If `AGENTS.md` (or `CLAUDE.md`) exists:**1311. Read existing content1322. Merge new sections (don't duplicate)1333. Update outdated commands and structure1344. Preserve user customizations135136**If it doesn't exist:**1371. Create from template above1382. Fill with discovered project context1393. Keep it concise — expand over time based on agent mistakes140141## Companion Documents142143| Document | Use When |144|----------|----------|145| `KNOWLEDGE.md` | Business context, domain rules, gotchas — suggest `init-knowledge` if missing |146147When running init-agents, if companion docs exist, reference them in AGENTS.md (e.g. "See KNOWLEDGE.md for business context"). Don't duplicate their content.148149## Rules150151- **Just do it** — no approval needed, write directly152- **Be specific** — "React 18 with TypeScript and Vite" not "React project"153- **Commands first** — put executable commands early, with flags154- **Code examples over prose** — one real snippet beats three paragraphs155- **File-scoped commands** — prefer single-file validation over full builds156- **Never commit secrets** — most common and valuable boundary157- **Hierarchy** — project `AGENTS.md` overrides global; nested `AGENTS.override.md` for subdirs (Codex)158- **Iterate** — start minimal, add detail when agents make mistakes