Skip to content

Commit d158dd8

Browse files
committed
augment(rules) Add .augment-guidelines
1 parent 0722e76 commit d158dd8

File tree

1 file changed

+328
-0
lines changed

1 file changed

+328
-0
lines changed

.augment-guidelines

+328
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
# Augment Guidelines
2+
3+
## Development Process
4+
5+
### Project Stack
6+
7+
The project uses the following tools and technologies:
8+
9+
- **uv** - Python package management and virtual environments
10+
- **ruff** - Fast Python linter and formatter
11+
- **py.test** - Testing framework
12+
- **pytest-watcher** - Continuous test runner
13+
- **mypy** - Static type checking
14+
- **doctest** - Testing code examples in documentation
15+
16+
### Development Workflow
17+
18+
1. **Start with Formatting**
19+
```
20+
uv run ruff format .
21+
```
22+
23+
2. **Run Tests**
24+
```
25+
uv run py.test
26+
```
27+
28+
For continuous testing during development, use pytest-watcher:
29+
```
30+
# Watch all tests
31+
uv run ptw .
32+
33+
# Watch and run tests immediately, including doctests
34+
uv run ptw . --now --doctest-modules
35+
36+
# Watch specific files or directories
37+
uv run ptw . --now --doctest-modules src/libtmux/_internal/
38+
```
39+
40+
3. **Commit Initial Changes**
41+
Make an atomic commit for your changes using conventional commits.
42+
43+
4. **Run Linting and Type Checking**
44+
```
45+
uv run ruff check . --fix --show-fixes
46+
uv run mypy
47+
```
48+
49+
5. **Verify Tests Again**
50+
```
51+
uv run py.test
52+
```
53+
54+
6. **Final Commit**
55+
Make a final commit with any linting/typing fixes.
56+
57+
### Python Code Standards
58+
59+
#### Docstring Guidelines
60+
61+
For `src/**/*.py` files, follow these docstring guidelines:
62+
63+
1. **Use reStructuredText format** for all docstrings.
64+
```python
65+
"""Short description of the function or class.
66+
67+
Detailed description using reStructuredText format.
68+
69+
Parameters
70+
----------
71+
param1 : type
72+
Description of param1
73+
param2 : type
74+
Description of param2
75+
76+
Returns
77+
-------
78+
type
79+
Description of return value
80+
"""
81+
```
82+
83+
2. **Keep the main description on the first line** after the opening `"""`.
84+
85+
3. **Use NumPy docstyle** for parameter and return value documentation.
86+
87+
#### Doctest Guidelines
88+
89+
For doctests in `src/**/*.py` files:
90+
91+
1. **Use narrative descriptions** for test sections rather than inline comments:
92+
```python
93+
"""Example function.
94+
95+
Examples
96+
--------
97+
Create an instance:
98+
99+
>>> obj = ExampleClass()
100+
101+
Verify a property:
102+
103+
>>> obj.property
104+
'expected value'
105+
"""
106+
```
107+
108+
2. **Move complex examples** to dedicated test files at `tests/examples/<path_to_module>/test_<example>.py` if they require elaborate setup or multiple steps.
109+
110+
3. **Utilize pytest fixtures** via `doctest_namespace` for more complex test scenarios:
111+
```python
112+
"""Example with fixture.
113+
114+
Examples
115+
--------
116+
>>> # doctest_namespace contains all pytest fixtures from conftest.py
117+
>>> example_fixture = getfixture('example_fixture')
118+
>>> example_fixture.method()
119+
'expected result'
120+
"""
121+
```
122+
123+
4. **Keep doctests simple and focused** on demonstrating usage rather than comprehensive testing.
124+
125+
5. **Add blank lines between test sections** for improved readability.
126+
127+
6. **Test your doctests continuously** using pytest-watcher during development:
128+
```
129+
# Watch specific modules for doctest changes
130+
uv run ptw . --now --doctest-modules src/path/to/module.py
131+
```
132+
133+
#### Pytest Testing Guidelines
134+
135+
1. **Use existing fixtures over mocks**:
136+
- Use fixtures from conftest.py instead of `monkeypatch` and `MagicMock` when available
137+
- For instance, if using libtmux, use provided fixtures: `server`, `session`, `window`, and `pane`
138+
- Document in test docstrings why standard fixtures weren't used for exceptional cases
139+
140+
2. **Preferred pytest patterns**:
141+
- Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile`
142+
- Use `monkeypatch` fixture over `unittest.mock`
143+
144+
#### Import Guidelines
145+
146+
1. **Prefer namespace imports**:
147+
- Import modules and access attributes through the namespace instead of importing specific symbols
148+
- Example: Use `import enum` and access `enum.Enum` instead of `from enum import Enum`
149+
- This applies to standard library modules like `pathlib`, `os`, and similar cases
150+
151+
2. **Standard aliases**:
152+
- For `typing` module, use `import typing as t`
153+
- Access typing elements via the namespace: `t.NamedTuple`, `t.TypedDict`, etc.
154+
- Note primitive types like unions can be done via `|` pipes and primitive types like list and dict can be done via `list` and `dict` directly.
155+
156+
3. **Benefits of namespace imports**:
157+
- Improves code readability by making the source of symbols clear
158+
- Reduces potential naming conflicts
159+
- Makes import statements more maintainable
160+
161+
## Git Commit Standards
162+
163+
### Commit Message Format
164+
```
165+
Component/File(commit-type[Subcomponent/method]): Concise description
166+
167+
why: Explanation of necessity or impact.
168+
what:
169+
- Specific technical changes made
170+
- Focused on a single topic
171+
172+
refs: #issue-number, breaking changes, or relevant links
173+
```
174+
175+
### Component Patterns
176+
#### General Code Changes
177+
```
178+
Component/File(feat[method]): Add feature
179+
Component/File(fix[method]): Fix bug
180+
Component/File(refactor[method]): Code restructure
181+
```
182+
183+
#### Packages and Dependencies
184+
| Language | Standard Packages | Dev Packages | Extras / Sub-packages |
185+
|------------|------------------------------------|-------------------------------|-----------------------------------------------|
186+
| General | `lang(deps):` | `lang(deps[dev]):` | |
187+
| Python | `py(deps):` | `py(deps[dev]):` | `py(deps[extra]):` |
188+
| JavaScript | `js(deps):` | `js(deps[dev]):` | `js(deps[subpackage]):`, `js(deps[dev{subpackage}]):` |
189+
190+
##### Examples
191+
- `py(deps[dev]): Update pytest to v8.1`
192+
- `js(deps[ui-components]): Upgrade Button component package`
193+
- `js(deps[dev{linting}]): Add ESLint plugin`
194+
195+
#### Documentation Changes
196+
Prefix with `docs:`
197+
```
198+
docs(Component/File[Subcomponent/method]): Update API usage guide
199+
```
200+
201+
#### Test Changes
202+
Prefix with `tests:`
203+
```
204+
tests(Component/File[Subcomponent/method]): Add edge case tests
205+
```
206+
207+
### Commit Types Summary
208+
- **feat**: New features or enhancements
209+
- **fix**: Bug fixes
210+
- **refactor**: Code restructuring without functional change
211+
- **docs**: Documentation updates
212+
- **chore**: Maintenance (dependencies, tooling, config)
213+
- **test**: Test-related updates
214+
- **style**: Code style and formatting
215+
216+
### General Guidelines
217+
- Subject line: Maximum 50 characters
218+
- Body lines: Maximum 72 characters
219+
- Use imperative mood (e.g., "Add", "Fix", not "Added", "Fixed")
220+
- Limit to one topic per commit
221+
- Separate subject from body with a blank line
222+
- Mark breaking changes clearly: `BREAKING:`
223+
- Use `See also:` to provide external references
224+
225+
### Good Commit Example
226+
```
227+
Pane(feat[capture_pane]): Add screenshot capture support
228+
229+
why: Provide visual debugging capability
230+
what:
231+
- Implement capturePane method with image export
232+
- Integrate with existing Pane component logic
233+
- Document usage in Pane README
234+
235+
refs: #485
236+
See also: https://example.com/docs/pane-capture
237+
```
238+
239+
### Bad Commit Example
240+
```
241+
fixed stuff and improved some functions
242+
```
243+
244+
## Avoiding Debug Loops
245+
246+
When debugging becomes circular and unproductive, follow these steps:
247+
248+
### Detection
249+
- You have made multiple unsuccessful attempts to fix the same issue
250+
- You are adding increasingly complex code to address errors
251+
- Each fix creates new errors in a cascading pattern
252+
- You are uncertain about the root cause after 2-3 iterations
253+
254+
### Action Plan
255+
256+
1. **Pause and acknowledge the loop**
257+
- Explicitly state that you are in a potential debug loop
258+
- Review what approaches have been tried and failed
259+
260+
2. **Minimize to MVP**
261+
- Remove all debugging cruft and experimental code
262+
- Revert to the simplest version that demonstrates the issue
263+
- Focus on isolating the core problem without added complexity
264+
265+
3. **Comprehensive Documentation**
266+
- Provide a clear summary of the issue
267+
- Include minimal but complete code examples that reproduce the problem
268+
- Document exact error messages and unexpected behaviors
269+
- Explain your current understanding of potential causes
270+
271+
4. **Format for Portability**
272+
- Present the problem in quadruple backticks for easy copying:
273+
274+
````
275+
# Problem Summary
276+
[Concise explanation of the issue]
277+
278+
## Minimal Reproduction Code
279+
```python
280+
# Minimal code example that reproduces the issue
281+
```
282+
283+
## Error/Unexpected Output
284+
```
285+
[Exact error messages or unexpected output]
286+
```
287+
288+
## Failed Approaches
289+
[Brief summary of approaches already tried]
290+
291+
## Suspected Cause
292+
[Your current hypothesis about what might be causing the issue]
293+
````
294+
295+
## LLM-Optimized Markdown Content Guidelines
296+
297+
When creating or editing markdown files within notes directories, adhere to the following guidelines:
298+
299+
1. **Conciseness and Clarity**:
300+
- **Be Brief**: Present information succinctly, avoiding unnecessary elaboration.
301+
- **Use Clear Language**: Employ straightforward language to convey ideas effectively.
302+
303+
2. **Structured Formatting**:
304+
- **Headings**: Utilize markdown headings (`#`, `##`, `###`, etc.) to organize content hierarchically.
305+
- **Lists**: Use bullet points (`-`) or numbered lists (`1.`, `2.`, etc.) to enumerate items clearly.
306+
- **Code Blocks**: Enclose code snippets within triple backticks (```) to distinguish them from regular text.
307+
308+
3. **Semantic Elements**:
309+
- **Emphasis**: Use asterisks (`*`) or underscores (`_`) for italicizing text to denote emphasis.
310+
- **Strong Emphasis**: Use double asterisks (`**`) or double underscores (`__`) for bold text to highlight critical points.
311+
- **Inline Code**: Use single backticks (`) for inline code references.
312+
313+
4. **Linking and References**:
314+
- **Hyperlinks**: Format links using `[Link Text](mdc:URL)` to provide direct access to external resources.
315+
- **References**: When citing sources, use footnotes or inline citations to maintain readability.
316+
317+
5. **Avoid Redundancy**:
318+
- **Eliminate Repetition**: Ensure that information is not unnecessarily repeated within the document.
319+
- **Use Summaries**: Provide brief summaries where detailed explanations are not essential.
320+
321+
6. **Standard Compliance**:
322+
- **llms.txt Conformance**: Structure the document in alignment with the `llms.txt` standard, which includes:
323+
- An H1 heading with the project or site name.
324+
- A blockquote summarizing the project's purpose.
325+
- Additional markdown sections providing detailed information.
326+
- H2-delimited sections containing lists of URLs for further details.
327+
328+
For more information on the `llms.txt` standard, refer to the official documentation: https://llmstxt.org/

0 commit comments

Comments
 (0)