Skip to content

Commit 3b17dfd

Browse files
committed
ai(rules[claude]) Link CLAUDE.md -> AGENTS.md (flip files)
1 parent a163312 commit 3b17dfd

File tree

2 files changed

+246
-246
lines changed

2 files changed

+246
-246
lines changed

AGENTS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

AGENTS.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## CRITICAL REQUIREMENTS
6+
7+
### Test Success
8+
- ALL tests MUST pass for code to be considered complete and working
9+
- Never describe code as "working as expected" if there are ANY failing tests
10+
- Even if specific feature tests pass, failing tests elsewhere indicate broken functionality
11+
- Changes that break existing tests must be fixed before considering implementation complete
12+
- A successful implementation must pass linting, type checking, AND all existing tests
13+
14+
## Project Overview
15+
16+
vcspull is a Python tool for managing and synchronizing multiple git, svn, and mercurial repositories via YAML or JSON configuration files. It allows users to pull/update multiple repositories in a single command, optionally filtering by repository name, path, or VCS URL.
17+
18+
## Development Environment
19+
20+
### Setup and Installation
21+
22+
```bash
23+
# Install development dependencies with uv
24+
uv pip install -e .
25+
26+
# Alternative: Use uv sync to install from pyproject.toml
27+
uv sync
28+
```
29+
30+
### Common Commands
31+
32+
#### Testing
33+
34+
```bash
35+
# Run all tests
36+
uv run pytest
37+
38+
# Run specific test(s)
39+
uv run pytest tests/test_cli.py
40+
uv run pytest tests/test_cli.py::test_sync
41+
42+
# Watch mode for tests (auto re-run on file changes)
43+
uv run ptw .
44+
# or
45+
make start
46+
47+
# Run tests with coverage
48+
uv run py.test --cov -v
49+
```
50+
51+
#### Code Quality
52+
53+
```bash
54+
# Format code with ruff
55+
uv run ruff format .
56+
# or
57+
make ruff_format
58+
59+
# Run ruff linting with auto-fixes
60+
uv run ruff check . --fix --show-fixes
61+
# or
62+
make ruff
63+
64+
# Run mypy type checking
65+
uv run mypy
66+
# or
67+
make mypy
68+
69+
# Watch mode for linting (using entr)
70+
make watch_ruff
71+
make watch_mypy
72+
```
73+
74+
#### Documentation
75+
76+
```bash
77+
# Build documentation
78+
make build_docs
79+
80+
# Start documentation server (auto-reload)
81+
make start_docs
82+
```
83+
84+
## Development Process
85+
86+
Follow this workflow for code changes:
87+
88+
1. **Format First**: `uv run ruff format .`
89+
2. **Run Tests**: `uv run py.test`
90+
3. **Run Linting**: `uv run ruff check . --fix --show-fixes`
91+
4. **Check Types**: `uv run mypy`
92+
5. **Verify Tests Again**: `uv run py.test`
93+
94+
## Code Architecture
95+
96+
### Core Components
97+
98+
1. **Configuration**
99+
- `config.py`: Handles loading and parsing of YAML/JSON configuration files
100+
- `_internal/config_reader.py`: Low-level config file reading
101+
102+
2. **CLI**
103+
- `cli/__init__.py`: Main CLI entry point with argument parsing
104+
- `cli/sync.py`: Repository synchronization functionality
105+
- `cli/add.py`: Adding new repositories to configuration
106+
107+
3. **Repository Management**
108+
- Uses `libvcs` package for VCS operations (git, svn, hg)
109+
- Supports custom remotes and URL schemes
110+
111+
### Configuration Format
112+
113+
Configuration files are stored as YAML or JSON in either:
114+
- `~/.vcspull.yaml`/`.json` (home directory)
115+
- `~/.config/vcspull/` directory (XDG config)
116+
117+
Example format:
118+
```yaml
119+
~/code/:
120+
flask: "git+https://github.com/mitsuhiko/flask.git"
121+
~/study/c:
122+
awesome: "git+git://git.naquadah.org/awesome.git"
123+
```
124+
125+
## Coding Standards
126+
127+
### Imports
128+
129+
- Use namespace imports: `import enum` instead of `from enum import Enum`
130+
- For typing, use `import typing as t` and access via namespace: `t.NamedTuple`, etc.
131+
- Use `from __future__ import annotations` at the top of all Python files
132+
133+
### Docstrings
134+
135+
Follow NumPy docstring style for all functions and methods:
136+
137+
```python
138+
"""Short description of the function or class.
139+
140+
Detailed description using reStructuredText format.
141+
142+
Parameters
143+
----------
144+
param1 : type
145+
Description of param1
146+
param2 : type
147+
Description of param2
148+
149+
Returns
150+
-------
151+
type
152+
Description of return value
153+
"""
154+
```
155+
156+
### Testing
157+
158+
#### Using libvcs Fixtures
159+
160+
When writing tests, leverage libvcs's pytest plugin fixtures:
161+
162+
- `create_git_remote_repo`, `create_svn_remote_repo`, `create_hg_remote_repo`: Factory fixtures
163+
- `git_repo`, `svn_repo`, `hg_repo`: Pre-made repository instances
164+
- `set_home`, `gitconfig`, `hgconfig`, `git_commit_envvars`: Environment fixtures
165+
166+
Example:
167+
```python
168+
def test_vcspull_sync(git_repo):
169+
# git_repo is already a GitSync instance with a clean repository
170+
# Use it directly in your tests
171+
```
172+
173+
#### Test Structure
174+
175+
Use `typing.NamedTuple` for parameterized tests:
176+
177+
```python
178+
class SyncFixture(t.NamedTuple):
179+
test_id: str # For test naming
180+
sync_args: list[str]
181+
expected_exit_code: int
182+
expected_in_out: ExpectedOutput = None
183+
184+
@pytest.mark.parametrize(
185+
list(SyncFixture._fields),
186+
SYNC_REPO_FIXTURES,
187+
ids=[test.test_id for test in SYNC_REPO_FIXTURES],
188+
)
189+
def test_sync(
190+
# Parameters and fixtures...
191+
):
192+
# Test implementation
193+
```
194+
195+
#### Mocking Strategy
196+
197+
- Use `monkeypatch` for environment, globals, attributes
198+
- Use `mocker` (from pytest-mock) for application code
199+
- Document every mock with comments explaining WHAT is being mocked and WHY
200+
201+
#### Configuration File Testing
202+
203+
- Use project helper functions like `vcspull.tests.helpers.write_config` or `save_config_yaml`
204+
- Avoid direct `yaml.dump` or `file.write_text` for config creation
205+
206+
### Git Commit Standards
207+
208+
Format commit messages as:
209+
```
210+
Component/File(commit-type[Subcomponent/method]): Concise description
211+
212+
why: Explanation of necessity or impact.
213+
what:
214+
- Specific technical changes made
215+
- Focused on a single topic
216+
```
217+
218+
Common commit types:
219+
- **feat**: New features or enhancements
220+
- **fix**: Bug fixes
221+
- **refactor**: Code restructuring without functional change
222+
- **docs**: Documentation updates
223+
- **chore**: Maintenance (dependencies, tooling, config)
224+
- **test**: Test-related updates
225+
- **style**: Code style and formatting
226+
227+
Example:
228+
```
229+
cli/add(feat[add_repo]): Add support for custom remote URLs
230+
231+
why: Enable users to specify alternative remote URLs for repositories
232+
what:
233+
- Add remote_url parameter to add_repo function
234+
- Update CLI argument parser to accept --remote-url option
235+
- Add tests for the new functionality
236+
```
237+
238+
## Debugging Tips
239+
240+
When stuck in debugging loops:
241+
242+
1. **Pause and acknowledge the loop**
243+
2. **Minimize to MVP**: Remove all debugging cruft and experimental code
244+
3. **Document the issue** comprehensively for a fresh approach
245+
4. Format for portability (using quadruple backticks)

0 commit comments

Comments
 (0)