Skip to content

Commit a67a3b5

Browse files
authored
Merge pull request #146 from trailofbits/dm/claude-md
Add CLAUDE.md files for Claude Code guidance
2 parents dd5ce02 + 7e13be5 commit a67a3b5

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

AGENTS.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# AGENTS.md
2+
3+
## Project Overview
4+
5+
A Cookiecutter template for Python packages, supporting both CLI and library project types. Generates projects with uv, ruff, pyright, and pytest pre-configured. It also comes with GitHub Actions workflows configured for the project.
6+
7+
This template is opinionated and enforces recommended practices when creating new Python projects.
8+
9+
## Repository Structure
10+
11+
- `{{cookiecutter.project_slug}}/` - Template directory (rendered by Cookiecutter)
12+
- `cookiecutter.json` - Template variables and prompts
13+
- `hooks/` - Pre/post generation scripts
14+
- `pre_gen_project.py` - Validates inputs (namespace, slug, entry point)
15+
- `post_gen_project.py` - Cleans up unused files based on options
16+
17+
## Key Template Variables
18+
19+
| Variable | Purpose |
20+
|----------|---------|
21+
| `project_name` | Human-readable name |
22+
| `project_slug` | Pip/repo name (auto-derived) |
23+
| `project_namespace_import` | Optional namespace (e.g., `company.tools`) |
24+
| `repo_type` | `CLI` or `library` |
25+
| `entry_point` | CLI command name (CLI only) |
26+
27+
## Testing Changes
28+
29+
Generate a test project to verify template changes:
30+
31+
```bash
32+
# Generate in temp directory
33+
uvx cookiecutter -o /tmp .
34+
35+
# Or with specific options (no prompts)
36+
uvx cookiecutter --no-input -o /tmp . project_name="Test Project" repo_type="CLI"
37+
```
38+
39+
Then verify the generated project:
40+
41+
```bash
42+
cd /tmp/test-project
43+
make lint && make test
44+
```
45+
46+
## Verification
47+
48+
When modifying the template:
49+
50+
1. Ensure Jinja2 syntax is valid in template files
51+
2. Test both `CLI` and `library` repo types
52+
3. Test with and without `project_namespace_import`
53+
4. Verify generated project passes `make lint && make test`
54+
55+
## Commit Messages
56+
57+
- Summary line: max 50 chars (hard limit 72)
58+
- Body lines: max 72 chars
59+
- Use Markdown formatting in description

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# AGENTS.md
2+
3+
## Project Overview
4+
5+
{{ cookiecutter.project_description }}
6+
7+
{%- if cookiecutter.repo_type == 'CLI' %}
8+
This is a command-line application with entry point `{{ cookiecutter.entry_point }}`.
9+
{%- else %}
10+
This is a Python library package.
11+
{%- endif %}
12+
13+
## Stack
14+
15+
- Package manager: uv
16+
- Build backend: uv_build
17+
- Linting/formatting: ruff
18+
- Type checking: pyright
19+
- Testing: pytest
20+
- CI: GitHub Actions (lint, test, release{%- if cookiecutter.documentation != 'none' %}, docs{%- endif %})
21+
22+
## Commands
23+
24+
Use Makefile targets, not tool commands directly:
25+
26+
- `make format` - Fix formatting issues
27+
- `make lint` - Run all static checks (ruff, pyright)
28+
- `make test` - Run tests with coverage
29+
- `make doc` - Generate documentation
30+
- `make build` - Build the package
31+
{%- if cookiecutter.entry_point %}
32+
- `make run` - Run the CLI (use `ARGS="..."` for arguments)
33+
{%- endif %}
34+
35+
## Verification
36+
37+
Run `make lint && make test` before committing.
38+
39+
## Commit Messages
40+
41+
- Summary line: max 50 chars (hard limit 72)
42+
- Body lines: max 72 chars
43+
- Use Markdown formatting in description
44+
- Reference issues where relevant (e.g., `See #123`)
45+
46+
## Project Layout
47+
48+
- `src/{{ cookiecutter.__project_import.replace('.', '/') }}/` - Source code
49+
- `test/` - Test files
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

0 commit comments

Comments
 (0)