Skip to content

Commit 32fb5e8

Browse files
committed
gh-152315: Add agent guidance
1 parent 95039a6 commit 32fb5e8

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# AGENTS.md
2+
3+
Guidance for future agent work in this CPython checkout.
4+
5+
## Work From Repo Evidence
6+
7+
- Start by reading the local code, tests, and recent commits touching the same area. CPython patches are usually narrow and issue-scoped.
8+
- Prefer existing local patterns over new abstractions. If nearby code uses a helper, macro, assertion style, or test support utility, follow it.
9+
- Keep unrelated cleanup out of the patch. Reviewers expect a clear line from issue to code to tests to NEWS/docs.
10+
- Before changing behavior, make the current failure visible with a focused reproducer or a targeted test.
11+
12+
## C Code Changes
13+
14+
- Treat every new object-producing call as an error path. If a call can fail, either propagate the exception or deliberately avoid allocation.
15+
- Be explicit about reference ownership. Pair new references with cleanup on every path, and avoid converting borrowed/constant data into owned objects unless needed.
16+
- For OOM or NULL-handling fixes, preserve the original exception semantics and add only the minimum logic required.
17+
- Do not rely on string formatting, `__qualname__`, or naming conventions when an exact runtime check is available.
18+
- Keep comments sparse and useful. Add comments for non-obvious heuristics and ownership decisions, not for code that reads directly.
19+
20+
## Tests
21+
22+
- Add regression tests next to existing tests for the affected behavior, and keep assertions exact when CPython already has stable wording.
23+
- Include both the positive case and the closest false-positive cases. Descriptor and binding changes usually need instance, classmethod, staticmethod, and metaclass coverage.
24+
- Use descriptive fixtures and method names that make failure output understandable.
25+
- When changing error handling, test the precise error message or exception path rather than only testing that an exception was raised.
26+
- For test support improvements, prefer shared helpers over repeating skip or environment logic in many files.
27+
28+
## Docs And NEWS
29+
30+
- User-visible behavior changes normally need a `Misc/NEWS.d/next/...` entry.
31+
- If a reviewer asks for a What's New note, keep its wording aligned with the NEWS entry, with contributor credit in What's New only.
32+
- Use CPython reST roles such as `:exc:`, `:func:`, and `:gh:` where appropriate.
33+
- Documentation changes should describe the behavior, not the implementation detail.
34+
35+
## Reviews And PR Hygiene
36+
37+
- Fetch and read the full PR conversation before responding to review feedback. Inline review threads may contain follow-up comments that change the desired fix.
38+
- Group review feedback by behavior, not by file. Make sure each requested edge case is either covered by code/tests or explicitly called out as intentionally not addressed.
39+
- After requested changes are made, rerun focused tests and summarize exactly which reviewer concerns were addressed.
40+
- If Bedevere requests the standard review phrase, use it only after the relevant commits are pushed to the PR branch.
41+
42+
## Commands
43+
44+
- Build after C changes:
45+
```sh
46+
make -j8
47+
```
48+
- Run a focused test module:
49+
```sh
50+
./python.exe -m test test_call
51+
```
52+
- Check whitespace before committing:
53+
```sh
54+
git diff --check
55+
```
56+
- Inspect recent area-specific history:
57+
```sh
58+
git log --oneline --max-count=80 -- Lib/test Python Modules Objects Doc Misc
59+
```
60+
61+
## Commits
62+
63+
- Use CPython-style commit messages when possible: `gh-NNNNNN: Short imperative summary`.
64+
- Keep commits reviewable. A small follow-up commit is fine for review-driven naming, docs wording, or missing coverage.
65+
- Do not add promotional or generated-by footers to commits.
66+
- Stage only files intended for the PR. Leave local planning notes and scratch files untracked unless explicitly requested.

0 commit comments

Comments
 (0)