Sub topic 1
Why Coding Agents Need Project Context
Prerequisites
This chapter assumes basic Git, Markdown, and command-line workflows. You should know that repositories often have project-specific commands and conventions.
Why Coding Agents Need Project Context
A coding agent can edit files, run commands, and inspect tests. It still lacks important local knowledge unless the repository provides it. Generic advice such as “run the tests” does not tell an agent which command to use, which database must be running, or where business logic belongs.
Project context reduces guesswork. It helps an agent choose the repository’s existing tools instead of adding unnecessary dependencies or changing files in the wrong way. It also gives reviewers a shared description of how work should be done.
What AGENTS.md Is
AGENTS.md is a plain-text instruction file for AI coding agents. A repository usually places its main AGENTS.md at the root. The file describes commands, conventions, structure, and review expectations for that codebase.
The file is guidance, not executable configuration. An agent may still need clarification when instructions conflict with a user’s request or when the project has changed.
The File Format: Just Markdown
There are no required fields or special syntax. Use normal Markdown headings, paragraphs, and lists. Write instructions that a person could understand and verify.
Keep the file short enough to scan. Prefer exact commands and paths over broad preferences. Separate shared rules from details that apply only to one package or directory.
What to Put in AGENTS.md
Useful sections include:
- Setup: dependency installation, local services, environment preparation, and required runtime versions.
- Build and test: exact commands for building, testing one file, linting, and type-checking.
- Code style: naming, export, formatting, and architecture rules.
- Project structure: important directories and where new code belongs.
- Change rules: migration policies, generated files, and required tests.
- Pull requests: title format, review checks, and required documentation.
# AGENTS.md
## Setup
- Install dependencies: `npm ci`
- Start services: `docker compose up -d db`
## Verification
- Run: `npm run lint && npm test`
## Style
- Keep route handlers thin.
- Put business logic in `src/services/`.Exercise
Why is “Run the tests” weaker than “Run npm test -- path/to/file.test.ts for a focused change”?
Show answer
The exact command is actionable and verifiable, while the vague instruction leaves the agent to guess the test tool, scope, and arguments.