Skip to content

Commit d900520

Browse files
committed
chore: add and example of AGENTS.md guidelines
1 parent f7a440d commit d900520

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# AGENTS.md
2+
3+
## Ground rules (always)
4+
- Be conservative, explicit, and boring.
5+
- When unsure, ask; don’t guess.
6+
- Make minimal, targeted changes; avoid refactors unless requested/necessary.
7+
- Preserve existing structure, conventions, and tooling.
8+
- Don’t add dependencies without strong justification.
9+
10+
## TypeScript
11+
- Write strict, idiomatic TS; follow the repo’s tsconfig and lint rules.
12+
- No `any` (use `unknown`, generics, or proper types).
13+
- Prefer `interface` for public shapes; `type` for unions/helpers.
14+
- Prefer immutability (`readonly`, `ReadonlyArray`) where practical.
15+
- Narrow with type guards; avoid assertions and `!` except as a last resort.
16+
- Prefer exhaustive handling (`never` checks) for unions.
17+
- Treat caught errors as `unknown` and narrow before use.
18+
19+
## Node.js
20+
- Target the repo’s supported Node LTS (don’t assume versions; check config/docs).
21+
- Prefer `async/await`; never swallow rejections.
22+
- Avoid module top-level side effects (I/O, network, reading env, global mutations) unless explicitly intended.
23+
- Env vars: validate centrally; read at runtime (not import-time); don’t mutate in app code (tests only with scoped setup/teardown).
24+
- Error handling: rethrow with context; preserve `cause` when available; don’t throw strings.
25+
- Library code should not log; CLIs may log intentionally with consistent exit codes.
26+
27+
## Testing (Vitest)
28+
- New logic requires tests unless truly trivial (types-only, re-exports, comments/formatting).
29+
- Tests must be deterministic and isolated; avoid shared mutable state.
30+
- Prefer behavioral tests; mock sparingly.
31+
- No committed `.only`/`.skip` (unless explicitly justified).
32+
- Bug fixes must include a regression test.
33+
- Avoid snapshots unless they add clear value and are stable.
34+
35+
## Style, docs, and security
36+
- Follow existing formatting/lint; keep functions small and readable.
37+
- Prefer named exports.
38+
- Update docs/comments when behavior changes (comments explain “why”, not “what”).
39+
- Never log secrets; validate/sanitize external inputs (paths/URLs/user data).
40+
- Dependency adds must be justified (need, alternatives, maintenance/license/security impact).
41+
42+
## MUST NOT
43+
- Change public APIs or introduce breaking changes without explicit instruction.
44+
- Perform stylistic rewrites or micro-optimizations.
45+
46+
## Verify before committing
47+
- Typecheck + lint + tests pass.
48+
- New behavior has coverage (including failure paths); no unintended snapshot changes.
49+
- No unnecessary diff churn; no accidental top-level side effects; env usage is validated and intentional.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- Reproducible environments thanks to [Volta][volta]
2222
- Example configuration for [GitHub Actions][gh-actions]
2323
- Simple example of TypeScript code and unit test
24+
- Basic [AGENTS.md][agents-md] guidelines for agents
2425

2526
🤲 Free as in speech: available under the APLv2 license.
2627

@@ -79,11 +80,15 @@ In 2023, my team and I gradually switched from Jest to [Vitest][vitest] in all t
7980

8081
Nevertheless, the choice of specific tooling always depends on the specific requirements and characteristics of the project.
8182

82-
### ES Modules
83+
### Why AGENTS.md over individual configs
84+
85+
The [AGENTS.md][agents-md] format has emerged as a community-driven standard, stewarded by the Agentic AI Foundation under the Linux Foundation. It is the closest thing to a universal config file, promoting consistency across AI coding tools.
8386

84-
This template uses native [ESM][esm]. Make sure to read [this][nodejs-esm], and [this][ts47-esm] first.
87+
The included guidelines are just an example. You should write your own, project-specific context and instructions.
88+
89+
### ES Modules
8590

86-
If your project requires CommonJS, you will have to [convert to ESM][sindresorhus-esm].
91+
This template uses native [ESM][esm]. Make sure to read [this][nodejs-esm], and [this][ts47-esm] first. If your project requires CommonJS, you will have to [convert to ESM][sindresorhus-esm].
8792

8893
Please do not open issues for questions regarding CommonJS or ESM on this repo.
8994

@@ -119,3 +124,4 @@ Licensed under the APLv2. See the [LICENSE](https://github.com/jsynowiec/node-ty
119124
[ts47-esm]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs
120125
[editorconfig]: https://editorconfig.org
121126
[vitest]: https://vitest.dev
127+
[agents-md]: https://agents.md

0 commit comments

Comments
 (0)