Skip to content

Commit 39ad01a

Browse files
authored
Add AGENTS.md
1 parent 15e757b commit 39ad01a

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding assistants (Claude, Codex, Cursor, etc.) when working with code in this repository.
4+
5+
Read the README.md for high level information about the project.
6+
7+
## Architecture Overivew
8+
9+
This project uses the [Katabole server framework](https://github.com/katabole/katabole).
10+
11+
## Code Style
12+
13+
### Comments
14+
15+
- Comments should explain *why*, not *what*.
16+
- Focus on non-obvious details, relevant design, intentional trade-offs, or important context.
17+
- Do not add comments that just summarize or repeat the code.
18+
- If the code is self-explanatory, no comment is needed.
19+
20+
### Variables
21+
22+
- Inline single use variables at their use sites if the expression is straight forward.
23+
- Intermediate variables are useful when they clarify intent or when the expression is complex.
24+
- Prefer defining and documenting constants over inline use of constant literals. The exception is for simple, trivial constants (e.g., `0`).
25+
26+
## Tests
27+
28+
Always add or change tests when appropriate.
29+
30+
The majority of your tests should be unit tests covering representative, realistic flows—do not litter the test files with every possible test, we are not fuzz testing here (though if you believe fuzz testing is necessary for a particularly security-sensitive component, you may recommend it)—as well as representative and important edge cases.
31+
32+
Tests should be human-readable and easy to follow along, and easily understood by a reader to be correct by visual inspection. So don't add too many abstractions or too much indirection in your tests.
33+
34+
For test cases covering one logical concept but with multiple potential sub-cases to be covered, follow the [subtest pattern](https://go.dev/blog/subtests) to parameterize a test case.
35+
36+
Follow the "arrange, act, assert" pattern.
37+
38+
After unit tests, the minority of your tests should be integration tests.
39+
40+
## Security
41+
42+
This is a server framework and template. Consequently, any issues here will be propagated and induce bugs in downstream dependents, so care needs to be taken with respect to correctness and especially security.
43+
44+
Always check for potential security issues, e.g., IDOR, SSRF, other confused deputy or abuse of server ambient authority issues, code injection or code execution, both preexisting and in new code.
45+
46+
Adhere to best practices and defense-in-depth. When planning, confirm with the user there is a clear authn and authz model and you understand it, and that it's consistently used throughout.
47+
48+
## Workflow Rules
49+
50+
Make sure you explore the code base and understand it before jumping into planning or coding.
51+
52+
Claude: Prefer using the Go LSP (gopls) plugin to navigate rather than `grep`ing or `find`ing symbols across the Go code.
53+
54+
Explore, interview and ask clarifying questions (if necessary), *then* plan. If there are open questions and multiple approaches, make a recommendation and explain tradeoffs.
55+
56+
### Making changes
57+
58+
- **Never commit directly to `main`.** Always create a feature branch and open a PR.
59+
- Always `go fmt` changed files.
60+
61+
### Submitting changes
62+
63+
Your commit messages and PR descriptions must be **concise**, **high level** summaries, and contain only the most salient information a reader should know.
64+
65+
Provide context, describe the problem or goal and motivation, summarize any design decisions made and any principles involved, if relevant, and summarize the key changes (existing behavior if relevant, new behavior), any outstanding TODOs or followups for the future. For each of these sections, only use them if they're relevant to the change.
66+
67+
DO NOT go into specific lines of code, specific files or line numbers. Keep it high level, focused on high level concepts, semantics, systems involved.
68+
69+
Don't add extra fluff about "Changes added: full test coverage" or "Test plan: add unit tests, all tests passed." It is taken for granted every change comes with relevant tests and they all pass. Only call out changes to tests if it's really important to know, e.g., fixing broken or incorrect tests, fixing gaps, etc.

0 commit comments

Comments
 (0)