sjennings/polyskills/writing-agent-context-files
Claude Code and agent skill by sjennings/polyskills
- community
Checking that the SKILL.md file is still in the repository.
Use when creating or updating AGENTS.md files for projects or subdirectories - covers top-level vs domain-level organization, capturing architectural intent and contracts, and mandatory freshness dates
Install
npx vskill@latest install sjennings/polyskills/writing-agent-context-filesSKILL.md
The same SKILL.md was published earlier as sjennings/polyskills/writing-agent-context-files.
Writing AGENTS.md Files
REQUIRED BACKGROUND: Read writing-agent-directives for foundational guidance on token efficiency, compliance techniques, and directive structure.
Core Principle
AGENTS.md files preserve project context so humans do not have to re-explain architectural intent every session.
Key distinction:
- Top-level: HOW to work in this codebase (commands, conventions)
- Subdirectory: WHY this piece exists and what it PROMISES (contracts, intent)
File Hierarchy
Agents and harnesses can use AGENTS.md files from the current directory up to the repository root:
Depth guideline: Typically one level (domain). Occasionally two (subdomain like auth/oauth2). Rarely more.
Top-Level AGENTS.md
Focuses on project-wide WHAT and HOW.
What to Include
| Section | Purpose | |
|---|---|---|
| Tech Stack | Framework, language, key dependencies | |
| Commands | Build, test, run commands | |
| Project Structure | Directory overview with purposes | |
| Conventions | Naming, patterns used project-wide | |
| Boundaries | What agents can/cannot edit |
Template
What NOT to Include
- Code style rules (use linters)
- Exhaustive command lists (reference package.json)
- Content that belongs in domain-level files
- Sensitive information (keys, credentials)
Subdirectory AGENTS.md (Domain-Level)
Focuses on WHY and CONTRACTS. The code shows WHAT; these files explain intent.
What to Include
| Section | Purpose | |
|---|---|---|
| Purpose | WHY this domain exists (not what it does) | |
| Contracts | What this domain PROMISES to others | |
| Dependencies | What it uses, what uses it, boundaries | |
| Key Decisions | ADR-lite: decisions and rationale | |
| Invariants | Things that must ALWAYS be true | |
| Gotchas | Non-obvious traps |
Template
Example: Auth Domain
Freshness Dates: MANDATORY
Every AGENTS.md MUST include a "Last verified" date.
CRITICAL: Use Bash to get the actual date. Do NOT hallucinate dates.
Include in file:
Why mandatory: Stale AGENTS.md files are worse than none. The date signals when contracts were last confirmed accurate.
Referencing Files
You can reference key files in AGENTS.md:
Do NOT use @ syntax (e.g., @./service.ts). This force-loads files into context, burning tokens. Just name the files; agents can read them when needed.
Heuristics: Top-Level vs Subdirectory
| Question | Top-level | Subdirectory | |
|---|---|---|---|
| Applies project-wide? | ✓ | ||
| New engineer needs on day 1? | ✓ | ||
| About commands/conventions? | ✓ | ||
| About WHY a component exists? | ✓ | ||
| About contracts between parts? | ✓ | ||
| Changes when the domain changes? | ✓ |
Rule of thumb:
- Top-level = "How to work here"
- Subdirectory = "Why this exists and what it promises"
When to Create Subdirectory AGENTS.md
Create when:
- Domain has non-obvious contracts with other parts
- Architectural decisions affect how code should evolve
- Invariants exist that aren't obvious from code
- New sessions consistently need the same context re-explained
Don't create for:
- Trivial utility folders
- Implementation details that change frequently
- Content better captured in code comments
Updating AGENTS.md Files
When updating any AGENTS.md:
- Update the freshness date using Bash
date +%Y-%m-%d - Verify contracts still hold - read the code, check invariants
- Remove stale content - better short and accurate than long and wrong
- Keep token-efficient - <300 lines top-level, <100 lines subdirectory
Common Mistakes
| Mistake | Fix | |
|---|---|---|
| Describing WHAT code does | Focus on WHY it exists, contracts it keeps | |
| Missing freshness date | Always include, always use Bash for real date | |
| Using @ to reference files | Just name files, let agents read on demand | |
| Too much detail | Subdirectory files should be <100 lines | |
| Duplicating parent content | Subdirectory inherits parent; don't repeat | |
| Stale contracts | Update when domain changes; verify dates |
Checklist
Top-level:
- [ ] Tech stack listed
- [ ] Key commands documented
- [ ] Project structure overview
- [ ] Freshness date (from
date +%Y-%m-%d)
Subdirectory:
- [ ] Purpose explains WHY (not what)
- [ ] Contracts: exposes, guarantees, expects
- [ ] Dependencies and boundaries clear
- [ ] Key decisions with rationale
- [ ] Invariants documented
- [ ] Freshness date (from
date +%Y-%m-%d) - [ ] Under 100 lines
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/writing-agent-context-files/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sjennings/polyskills/writing-agent-context-files)