Video summary
How I Write My AGENTS.md Files - Best Practices
Main summary
Key takeaways
How I Write My AGENTS.md Files — Best Practices
What Agents.md is
agents.mdis an open, vendor-agnostic plain-text/Markdown format for supplying persistent instructions and context to coding AI agents.- It is supported/usable across different agent platforms (examples: Cursor, Claude, Google/Gemini-style systems).
- Purpose: keep recurring environment, style, and workflow constraints centrally defined so agents follow project-specific conventions without repeating the same prompt every conversation.
Keep a single source of truth for environment and workflow rules so agents consistently follow project conventions.
Demo setup (what the presenter did)
- Simple Django “sample project” used as a sandbox.
utils.pycontains math functions. - Demo: asked an LLM (demo used “sonnet 4.5”) to implement a function (nth Lucas number).
- Without
agents.md: agent used defaults (no type hints, incorrect command patterns). - With a root
agents.mdcontaining rules (e.g., “always use type hints”), the agent adapted and produced type-hinted code even if existing files lack hints. - Added a local (per-folder)
agents.mdin the mathematics app to override the global rule (e.g., “never use type hints here”). The agent honored the local override while keeping other rules (e.g., camelCase).
- Without
Key technical / practical points and behavior
- Platforms that support
agents.mdtreat these files as contextual instructions; you don’t need to paste the same instructions into each prompt. - You can compose multiple
agents.mdfiles (root + per-directory). More specific files can override broader ones. - Not foolproof: agents can still ignore boundaries (for example, run
gitcommands orrm) if explicitly instructed —agents.mdhelps reduce mistakes but doesn’t guarantee safety.
Best practices and recommended content
- Put commands early
- Specify how to run project commands so agents use the correct invocation.
- Example: for Django + uv workflows, state something like “use
uv; all Python commands must run withuv run.”
- Provide concrete examples rather than long prose
- For coding style, prefer “bad example → corrected example” over long textual descriptions.
- Specify stack and exact versions
- State precise versions (e.g., Python 3.12+, package manager, DB such as SQLite3, frameworks).
- Include a project structure / file tree
- A pasted
treeoutput or brief outline helps agents locate files and understand app responsibilities.
- A pasted
- Define coding conventions via examples
- Show examples for camelCase vs snake_case, type hint usage, etc., instead of exhaustive prose.
- Add ground rules and boundaries
- Examples: “Never delete files with
rm”, “Never rungitcommands” (note: agents may ignore these if asked directly).
- Examples: “Never delete files with
- State workflow constraints and environment details early
- Example: migrations must be run via
uv run manage.py migrate, or how to set up Tailwind/Vite/React.
- Example: migrations must be run via
- Prefer a single central file for global rules, with local
agents.mdfor exceptions- Use local files to disable or alter rules for specific directories/apps.
Use cases called out
- Ensuring correct commands and package manager usage (e.g., Django +
uvexample). - Environment-specific installs (Tailwind + Vite + React) where agents often fail without explicit instructions.
- Docker or package-manager setups.
- Testing and contribution workflows (can be referenced from a central
agents.mdor linkedCONTRIBUTING.md).
Limitations / cautions
- Agents may still perform unsafe or undesired operations if explicitly instructed (e.g., running
gitor deleting files). agents.mdreduces repeated mistakes but cannot fully enforce behavior.- If the codebase lacks consistent typing/style, align
agents.mdwith existing code to avoid friction.
What to include in your agents.md (concise checklist)
- Project overview and purpose
- Environment and exact versions (Python, package manager, DB, frameworks)
- Command examples (real, correct command lines)
- Coding style examples (bad/correct snippets)
- Project tree / file map
- Explicit rules and boundaries
- Any per-directory
agents.mdfor local overrides
Sources / main speakers
- Video presenter / author (YouTuber demoing the workflow; unnamed in subtitles)
- Agents.md best-practices documentation referenced in the video
- Demo project: “sample project” (basic Django app used in the walkthrough)
- Agent platforms and models referenced: Cursor, Claude, Gemini-style agents; demo model noted as “sonnet 4.5.”
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.