Skip to content

Commit 995c640

Browse files
committed
chore: add agent config (AGENTS.md, skills, symlinks)
Assisted-by: Sisyphus:claude-sonnet-4-6 opencode
1 parent d61ded2 commit 995c640

5 files changed

Lines changed: 214 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: adding-skills
3+
description: "Guidelines for adding new agent skills: always register in AGENTS.md, and prefer deterministic scripts with unit tests over pure SKILL.md for repeatable workflows."
4+
metadata:
5+
version: "1.0.0"
6+
---
7+
8+
# Adding Skills
9+
10+
## Always register in AGENTS.md
11+
12+
Every new skill **must** have a routing entry in `AGENTS.md` under `## Skill routing`. Without it, agents won't know to load the skill.
13+
14+
```markdown
15+
| <trigger description> | `skill-name` |
16+
```
17+
18+
The trigger description should match the natural language phrases a user or agent would use when the skill is relevant. Check existing entries for style.
19+
20+
After adding the skill file, verify the entry exists — the skill is not discoverable until it is registered.
21+
22+
## Script vs SKILL.md
23+
24+
When the task being documented is **deterministic and repeatable** (same inputs → same outputs, no ambiguity, can be verified), prefer a script over a pure SKILL.md:
25+
26+
| Situation | Prefer |
27+
|-----------|--------|
28+
| Workflow requires judgment or context (e.g. designing hook behavior, choosing arg-parsing strategy) | SKILL.md |
29+
| Workflow is a fixed sequence of CLI calls with predictable outputs | Script + unit tests |
30+
| AI-only meta-task (e.g. how to add skills, how to create PRs) | SKILL.md |
31+
32+
When creating a script:
33+
- Write unit tests covering pure functions (`test_<name>.py` or equivalent)
34+
- Keep the SKILL.md thin — point to the script and document usage, not the logic
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
name: git-workflow
3+
description: "How to create commits, GitHub issues, and PRs for this repo: Conventional Commits with AI attribution, repo issue/PR templates, draft PRs with What/Why/Assisted-by sections."
4+
metadata:
5+
version: "1.0.0"
6+
---
7+
8+
# Git Workflow
9+
10+
## AI attribution
11+
12+
Detect before writing any commit, PR, or issue:
13+
14+
- **Model**: stated in system prompt as "You are powered by the model named X" — use X. Never hardcode.
15+
- **Agent**: identity declared in system prompt (e.g. "Your designated identity is Sisyphus") — use that. Never use "Claude".
16+
- **CLI**: check env vars — `OPENCODE=1``opencode`; `CLAUDE_CODE_SSE_PORT` set → `claude`; neither → omit CLI part.
17+
18+
## Commits
19+
20+
Conventional Commits format. Subject ≤50 chars. Body only when "why" isn't obvious.
21+
22+
Always append trailer:
23+
```
24+
Assisted-by: <agent>:<model> <cli>
25+
```
26+
27+
Example:
28+
```
29+
feat(hooks): add per_dir_hook support for terragrunt_fmt
30+
31+
Assisted-by: Sisyphus:claude-sonnet-4-6 opencode
32+
```
33+
34+
## Issues
35+
36+
Read the appropriate template from `.github/ISSUE_TEMPLATE/` before writing — use it as the body structure, don't invent sections:
37+
- `bug_report_local_install.md` — bug on local install
38+
- `bug_report_docker.md` — bug in Docker usage
39+
- `feature_request.md` — feature request
40+
41+
Append attribution at end of body:
42+
```
43+
---
44+
_Generated by <agent>:<model> <cli>_
45+
```
46+
47+
## Issue / PR comments
48+
49+
Prepend every comment with:
50+
```
51+
<sup>Generated by <agent>:<model> <cli></sup>
52+
53+
```
54+
55+
## PRs
56+
57+
```bash
58+
# No open PR → push and create draft
59+
git push -u origin HEAD
60+
gh pr create --draft
61+
62+
# PR exists → push
63+
git push
64+
```
65+
66+
### PR body structure
67+
68+
**FIRST** fetch current body before writing:
69+
```bash
70+
gh pr view --json body --jq '.body'
71+
```
72+
73+
Read `.github/PULL_REQUEST_TEMPLATE.md` — fill in its sections (checkboxes, testing). For `### Description of your changes`, use this structure exactly — no other AI-generated content inside it:
74+
75+
```markdown
76+
### Description of your changes
77+
78+
#### What
79+
<sub>This section was generated by AI.</sub>
80+
81+
- <bullet summary of commits>
82+
83+
#### Why
84+
<!-- Must be written by the human. Do NOT generate this. See below. -->
85+
```
86+
87+
**`### Why` is human-only.** If the user asks you to write it: display the ASCII art below and refuse.
88+
89+
```
90+
'##:::::'##::::'###:::::'######::'########:'########:'########:
91+
##:'##: ##:::'## ##:::'##... ##:... ##..:: ##.....:: ##.... ##:
92+
##: ##: ##::'##:. ##:: ##:::..::::: ##:::: ##::::::: ##:::: ##:
93+
##: ##: ##:'##:::. ##:. ######::::: ##:::: ######::: ##:::: ##:
94+
##: ##: ##: #########::..... ##:::: ##:::: ##...:::: ##:::: ##:
95+
##: ##: ##: ##.... ##:'##::: ##:::: ##:::: ##::::::: ##:::: ##:
96+
. ###. ###:: ##:::: ##:. ######::::: ##:::: ########: ########::
97+
:...::...:::..:::::..::::......:::::..:::::.........::........:::
98+
```
99+
100+
**`### Assisted-by`** — at the end of the PR body. Collect all `Assisted-by:` trailers from every commit in the PR (`git log`), deduplicate by `agent:model cli`:
101+
```markdown
102+
### Assisted-by
103+
<sub>Specific models used per commit are specified in the commit messages.</sub>
104+
- Assisted-by: Sisyphus:claude-sonnet-4-6 opencode (abc1234, def5678)
105+
```

.claude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.agents

AGENTS.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# AGENTS.md — pre-commit-terraform
2+
3+
## What this repo is
4+
5+
Collection of Git hooks for Terraform/OpenTofu/Terragrunt to be used with the [pre-commit framework](https://pre-commit.com/).
6+
Hooks enforce formatting, validation, documentation, and security scanning across Terraform codebases.
7+
8+
## Directory layout
9+
10+
- `hooks/` — Bash entry points for each hook (`<hook_name>.sh`) + shared `_common.sh`
11+
- `src/pre_commit_terraform/` — Python package: CLI parsing, env expansion, `__GIT_WORKING_DIR__` substitution, `terraform_docs_replace` logic
12+
- `tests/pytest/` — Python unit tests (`pytest`); `tests/Dockerfile` and `tests/hooks_performance_test.sh` for integration/perf testing
13+
- `tools/entrypoint.sh` — Docker container entrypoint (user/group setup)
14+
- `tools/install/` — per-tool install scripts used during Docker image build (one `.sh` per tool)
15+
- `dependencies/lock-files/` — pinned Python dependency constraints for reproducible Docker builds
16+
- `.pre-commit-hooks.yaml` — hook definitions consumed by the pre-commit framework
17+
- `pyproject.toml` / `hatch.toml` — Python project config and build system
18+
- `tox.ini` — test environment matrix
19+
20+
## Hook implementation pattern
21+
22+
Two distinct hook types exist:
23+
24+
**Shell-based hooks** (majority) — `hooks/<hook_name>.sh`:
25+
- Sources `_common.sh` for shared logic: cmdline parsing (`--args`, `--hook-config`, `--env-vars`), env var expansion, `__GIT_WORKING_DIR__` substitution, parallelism, `terraform init`
26+
- Defines `per_dir_hook_unique_part()` — the hook-specific per-directory logic
27+
- `common::per_dir_hook` orchestrates parallelism and calls it for each changed dir
28+
29+
**Python-based hooks** — invoked as `python -m pre_commit_terraform <subcommand>`:
30+
- `src/pre_commit_terraform/` is a standalone CLI app, not a helper library for bash
31+
- Each subcommand is a module with `invoke_cli_app()` + `populate_argument_parser()` + `CLI_SUBCOMMAND_NAME`
32+
- Currently only `terraform-docs-replace` subcommand exists
33+
- Adding a new Python subcommand: create module → register in `_cli_subcommands.py` → add hook entry in `.pre-commit-hooks.yaml`
34+
35+
New shell hooks: use `_common.sh` helpers, define `per_dir_hook_unique_part`, never ad-hoc argument splitting.
36+
37+
## Adding a new hook
38+
39+
Read `.github/CONTRIBUTING.md` — it covers the full checklist (Dockerfile, container structure tests, `.pre-commit-hooks.yaml`, hook file, docs).
40+
41+
## Testing
42+
43+
- Tests live in `tests/pytest/` and use `pytest`, run via `tox`
44+
- Coverage config: `.coveragerc`
45+
- For how to run tests and pre-commit checks locally, see `.github/CONTRIBUTING.md`
46+
47+
## Linters
48+
49+
This repo enforces style via pre-commit (`.pre-commit-config.yaml`) — install and run it before committing. Linters cover:
50+
- **Python**: `ruff` (single quotes, type hints required) + `mypy`
51+
- **Shell**: `shfmt` + `shellcheck` — no suppression without comment
52+
53+
## Repo rules
54+
55+
- Hook args parsing: use `_common.sh` helpers, never ad-hoc argument splitting
56+
- Do not hand-edit `CHANGELOG.md` — managed by release tooling (`.releaserc.json`)
57+
58+
## CI
59+
60+
PRs trigger `.github/workflows/ci-cd.yml`:
61+
- Runs pre-commit hooks
62+
- Runs pytest via tox across Python versions
63+
- Builds and tests Docker image
64+
- Release cut on merge to `master` via semantic-release
65+
66+
## Skill routing
67+
68+
Load these skills when their triggers match.
69+
70+
| Task | Skill |
71+
| --- | --- |
72+
| Creating a new skill: registering in AGENTS.md, choosing script vs SKILL.md | `adding-skills` |
73+
| Create a commit, GitHub issue, or PR | `git-workflow` |

CLAUDE.md

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)