terraform-review-agent
CLAUDE.md102 starsChanged 6 months agoMITView on GitHub
Project contract for Claude Code / AI coding assistants. Replace [PLACEHOLDERS] per project; everything else is fixed standard. Standard LangGraph src-layout (<https://docs.langchain.com/oss/python/langgraph/application-structure>): All importable code lives under src/[package_name]/. agent.py exposes the compiled graph as a module-level agent variable.
- Reads credentials
- Installs packages
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 47
All importable code lives under src/[package_name]/.
- Distinctive: line 146
Every node gets at least one unit test
- Very specific: line 147
Use pytest.fixture for graph construction to stay DRY
- Very specific: line 153
Read this file, then pyproject.toml, then src/[package_name]/agent.py
- Very specific: line 155
Add Pydantic schemas to utils/state.py before writing node code
- Distinctive: line 157
Add at least one unit test
- Very specific: line 158
Run make fmt lint type test before declaring done
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Project contract for Claude Code / AI coding assistants. Replace
[PLACEHOLDERS]per project; everything else is fixed standard.
1. Project
- Name:
terraform-review-agent - Goal:
A reusable GitHub Actions workflow that uses a LangGraph multi-agent system to review Terraform pull requests for security, cost, and style issues, posting a single severity-ranked comment. - Trigger:
GitHubpull_requestevents (opened,synchronize,reopened,ready_for_review) on Terraform-file changes, via a reusable workflow consumed by other repos. Users: PR authors and reviewers. Secondary:workflow_dispatchfor manual re-runs. - Framework:
LangGraph
2. Stack (fixed — do not change without explicit instruction)
- Python 3.13 · uv package manager ·
.venvonly (never system Python) - Pydantic v2 for all state, tool I/O, and config schemas
- LangGraph or LangChain
- SQLite checkpointer (
langgraph-checkpoint-sqlite) if keeping state is required - LLM providers: OpenAI, Anthropic, Google only — selectable via config
- Docker (compose) for reproducibility ·
structloglogging ·pytest·ruff·mypy --strict
3. Layout
Standard LangGraph src-layout (https://docs.langchain.com/oss/python/langgraph/application-structure):
[project]/
├── CLAUDE.md, README.md, .env.example, .gitignore, .python-version
├── pyproject.toml, uv.lock, langgraph.json
├── Dockerfile, docker-compose.yml, Makefile
├── src/[package_name]/
│ ├── agent.py # exposes compiled `agent` for langgraph.json
│ ├── config.py # Pydantic Settings (env-driven)
│ ├── llm.py # provider factory (OpenAI/Anthropic/Google)
│ ├── utils/{state,nodes,tools,prompts}.py
│ └── persistence/checkpointer.py
├── tests/{unit,integration}/
├── data/ # SQLite, fixtures (gitignored if dynamic)
└── scripts/ # thin wrappers only — no business logicAll importable code lives under src/[package_name]/. agent.py exposes the compiled graph as a module-level agent variable.
4. Setup & hard rules
python3.13 -m venv .venv && source .venv/bin/activate
pip install uv
uv sync --inexact --extra dev # exact versions from uv.lock (--inexact keeps uv/pip)
cp .env.example .env # fill in keys- ❌ Never
pip installoutside.venv - ❌ Never invoke a bare
python— always activate.venvfirst - ❌ Never commit
.env,data/*.sqlite,.venv/,__pycache__ - 📌 Deps are pinned in
uv.lock(committed). After editingpyproject.toml, runuv lock(ormake lock);make lintrunsuv lock --checkand fails on drift.
5. Required env vars (.env.example)
# At least one LLM key required
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
DEFAULT_LLM_PROVIDER=anthropic # openai | anthropic | google
DEFAULT_LLM_MODEL=claude-sonnet-4-5
DEFAULT_LLM_TEMPERATURE=0.0
SQLITE_PATH=./data/state.sqlite
# Optional observability
LANGSMITH_API_KEY=
LANGSMITH_TRACING=false
LANGSMITH_PROJECT=[PROJECT_NAME]
LOG_LEVEL=INFO
ENVIRONMENT=development # development | staging | production6. Patterns (where things live)
- LLM factory (
llm.py): singleget_llm(provider, model, temperature)switching onopenai|anthropic|googleusinglangchain-openai,langchain-anthropic,langchain-google-genai. Defaults fromconfig.settings. - State (
utils/state.py): Pydantic models. For LangGraph messages:Annotated[list[AnyMessage], add_messages]. No untyped dicts. - Checkpointer (
persistence/checkpointer.py):SqliteSaver.from_conn_string(settings.sqlite_path). Postgres only on explicit request. - Tools (
utils/tools.py):@toolfromlangchain_core.toolswith Pydantic input schemas. - Prompts (
utils/prompts.py): never inlined in node code. - Config (
config.py):pydantic_settings.BaseSettingsreading env — secrets never hardcoded.
7. Docker
- Base:
python:3.13-slim,.venvat/app/.venv(identical to host), non-root user - Compose: mount
./data(SQLite persists across restarts) and./src(dev hot-reload — remove for prod) - Run via
docker compose up
8. make targets
venv · install · fmt · lint · type · test · run · docker-build · docker-up · clean
Python targets invoke ./.venv/bin/... — never bare python. run is the exception: it executes inside the container (docker compose run agent …) so the bundled scanners are on PATH. Use these instead of re-inventing commands.
9. langgraph.json
{
"dependencies": ["."],
"graphs": { "agent": "./src/[package_name]/agent.py:agent" },
"env": "./.env",
"python_version": "3.13"
}10. Conventions
- Type hints everywhere;
mypy --strictmust pass onsrc/ - Pydantic for all data shapes — no bare dicts across module boundaries
- One node = one small, pure-ish function
- No
printinsrc/— structured logging only - Raise typed exceptions; let the graph handle retry/branching, not try/except spaghetti
11. Testing
tests/unit/— pure function and node tests; mock LLM callstests/integration/— compiled graph end-to-end with in-memory SQLite checkpointer- Every node gets at least one unit test
- Use
pytest.fixturefor graph construction to stay DRY
12. Workflow when editing this project
- Read this file, then
pyproject.toml, thensrc/[package_name]/agent.py - Honor framework choice from §1
- Add Pydantic schemas to
utils/state.pybefore writing node code - New nodes in
utils/nodes.py, wired inagent.py - Add at least one unit test
- Run
make fmt lint type testbefore declaring done
13. Out of scope (stop and ask first)
Cloud-managed DBs, vector stores, message queues · Kubernetes / Helm / Terraform · LLM providers other than OpenAI / Anthropic / Google · Frontend frameworks · Paid third-party APIs beyond LLMs.
14. References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

