Agent instructions: [Project name]
These rules apply to every coding agent that works in this repository, and to the people who review its work. Replace everything in [square brackets]. Delete any line that does not apply. A short, accurate file beats a long, stale one.
Project
- What it is: [One or two sentences. What the project does, who uses it, and what matters most, for example correctness of invoices or uptime of the public API.]
- Language and framework: [e.g. TypeScript with React and Node.js, or Python with FastAPI].
- Runtime versions: [e.g. Node.js 22, Python 3.12]. Use these versions. Do not upgrade them as a side effect of a task.
- Package manager: [npm / pnpm / yarn / uv / poetry / pip]. Use only this one.
- Layout:
[src/]application code[tests/]tests[scripts/]maintenance and one-off scripts[docs/]documentation and decision records- Start here: [entry point, main module or architecture document].
- Do not edit: [generated folders, vendored code, lock files by hand, migrations that have already run].
Commands
| Task | Command |
|---|---|
| Install dependencies | [install command] |
| Run locally | [dev command] |
| Format | [format command] |
| Check formatting | [format check command] |
| Lint | [lint command] |
| Type check | [type check command, or delete this row] |
| Run all tests | [test command] |
| Run one test file | [single test command] |
| Build | [build command, or delete this row] |
Use the scripts above. Do not switch package managers, add new tooling or change these commands unless the task is about tooling.
Code conventions
- Follow the formatter and linter configuration in the repository. Do not change their settings to make your code pass.
- Names say what a thing is or does. Avoid abbreviations that a new team member would have to guess.
- Keep functions small and focused. Return early instead of nesting deeply.
- Handle an error where you can do something useful about it. Otherwise let it propagate with context. Never swallow an exception silently.
- Comments explain why, not what. Delete commented-out code instead of leaving it behind.
- Keep public interfaces stable: HTTP APIs, exported functions, database columns, configuration keys, CLI flags and event names. Change them only when the task says so, and call the change out in your summary.
- Match the style of the file you are editing, even where you would have chosen differently.
- [Project-specific rule, for example: all money values are integers in the smallest currency unit.]
- [Project-specific rule, for example: dates are stored in UTC and converted only for display.]
Dependencies
- Do not add, remove or upgrade a dependency without asking first.
- When a new dependency is approved, choose a maintained, widely used package, install it with the project's package manager and commit the updated lock file.
- Prefer the standard library or an existing dependency over a new one for small tasks.
Testing
- New behaviour comes with tests. A bug fix comes with a test that fails before the fix and passes after it.
- Put tests next to the existing tests for that code and reuse their helpers and fixtures.
- Tests must not depend on the network, the real clock, random values without a seed, test order or shared state.
- Never delete, skip or weaken a test to make the suite pass. If you believe a test is wrong, say so and explain why.
- Full testing rules: [link to rules/testing.md or your own document].
Working style
- Read before you write. Look at the code around the change and the tests that cover it.
- Keep each change focused on the task. Do not rename, reformat or refactor unrelated code in the same change.
- Prefer editing existing files to creating new ones. Do not add documentation files unless asked.
- Ask before you start when:
- the request is ambiguous or has more than one reasonable reading
- the change would touch more than [10] files
- the change needs a new dependency, a schema change or a new environment variable
- you would need to change a public interface
- When you make an assumption, write it down in your summary.
- If you get stuck after two honest attempts at the same problem, stop and report what you tried instead of trying random changes.
Security and secrets
- Never commit secrets, tokens, API keys, passwords, private keys, session cookies or real customer data.
- Configuration comes from environment variables or the secret store. Keep
.envfiles out of git. List variable names, without values, in.env.example. - Never print a secret value in output, logs, tests, fixtures, screenshots or commit messages. Refer to it by name.
- Validate all external input at the boundary: requests, webhooks, uploaded files, queue messages and responses from third-party APIs.
- Use parameterised queries. Never build SQL, shell commands, file paths or HTML from input by string concatenation.
- Check authorisation on the server for every action and every object, not only in the user interface.
- Do not send code or data to outside services unless the task requires it.
- If you find a secret in the code, stop, report its location (not its value) and recommend rotating it.
- Full security rules: [link to rules/security-and-secrets.md or your own document].
Never do without explicit approval in this conversation
- Run destructive commands:
rm -rf,git reset --hard,git clean -fdx,git checkout -- .orgit restore .over uncommitted work, dropping or truncating tables, deleting cloud resources or storage buckets. - Force push, rewrite published history, or delete remote branches or tags.
- Push directly to
main,masteror a release branch, merge a pull request, publish a package or deploy. - Run migrations or scripts against shared, staging or production databases.
- Change CI/CD pipelines, infrastructure, DNS, authentication, permissions or billing configuration.
- Disable or skip tests, lint rules, type checks or security controls to get a passing build.
- Install global tools, change system settings or edit files outside this repository.
- Read or copy files that hold real credentials, such as
.env, key files or cloud credential folders. - Send email, messages or webhooks to real recipients.
Approval for one of these actions covers that action only. Ask again for the next one.
Git, commits and pull requests
- Branch names:
type/short-description, for examplefix/login-redirectorfeat/csv-export. - Commit messages follow Conventional Commits:
type(scope): summaryin the imperative mood, 72 characters or fewer. Types:feat,fix,docs,refactor,test,perf,build,ci,chore,revert. Use the body to explain why. Mark a breaking change with!after the type and aBREAKING CHANGE:footer. - One logical change per commit. Keep formatting-only changes in their own commit.
- Create commits only when asked. Never commit build output, local configuration, editor files or logs.
- Pull request descriptions cover:
- what changed and why
- how it was tested, with the commands you ran
- screenshots for user interface changes
- risks and how to roll back
- the linked issue: [issue tracker link format]
Before you say done
- Run the format check, linter, type checker and tests from the Commands table. If something fails and you cannot fix it, report exactly what fails and why.
- Run the build if the project has one.
- Read your own diff from top to bottom. Remove debug output, commented-out code, stray files and anything that looks like a secret.
- For user-facing changes, check the result in the running app where you can.
- Summarise:
- what changed and why
- the files you touched
- the commands you ran and their results
- what you could not verify
- assumptions and follow-up work
Never say that something works, passes or is fixed unless you ran it and saw the result. "I could not run this" is a useful answer. A confident guess is not.
Maintaining this file
Owner: [team or person]. Last reviewed: [YYYY-MM-DD]. Keep it under about 200 lines. When a rule stops being true, change it in the same pull request as the code that changed it.