# CLAUDE.md — agentreflect repo

## Project overview

`agentreflect` is a Python CLI tool that analyzes AI coding agent failure logs and generates targeted AGENTS.md rule suggestions. It is part of the agent quality trilogy: coderace → agentmd → agentlint → agentreflect.

## Commands

```bash
# Install in dev mode
pip install -e '.[dev]'

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=agentreflect --cov-report=term-missing

# Build package
python -m build

# Test CLI
agentreflect --version
agentreflect generate --from-notes "agent forgot to check None"
agentreflect generate --from-pytest tests/fixtures/sample-failures.txt
```

## Architecture

- `agentreflect/parsers/` — input parsers (pytest, git, notes)
- `agentreflect/generators/` — suggestion generators (pattern-based, LLM)
- `agentreflect/output/` — formatters (markdown, diff, apply)
- `agentreflect/models.py` — FailureRecord, RuleSuggestion dataclasses
- `agentreflect/cli.py` — click-based CLI entry point

## Key constraints

1. Basic mode (no `--llm`) must work without any API key
2. The `anthropic` package is only imported when `--llm` is used
3. Pattern generator must always return at least one suggestion
4. Apply mode appends to file, never overwrites existing content
