Skip to content

Commit a09f306

Browse files
Merge pull request #1010 from LalatenduMohanty/concise-docs-guidance
docs(agents): reduce duplication and add concise writing guidance
2 parents 10daf52 + c44e85d commit a09f306

1 file changed

Lines changed: 33 additions & 142 deletions

File tree

AGENTS.md

Lines changed: 33 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,58 @@
22

33
> **Note**: This file is also available as `CLAUDE.md` (symlink) for Claude Code CLI users.
44
>
5-
> **IMPORTANT**: Before making any code changes, you MUST read [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive coding standards and design patterns. This file provides essential quick reference only.
6-
7-
## When to Read CONTRIBUTING.md
8-
9-
**Always read CONTRIBUTING.md before:**
10-
11-
- Writing new functions (for type annotation standards)
12-
- Adding imports (for import organization rules)
13-
- Creating tests (for testing patterns)
14-
- Making commits (for commit message format)
15-
- Adding error handling or logging
5+
> Read [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive coding standards, design patterns, and commit message format. This file provides agent-specific quick reference only.
166
177
## Essential Rules (MUST FOLLOW)
188

199
### Do
2010

11+
- Keep all written text concise and easy to understand — docstrings, comments, commit messages, PR descriptions, and documentation
2112
- Add docstrings on all public functions and classes
2213
- Use file-scoped commands for fast feedback (see below)
23-
- Follow existing patterns - search codebase for similar code
14+
- Follow existing patterns search codebase for similar code
2415
- Chain exceptions: `raise ValueError(...) from err`
2516
- Use `req_ctxvar_context()` for per-requirement logging
26-
- Run `hatch run lint:fix` to format code (handles line length, whitespace, etc.)
17+
- Run `hatch run lint:fix` to format code
2718

2819
### Don't
2920

3021
- Don't run full test suite for small changes (use file-scoped)
3122
- Don't create temporary helper scripts or workarounds
3223
- Don't commit without running quality checks
33-
- Don't make large speculative changes without asking
24+
- Don't make large speculative changes — ask first or propose a plan
3425
- Don't update git config or force push to main
35-
- Don't use bare `except:` - always specify exception types
26+
- Don't use bare `except:` — always specify exception types
27+
- Don't invent new patterns — search the codebase for existing ones
3628

3729
## Commands (IMPORTANT: Use File-Scoped First)
3830

39-
### Setup Commands (Run Once)
31+
### Setup (Run Once)
4032

4133
```bash
42-
# Install pre-commit hooks for automatic file formatting
43-
hatch run lint:install-hooks
34+
hatch run lint:install-hooks # Pre-commit hooks for automatic formatting
4435
```
4536

46-
### File-Scoped Commands (PREFER THESE)
37+
### File-Scoped (PREFER THESE)
4738

4839
```bash
49-
# Type check single file
50-
hatch run mypy:check <filepath>
51-
52-
# Format single file
53-
hatch run lint:fix <filepath>
54-
55-
# Test specific file
56-
hatch run test:test tests/test_<module>.py
57-
58-
# Test specific function
59-
hatch run test:test tests/test_<module>.py::test_function_name
60-
61-
# Debug test with verbose output
62-
hatch run test:test <filepath> --log-level DEBUG
40+
hatch run mypy:check <filepath> # Type check single file
41+
hatch run lint:fix <filepath> # Format single file
42+
hatch run test:test tests/test_<module>.py # Test specific file
43+
hatch run test:test tests/test_<module>.py::test_name # Test specific function
44+
hatch run test:test <filepath> --log-level DEBUG # Debug test
6345
```
6446

65-
### Project-Wide Commands (ASK BEFORE RUNNING)
47+
### Project-Wide (ASK BEFORE RUNNING)
6648

6749
```bash
6850
hatch run lint:fix # Format all code
6951
hatch run test:test # Full test suite (slow!)
7052
hatch run mypy:check # Type check everything
7153
hatch run lint:check # Final lint check
72-
hatch run lint:precommit # All linters and other pre-commit hooks
54+
hatch run lint:precommit # All linters and pre-commit hooks
7355
```
7456

75-
### Pre-commit Hooks
76-
77-
Run all linters and formatters via pre-commit:
78-
79-
```bash
80-
hatch run lint:precommit # Run all hooks manually
81-
```
82-
83-
Pre-commit runs automatically on commit after installation with `hatch run lint:install-hooks`.
84-
85-
**Markdown formatting:** The mdformat hook formats Markdown files using a pure Python formatter with GitHub Flavored Markdown support.
86-
8757
## Safety and Permissions
8858

8959
### Allowed Without Asking
@@ -104,14 +74,14 @@ Pre-commit runs automatically on commit after installation with `hatch run lint:
10474

10575
## Project Structure
10676

107-
- `src/fromager/` - Main package code
108-
- `tests/` - Unit tests (mirror `src/` structure)
109-
- `e2e/` - End-to-end integration tests
110-
- `docs/` - Sphinx documentation
77+
- `src/fromager/` Main package code
78+
- `tests/` Unit tests (mirror `src/` structure)
79+
- `e2e/` End-to-end integration tests
80+
- `docs/` Sphinx documentation
11181

11282
### Reference Files for Patterns
11383

114-
**Before writing code, look at these examples:**
84+
Look at these before writing code:
11585

11686
- Type annotations: `src/fromager/context.py`
11787
- Pydantic models: `src/fromager/packagesettings.py`
@@ -121,112 +91,33 @@ Pre-commit runs automatically on commit after installation with `hatch run lint:
12191

12292
## Code Patterns
12393

124-
**Import Guidelines (ALWAYS FOLLOW):**
125-
126-
- **PEP 8: imports should be at the top**: All import statements MUST be placed at the top of the file, after module docstrings and before other code. This applies to ALL Python files in the project.
127-
- **No local imports**: Do not place import statements inside functions, methods, or conditional blocks under any circumstances
128-
129-
### Testing Pattern
130-
131-
```python
132-
def test_behavior(tmp_path: pathlib.Path) -> None:
133-
"""Verify expected behavior."""
134-
# Arrange
135-
config = tmp_path / "config.txt"
136-
config.write_text("key=value\n")
137-
# Act
138-
result = load_config(config)
139-
# Assert
140-
assert result["key"] == "value"
141-
```
142-
143-
## Commit Message Format (REQUIRED)
144-
145-
Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format:
146-
147-
```text
148-
<type>(<scope>): <short summary>
149-
150-
<body explaining what + why>
94+
**Import rules:** All imports at the top of the file, no local imports. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
15195

152-
<footer: Closes: #123>
153-
```
96+
**Testing:** Use Arrange/Act/Assert pattern, name functions `test_<behavior>()`. See `tests/test_context.py` for examples.
15497

155-
### Types
98+
## Commit Messages
15699

157-
- **feat**: new functionality
158-
- **fix**: bug fix
159-
- **docs**: documentation only
160-
- **test**: tests only
161-
- **refactor**: behavioral no-op refactor
162-
- **perf**: performance improvement
163-
- **chore**: tooling or dependency change
100+
Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) — see [CONTRIBUTING.md](CONTRIBUTING.md) for format, types, and examples.
164101

165-
### Good Examples
102+
When AI agents create or significantly modify code, add attribution:
166103

167104
```text
168-
feat(resolver): add exponential backoff for HTTP retries
169-
170-
Improves resilience when PyPI is under load by adding jittered backoff.
171-
172-
Closes: #123
173-
```
174-
175-
```text
176-
fix(constraints): handle missing constraint file gracefully
177-
178-
Validate file existence and emit helpful message instead of crashing.
179-
```
105+
feat(scope): short summary
180106
181-
### AI Agent Attribution
182-
183-
When AI agents create or significantly modify code, add attribution using `Co-Authored-By`:
184-
185-
```text
186-
feat(resolver): add exponential backoff for HTTP retries
187-
188-
Improves resilience when PyPI is under load by adding jittered backoff.
107+
Body explaining what and why.
189108
190109
Co-Authored-By: Claude <claude@anthropic.com>
191110
Closes: #123
192111
```
193112

194-
### Bad Examples (NEVER DO THIS)
195-
196-
- `fix bug` (too vague)
197-
- `updated files` (not descriptive)
198-
- `WIP` (not informative)
199-
- `fixed the thing that was broken` (not professional)
200-
201113
## Workflow for Complex Tasks
202114

203115
1. **Search codebase** for similar patterns first
204-
2. **Create a checklist** in a markdown file for tracking
205-
3. **Work through items systematically** one at a time
116+
2. **Create a checklist** for tracking progress
117+
3. **Work through items** one at a time
206118
4. **Run file-scoped tests** after each change
207-
5. **Check off completed items** before moving to next
208-
6. **Run full quality checks** only at the end
209-
210-
## When Uncertain
211-
212-
- Ask clarifying questions rather than making assumptions
213-
- Search the codebase for similar patterns before inventing new ones
214-
- Propose a specific plan before making large changes
215-
- Reference [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidance
216-
- **DO NOT** make large speculative changes without confirmation
217-
218-
## Quality Checklist Before Finishing
219-
220-
- [ ] Read CONTRIBUTING.md for relevant standards
221-
- [ ] Type annotations on all functions
222-
- [ ] Docstrings on public APIs
223-
- [ ] Tests cover the change
224-
- [ ] File-scoped tests pass
225-
- [ ] No trailing whitespace
226-
- [ ] File ends with single newline
227-
- [ ] Conventional Commit format used
228-
- [ ] Full quality checks pass: `hatch run lint:fix && hatch run test:test && hatch run mypy:check && hatch run lint:check`
119+
5. **Run full quality checks** only at the end: `hatch run lint:fix && hatch run test:test && hatch run mypy:check && hatch run lint:check`
229120

230121
---
231122

232-
**See [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive standards, detailed examples, and design patterns used in Fromager.**
123+
**See [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive standards, detailed examples, and design patterns.**

0 commit comments

Comments
 (0)