Skip to content

Commit a22a0aa

Browse files
roli-lpciclaude
andcommitted
Add llms.txt, AGENTS.md, and CLAUDE.md for agent discoverability
llms.txt: llmstxt.org-spec navigation index for external AI tools. AGENTS.md: AAIF-convention agent instructions with commands, code style examples, and Always/Ask/Never boundaries. CLAUDE.md: Lean Claude Code context with architecture and gotchas. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 110fd50 commit a22a0aa

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed

AGENTS.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# AGENTS.md
2+
3+
## Commands
4+
5+
- `pip install -e ".[dev]"` -- Install with dev dependencies
6+
- `pytest` -- Run all 140 tests
7+
- `pytest tests/test_run_command.py -v` -- Single test module
8+
- `ruff check src/pygate/` -- Lint
9+
- `ruff check src/pygate/ --fix` -- Lint with auto-fix
10+
- `pyright src/pygate/` -- Type check (basic mode)
11+
- `python -m build` -- Build wheel and sdist
12+
- `pygate run` -- Run all quality gates
13+
- `pygate repair --max-attempts 3` -- Auto-repair lint failures
14+
- `pygate summarize` -- Generate agent-readable brief
15+
16+
## Testing
17+
18+
- Framework: `pytest` (config in `pyproject.toml` under `[tool.pytest.ini_options]`)
19+
- Test location: `tests/`, one file per source module
20+
- Fixtures: `tests/conftest.py` + JSON fixtures in `tests/fixtures/`
21+
- All tests run offline — no subprocess execution, all gate outputs are mocked
22+
- Run single test: `pytest tests/test_gates_ruff.py::test_ruff_parse -v`
23+
24+
## Project Structure
25+
26+
```
27+
src/pygate/
28+
cli.py # Argument parsing, subcommand dispatch
29+
run_command.py # `pygate run` — orchestrates gate execution
30+
repair_command.py # `pygate repair` — bounded auto-fix loop (ruff --fix)
31+
summarize_command.py # `pygate summarize` — agent brief from JSON artifacts
32+
gates/ # Individual gate implementations
33+
ruff.py # Ruff lint gate (JSON output parsing)
34+
pyright.py # Pyright type-check gate
35+
pytest_gate.py # Pytest gate (--json-report parsing)
36+
models.py # Pydantic models (GateResult, Failure, Escalation, etc.)
37+
config.py # pygate.toml / pyproject.toml config loading
38+
constants.py # Exit codes, default paths
39+
exec.py # Subprocess execution wrapper
40+
env.py # Environment detection (CI, tool availability)
41+
fs.py # File operations (artifact writes)
42+
deterministic_fix.py # Safe ruff --fix wrapper with rollback
43+
schemas/ # JSON schemas for all artifact types
44+
demo/artifacts/ # Example output from each command
45+
```
46+
47+
## Code Style
48+
49+
- Python 3.10+ required (`from __future__ import annotations` in all modules)
50+
- Pydantic v2 `BaseModel` for all structured data (not dataclasses)
51+
- `str(Enum)` for status values (`GateStatus.PASS`, `RunMode.CANARY`, etc.)
52+
- Ruff line length: 120, rules: `E, F, W, I, UP, B, SIM`
53+
- Pyright basic mode
54+
- Build system: hatchling
55+
56+
Good:
57+
```python
58+
from pydantic import BaseModel, Field
59+
60+
class GateResult(BaseModel):
61+
gate: str
62+
status: GateStatus
63+
failures: list[Failure] = Field(default_factory=list)
64+
duration_ms: int = 0
65+
```
66+
67+
Bad:
68+
```python
69+
# Don't use raw dicts for gate results
70+
result = {"gate": "ruff", "status": "pass", "failures": []}
71+
72+
# Don't use dataclasses — this project uses Pydantic
73+
@dataclass
74+
class GateResult:
75+
gate: str
76+
```
77+
78+
## Git Workflow
79+
80+
- Branch from `main`
81+
- Conventional commits: `feat:`, `fix:`, `test:`, `docs:`, `chore:`
82+
- Run `pytest` and `ruff check` before pushing
83+
- JSON schemas in `schemas/` must stay in sync with Pydantic models in `models.py`
84+
85+
## Boundaries
86+
87+
**Always:**
88+
- Run `pytest` after modifying source files
89+
- Keep Pydantic v2 as the modeling library
90+
- Maintain Python 3.10+ compatibility
91+
- Update JSON schemas when changing Pydantic models
92+
- Use `from __future__ import annotations` in every module
93+
94+
**Ask first:**
95+
- Adding new runtime dependencies (currently only pydantic + tomli)
96+
- Adding new gate types (ruff/pyright/pytest are the current three)
97+
- Changing exit codes in `constants.py`
98+
- Modifying the repair loop bounds or retry logic
99+
- Changing artifact output format (breaks downstream consumers)
100+
101+
**Never:**
102+
- Execute subprocess commands in tests (all gate outputs are mocked)
103+
- Use dataclasses instead of Pydantic models
104+
- Remove or weaken the bounded repair loop (max-attempts is a safety constraint)
105+
- Commit real project output to `demo/artifacts/` (use synthetic examples)
106+
- Break JSON schema backward compatibility without a version bump

CLAUDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Quick Gate Python (pygate-ci)
2+
3+
Deterministic quality gate CLI for Python projects. Runs ruff + pyright + pytest, produces structured JSON artifacts, supports bounded auto-repair.
4+
5+
## Commands
6+
7+
- `pip install -e ".[dev]"` -- Install
8+
- `pytest` -- 140 tests, all offline
9+
- `pytest tests/test_run_command.py -v` -- Single module
10+
- `ruff check src/pygate/ --fix` -- Lint fix
11+
- `pyright src/pygate/` -- Type check
12+
- `python -m build` -- Build
13+
14+
## Architecture
15+
16+
Three subcommands: `pygate run` (execute gates) → `pygate repair` (auto-fix loop) → `pygate summarize` (agent brief).
17+
18+
```
19+
src/pygate/
20+
cli.py → run_command.py / repair_command.py / summarize_command.py
21+
gates/ruff.py, pyright.py, pytest_gate.py # Individual gates
22+
models.py # Pydantic v2 models for all structured output
23+
config.py # Config from pygate.toml or pyproject.toml
24+
exec.py # Subprocess wrapper
25+
deterministic_fix.py # ruff --fix with rollback safety
26+
```
27+
28+
Key flow: `run_command` calls each gate → gate parses tool JSON output → results written as artifacts → exit code reflects pass/fail.
29+
30+
## Key Constraints
31+
32+
- Pydantic v2 for all models (not dataclasses)
33+
- `from __future__ import annotations` in every module
34+
- JSON schemas in `schemas/` must match Pydantic models
35+
- Tests never execute real subprocesses — all gate outputs mocked
36+
- Repair loop is bounded by `--max-attempts` (safety invariant)
37+
- Two runtime deps only: `pydantic`, `tomli` (for Python <3.11)
38+
39+
## Gotchas
40+
41+
- Package name on PyPI is `pygate-ci` but import name is `pygate`
42+
- `hatchling` build system (not setuptools) — source lives in `src/pygate/`
43+
- `pytest_gate.py` (not `test_gate.py`) to avoid pytest collecting it as a test
44+
- Config loading checks `pygate.toml` first, falls back to `[tool.pygate]` in `pyproject.toml`
45+
- `deterministic_fix.py` creates backup before `ruff --fix` and rolls back on failure

llms.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Quick Gate Python (pygate-ci)
2+
3+
> Deterministic quality gate CLI for Python projects. Runs ruff, pyright, and pytest with structured JSON output. Bounded auto-repair mode fixes lint issues automatically (max 3 attempts). Produces machine-readable escalation evidence for AI agents. Python 3.10+, Apache 2.0.
4+
5+
## Docs
6+
7+
- [README](https://github.com/roli-lpci/quick-gate-python/blob/main/README.md): Install, commands, configuration, CI integration, architecture, escalation schema
8+
- [CHANGELOG](https://github.com/roli-lpci/quick-gate-python/blob/main/CHANGELOG.md): Version history
9+
- [CONTRIBUTING](https://github.com/roli-lpci/quick-gate-python/blob/main/CONTRIBUTING.md): Development setup, PR guidelines
10+
11+
## Commands
12+
13+
The CLI has three subcommands:
14+
- `pygate run` -- Run quality gates (ruff + pyright + pytest), output structured JSON
15+
- `pygate repair` -- Auto-fix lint failures with bounded retry loop (max-attempts configurable)
16+
- `pygate summarize` -- Generate agent-readable brief from gate results
17+
18+
## Core Modules
19+
20+
- [CLI](https://github.com/roli-lpci/quick-gate-python/blob/main/src/pygate/cli.py): Argument parsing, subcommand dispatch
21+
- [Run Command](https://github.com/roli-lpci/quick-gate-python/blob/main/src/pygate/run_command.py): Orchestrates gate execution, collects results
22+
- [Repair Command](https://github.com/roli-lpci/quick-gate-python/blob/main/src/pygate/repair_command.py): Bounded auto-repair loop with ruff --fix
23+
- [Summarize Command](https://github.com/roli-lpci/quick-gate-python/blob/main/src/pygate/summarize_command.py): Agent brief generation from JSON artifacts
24+
- [Gates](https://github.com/roli-lpci/quick-gate-python/tree/main/src/pygate/gates): Individual gate implementations (ruff, pyright, pytest)
25+
- [Models](https://github.com/roli-lpci/quick-gate-python/blob/main/src/pygate/models.py): Pydantic models for all structured output
26+
27+
## Schemas
28+
29+
- [Failures Schema](https://github.com/roli-lpci/quick-gate-python/blob/main/schemas/failures.schema.json): JSON schema for gate failure output
30+
- [Escalation Schema](https://github.com/roli-lpci/quick-gate-python/blob/main/schemas/escalation.schema.json): JSON schema for escalation evidence
31+
- [Repair Report Schema](https://github.com/roli-lpci/quick-gate-python/blob/main/schemas/repair-report.schema.json): JSON schema for auto-repair results
32+
- [Agent Brief Schema](https://github.com/roli-lpci/quick-gate-python/blob/main/schemas/agent-brief.schema.json): JSON schema for summarize output
33+
34+
## GitHub Action
35+
36+
- [Action Definition](https://github.com/roli-lpci/quick-gate-python/blob/main/.github/actions/pygate/action.yml): Composite GitHub Action for CI integration
37+
38+
## Optional
39+
40+
- [Security Policy](https://github.com/roli-lpci/quick-gate-python/blob/main/SECURITY.md): Vulnerability reporting
41+
- [Demo Artifacts](https://github.com/roli-lpci/quick-gate-python/tree/main/demo/artifacts): Example JSON output from each command

0 commit comments

Comments
 (0)