haac-aikit 0.1.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -69
- package/catalog/ci/aikit-rules.yml +55 -0
- package/catalog/docs/claude-md-reference.md +316 -0
- package/catalog/hooks/check-pattern-violations.sh +137 -0
- package/catalog/hooks/hooks.json +38 -0
- package/catalog/hooks/judge-rule-compliance.sh +197 -0
- package/catalog/hooks/log-rule-event.sh +80 -0
- package/catalog/rules/AGENTS.md.tmpl +28 -7
- package/catalog/rules/aikit-rules.json +37 -0
- package/catalog/rules/claude-rules/example.md +38 -0
- package/dist/cli.mjs +1227 -125
- package/dist/cli.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,126 +4,225 @@
|
|
|
4
4
|
[](https://github.com/Hamad-Center/haac-aikit)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
One command drops a complete, opinionated, cross-tool setup into any repo — rules, skills, slash commands, subagents, safety hooks, MCP stub, and CI templates.
|
|
7
|
+
A CLI that drops a working AI-coding setup into any repo — rules, skills, safety hooks, subagents, MCP stub, CI templates — and then helps you figure out which of those rules are actually doing anything.
|
|
9
8
|
|
|
10
|
-
Works with
|
|
11
|
-
|
|
12
|
-
---
|
|
9
|
+
Works with Claude Code, Cursor, GitHub Copilot, Windsurf, Aider, Gemini CLI, and OpenAI Codex CLI.
|
|
13
10
|
|
|
14
11
|
## Quickstart
|
|
15
12
|
|
|
16
13
|
```bash
|
|
17
|
-
# Run in any repo directory
|
|
18
14
|
npx haac-aikit
|
|
19
|
-
|
|
20
|
-
# Or install globally
|
|
21
|
-
npm i -g haac-aikit
|
|
22
|
-
aikit
|
|
23
15
|
```
|
|
24
16
|
|
|
25
|
-
The
|
|
17
|
+
The wizard takes about 30 seconds and writes a `.aikitrc.json` you can commit. Re-run later with `aikit sync`.
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
For CI or scripts:
|
|
28
20
|
|
|
29
21
|
```bash
|
|
30
22
|
npx haac-aikit --yes --tools=claude,cursor,copilot --preset=standard
|
|
31
23
|
```
|
|
32
24
|
|
|
33
|
-
|
|
25
|
+
## Why this exists
|
|
26
|
+
|
|
27
|
+
Every AI tool now wants its own rules file: CLAUDE.md, `.cursor/rules/`, `copilot-instructions.md`, AGENTS.md. They all do roughly the same thing — tell the model how your team writes code — but you end up maintaining four copies, none of which you can tell are working.
|
|
28
|
+
|
|
29
|
+
You write 30 rules and pray. The kit you cloned last quarter ships a CLAUDE.md with rules about Python even though you write Go. You never delete the dead ones because you can't tell they're dead.
|
|
30
|
+
|
|
31
|
+
haac-aikit gives you the curated baseline like other kits do (skills, hooks, agents, etc.), and on top of that it adds three things no other kit ships:
|
|
32
|
+
|
|
33
|
+
1. **Observability** — telemetry hooks log which rules are loaded and violated, so `aikit doctor --rules` can tell you which to keep, strengthen, or delete.
|
|
34
|
+
2. **Dialect translation** — Cursor's MDC, Claude's emphasis tokens, Aider's imperative phrasing all want different things. Same canonical AGENTS.md, reformatted per tool.
|
|
35
|
+
3. **`aikit learn`** — mines your team's PR review comments for repeated corrections and proposes them as new rules.
|
|
36
|
+
|
|
37
|
+
## What changes after you install it
|
|
38
|
+
|
|
39
|
+
**Right after `aikit init`:**
|
|
40
|
+
|
|
41
|
+
- One `AGENTS.md` becomes the source of truth for every AI tool you use. You stop maintaining four copies of the same rules.
|
|
42
|
+
- Force-pushing to `main`, committing secrets, reading `.env*` / `.ssh/` / `.aws/` files, `rm -rf` outside the project, and about a dozen other footguns are blocked at the hook level. They don't depend on the AI cooperating — the hook fires before the tool call.
|
|
43
|
+
- 18 process skills (TDD, brainstorming, debugging, etc.) sit in `.claude/skills/` and load on demand. Always-on cost is roughly 100 tokens per skill, so your context window stays clean.
|
|
44
|
+
- Per-PR safety: a `gitleaks` workflow ships in `.github/workflows/` so secrets caught at commit time don't slip through code review either.
|
|
45
|
+
|
|
46
|
+
**After a week or two of use:**
|
|
47
|
+
|
|
48
|
+
- `aikit doctor --rules` shows you which rules fire often, which fire and get violated, and which never come up. You delete the dead ones, strengthen the disputed ones, and stop guessing.
|
|
49
|
+
- The `.aikit/events.jsonl` log accumulates a real record of every rule load and pattern violation — local, gitignored, never uploaded. If you opt into the LLM judge it also includes per-turn cited / violated verdicts.
|
|
50
|
+
|
|
51
|
+
**After a month:**
|
|
52
|
+
|
|
53
|
+
- `aikit learn --limit=30` mines your merged PRs for repeated review comments and proposes new rules. Patterns like "we always validate at the boundary" or "use named exports here" that used to live only in code review get codified without anyone hand-typing them.
|
|
54
|
+
- The optional GitHub Actions workflow posts a sticky PR comment with a rule-adherence score, so regressions across releases are visible at PR-review time.
|
|
34
55
|
|
|
35
|
-
|
|
56
|
+
**What you don't get locked into:**
|
|
57
|
+
|
|
58
|
+
- AGENTS.md is portable — Cursor, Copilot, Codex, Aider, and Gemini all read it. Switching tools doesn't mean rewriting your rules.
|
|
59
|
+
- The catalog (skills, hooks, agents) is just markdown and shell scripts under `.claude/`. Take it and walk away whenever — haac-aikit never reaches back into your repo and there's no SaaS to cancel.
|
|
60
|
+
- All telemetry is local. The opt-in LLM judge calls the Anthropic API only with your own key, only on `Stop` events, and you can pull the env var anytime.
|
|
61
|
+
|
|
62
|
+
## What you get
|
|
63
|
+
|
|
64
|
+
### Minimal scope
|
|
36
65
|
|
|
37
|
-
### Scope: minimal
|
|
38
66
|
| File | Purpose |
|
|
39
67
|
|---|---|
|
|
40
|
-
| `AGENTS.md` |
|
|
41
|
-
| `CLAUDE.md` |
|
|
42
|
-
| `.cursor/rules/000-base.mdc` |
|
|
43
|
-
| `.github/copilot-instructions.md` |
|
|
44
|
-
|
|
|
45
|
-
| `.
|
|
46
|
-
| `.
|
|
47
|
-
| `.aikitrc.json` | Versioned config for reproducible re-runs |
|
|
48
|
-
|
|
49
|
-
### Scope: standard (default) — adds
|
|
50
|
-
- **18 curated skills** (10 Tier-1 always-on + 8 Tier-2 default) — process skills, not stack-specific
|
|
51
|
-
- **8 subagents** — orchestrator, planner, researcher, implementer, reviewer, tester, security-auditor, devops
|
|
52
|
-
- **Safety hooks** — block dangerous bash, force-push to main, secret commits, sensitive file access
|
|
53
|
-
- **Quality hooks** — format on save, session context primer, pre-compaction state preservation
|
|
54
|
-
- **CI workflows** — secret scanning (gitleaks), standard CI, `@claude` PR responder
|
|
55
|
-
|
|
56
|
-
### Scope: everything — adds
|
|
57
|
-
- Domain-specialist agents (frontend, backend, mobile) based on your project shape
|
|
58
|
-
- Dev container, plugin wrapper, OTel exporter config, auto-sync CI workflow
|
|
59
|
-
|
|
60
|
-
---
|
|
68
|
+
| `AGENTS.md` | The canonical project rules — your edits outside the BEGIN/END markers are never touched |
|
|
69
|
+
| `CLAUDE.md` | Five-line shim that imports `@AGENTS.md` plus a Claude-only override block |
|
|
70
|
+
| `.cursor/rules/000-base.mdc` | Cursor MDC, dialect-translated from AGENTS.md (not a generic shim) |
|
|
71
|
+
| `.github/copilot-instructions.md`, `GEMINI.md`, `CONVENTIONS.md`, `.windsurf/rules/project.md` | Per-tool shims |
|
|
72
|
+
| `.mcp.json` | MCP stub with filesystem, memory, fetch — three servers, ~1k tokens of tool defs |
|
|
73
|
+
| `.claude/settings.json` | Hardened permissions: deny list for secrets and destructive commands |
|
|
74
|
+
| `.aikitrc.json` | Versioned config so re-runs are deterministic |
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
### Standard scope (default) adds
|
|
77
|
+
|
|
78
|
+
- 18 process skills, organised into Tier 1 (always-on) and Tier 2 (opt-in). Skill bodies only load when triggered, so the at-rest cost is roughly 100 tokens each.
|
|
79
|
+
- 8 subagents: orchestrator, planner, researcher, implementer, reviewer, tester, security-auditor, devops.
|
|
80
|
+
- Safety hooks that block dangerous bash, force-push to main, secret commits, and reads of sensitive files.
|
|
81
|
+
- Observability hooks (see below).
|
|
82
|
+
- A starter `.claude/aikit-rules.json` with regex patterns for common things like no `console.log`, no default exports, no `any`.
|
|
83
|
+
- `docs/claude-md-reference.md` — a 2026 reference doc on Anthropic's memory features for your team.
|
|
84
|
+
- `.claude/rules/example.md` — a starter path-scoped rule that only loads when matching files are read.
|
|
85
|
+
- CI workflows: gitleaks, standard CI, optional `@claude` PR responder, optional rule-adherence PR comment.
|
|
86
|
+
|
|
87
|
+
### Everything scope adds
|
|
88
|
+
|
|
89
|
+
Dev container, OTel exporter, plugin wrapper, auto-sync CI, and shape-specific agents (frontend / backend / mobile, picked based on the project shape you select in the wizard).
|
|
90
|
+
|
|
91
|
+
## Rule observability
|
|
92
|
+
|
|
93
|
+
After a few Claude Code sessions:
|
|
63
94
|
|
|
64
95
|
```
|
|
65
|
-
aikit
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
$ aikit doctor --rules
|
|
97
|
+
|
|
98
|
+
Hot rules (working as intended)
|
|
99
|
+
commit.conventional-commits — 47 loads
|
|
100
|
+
security.no-sensitive-files — 12 loads
|
|
101
|
+
|
|
102
|
+
Disputed rules (>30% violation rate)
|
|
103
|
+
code-style.no-console-log — 47 loads, 18 pattern violations
|
|
104
|
+
Frequently violated. Strengthen with IMPORTANT/YOU MUST or move to a hook.
|
|
105
|
+
|
|
106
|
+
Dead rules (never observed)
|
|
107
|
+
legacy.bounded-contexts
|
|
108
|
+
Never loaded, cited, or violated. Consider removing or rephrasing.
|
|
72
109
|
```
|
|
73
110
|
|
|
74
|
-
|
|
111
|
+
This comes from three small hooks shipped at standard scope:
|
|
112
|
+
|
|
113
|
+
- **`log-rule-event.sh`** runs on `InstructionsLoaded`. It scans loaded files for `<!-- id: code-style.no-any -->` markers and writes one event per rule per session.
|
|
114
|
+
- **`check-pattern-violations.sh`** runs on `PostToolUse` for Edit/Write. It reads `.claude/aikit-rules.json` and flags any pattern matches in the file Claude just wrote.
|
|
115
|
+
- **`judge-rule-compliance.sh`** runs on `Stop`. It's opt-in. If you set `AIKIT_JUDGE=1` and `ANTHROPIC_API_KEY`, it asks Claude Haiku to verdict whether each loaded rule was cited or violated this turn (~$0.001/turn). Without both env vars it returns immediately and does nothing.
|
|
75
116
|
|
|
76
|
-
|
|
117
|
+
All three hooks append to `.aikit/events.jsonl`, which `sync` adds to `.gitignore`. Nothing leaves your machine unless you opt in to the judge.
|
|
77
118
|
|
|
78
|
-
|
|
119
|
+
`aikit report` formats the same data as Markdown (PR-comment ready) or JSON (`--format=json`, for CI). Without judge data, the adherence score is `null` with `basis: "no-evidence"` rather than a fake number derived from load counts.
|
|
79
120
|
|
|
80
|
-
|
|
121
|
+
### Adding observability to your own rules
|
|
122
|
+
|
|
123
|
+
In any rule file, add a stable HTML-comment ID:
|
|
124
|
+
|
|
125
|
+
```markdown
|
|
126
|
+
- <!-- id: code-style.no-any emphasis=high paths=src/**/*.ts --> Use `unknown` and type guards, not `any`.
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The `id` is required for telemetry. `emphasis` and `paths` are optional metadata read by the dialect translators. HTML comments cost zero context tokens — Claude strips them before injection — so this is free observability.
|
|
130
|
+
|
|
131
|
+
## Dialect translation
|
|
132
|
+
|
|
133
|
+
Other multi-tool kits copy the same content into every per-tool file. haac-aikit reformats per dialect.
|
|
134
|
+
|
|
135
|
+
For Cursor that means: `.cursor/rules/000-base.mdc` gets proper MDC frontmatter, **bold** emphasis on rules tagged `emphasis=high`, and a paths hint surfaced inline. Rule IDs are preserved so the observability hooks see them load alongside AGENTS.md.
|
|
136
|
+
|
|
137
|
+
Claude, Aider, Copilot, and Gemini translators are the next thing on the roadmap.
|
|
138
|
+
|
|
139
|
+
## Learn from your PR history
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
$ aikit learn --limit=30
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Pulls the last 30 merged PRs via `gh`, scans review and issue comments for correction phrases ("we always", "don't here", "actually let's", "nit:"), tokenises them, clusters by Jaccard similarity, and prints proposals in a paste-ready block:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
<!-- BEGIN:learned -->
|
|
149
|
+
## Learned conventions
|
|
150
|
+
- <!-- id: learned.use-named-exports --> we always use named exports here, not default
|
|
151
|
+
- <!-- id: learned.validate-input-boundary --> please validate inputs at the API boundary
|
|
152
|
+
<!-- END:learned -->
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Review the suggestions, paste the keepers into AGENTS.md. The similarity threshold is intentionally permissive — false positives are easy to reject, missed signal is harder to recover. There are no ML dependencies; it's regex, a stopword list, and a five-line stemmer.
|
|
156
|
+
|
|
157
|
+
## Update safety
|
|
158
|
+
|
|
159
|
+
haac-aikit owns content between BEGIN/END markers. Everything outside is yours.
|
|
81
160
|
|
|
82
161
|
```markdown
|
|
83
162
|
# My Project
|
|
84
163
|
|
|
85
|
-
My
|
|
164
|
+
My own notes — never touched by aikit.
|
|
86
165
|
|
|
87
166
|
<!-- BEGIN:haac-aikit -->
|
|
88
|
-
|
|
167
|
+
managed content
|
|
89
168
|
<!-- END:haac-aikit -->
|
|
90
169
|
|
|
91
170
|
More of my notes — also never touched.
|
|
92
171
|
```
|
|
93
172
|
|
|
94
|
-
`aikit sync`
|
|
173
|
+
`aikit sync` is idempotent: running it twice produces the same files. `aikit diff` shows what would change. `aikit update` shows the diff and prompts before writing.
|
|
174
|
+
|
|
175
|
+
The marker engine handles four dialects automatically (`.md` → `<!-- ... -->`, `.yml` → `# `, `.json` → `// `, shell → `# `). If a downstream user removes a marker by accident, the hook refuses to silently re-append — it errors out so you can investigate.
|
|
95
176
|
|
|
96
|
-
|
|
177
|
+
## Commands
|
|
97
178
|
|
|
98
|
-
|
|
179
|
+
```
|
|
180
|
+
aikit interactive wizard
|
|
181
|
+
aikit sync regenerate from .aikitrc.json (idempotent)
|
|
182
|
+
aikit update pull latest templates, show diff, prompt
|
|
183
|
+
aikit diff show drift between current state and a fresh generation
|
|
184
|
+
aikit add <item> add a single skill, command, agent, or hook
|
|
185
|
+
aikit list show installed items + catalog availability
|
|
186
|
+
aikit doctor schema, triggers, broken-link checks
|
|
187
|
+
aikit doctor --rules rule observability buckets
|
|
188
|
+
aikit report Markdown adherence summary
|
|
189
|
+
aikit report --format=json same data, structured for CI
|
|
190
|
+
aikit learn --limit=30 propose rules from your PR review history
|
|
191
|
+
```
|
|
99
192
|
|
|
100
|
-
|
|
193
|
+
Most prompts have a `--flag` equivalent for headless use.
|
|
101
194
|
|
|
102
|
-
|
|
103
|
-
- **≤200 lines** AGENTS.md enforced in CI
|
|
104
|
-
- **Zero LLM-generated dumps** — every shipped artifact is human-curated (ETH Zurich 2026 found LLM dumps add cost, don't improve success rate)
|
|
105
|
-
- **3 MCP servers by default** — filesystem + memory + fetch only (5 servers = ~77K tokens of tool defs)
|
|
195
|
+
## Design choices, in case they help you decide
|
|
106
196
|
|
|
107
|
-
|
|
197
|
+
- **Skills are ~100 tokens at rest.** Bodies load only when the skill is triggered. A kit with 30 always-on skill bodies eats your context window before you've started.
|
|
198
|
+
- **AGENTS.md is canonical, CLAUDE.md is a 5-line shim that imports it.** One source of truth across all tools.
|
|
199
|
+
- **Three MCP servers by default.** Five servers can be ~77K tokens of tool definitions. Most projects don't need a search engine *and* a database *and* a filesystem in every conversation.
|
|
200
|
+
- **Marker-protected templates.** This was the first thing I broke in my own setup before adding the marker engine. Your edits outside the markers survive every `sync`.
|
|
201
|
+
- **No LLM-generated content in the catalog.** Every shipped skill / hook / agent is human-curated. ETH Zurich's 2026 study on LLM-augmented context found dumps add cost without improving success rate.
|
|
108
202
|
|
|
109
|
-
##
|
|
203
|
+
## How haac-aikit compares
|
|
110
204
|
|
|
111
205
|
| | haac-aikit | rulesync | ruler | claudekit |
|
|
112
206
|
|---|---|---|---|---|
|
|
113
|
-
|
|
|
114
|
-
| Cross-tool |
|
|
115
|
-
| Open Skills standard
|
|
116
|
-
| Config file backed |
|
|
117
|
-
| Idempotent markers |
|
|
207
|
+
| Includes content (skills, agents, hooks) | yes | no — config manager only | no — config manager only | Claude-only |
|
|
208
|
+
| Cross-tool | 7 tools | yes | yes | no |
|
|
209
|
+
| Open Skills standard (agentskills.io) | yes | no | no | no |
|
|
210
|
+
| Config file backed | `.aikitrc.json` | no | no | no |
|
|
211
|
+
| Idempotent BEGIN/END markers | yes | no | `.bak` backups | no |
|
|
212
|
+
| Rule observability | yes | no | no | no |
|
|
213
|
+
| Dialect translation | yes | no | no | no |
|
|
214
|
+
| Learn from PR history | yes | no | no | no |
|
|
215
|
+
|
|
216
|
+
## Status
|
|
118
217
|
|
|
119
|
-
|
|
218
|
+
This is 0.4.0. The strategy plan reserves 1.0 until at least three external teams have used the observability loop on real PRs — until then, expect breaking changes between minor versions. The Cursor dialect translator is the only one shipping in 0.4.0; Claude, Aider, Copilot, and Gemini translators are next.
|
|
120
219
|
|
|
121
220
|
## Contributing
|
|
122
221
|
|
|
123
222
|
Issues and PRs welcome at [github.com/Hamad-Center/haac-aikit](https://github.com/Hamad-Center/haac-aikit).
|
|
124
223
|
|
|
125
|
-
|
|
224
|
+
I'm looking for **three teams** to try the observability loop on a real codebase. Your feedback shapes 1.0. Comment on [issue #1](https://github.com/Hamad-Center/haac-aikit/issues/1) if you're up for it.
|
|
126
225
|
|
|
127
|
-
## License
|
|
226
|
+
## License
|
|
128
227
|
|
|
129
|
-
MIT. See [ATTRIBUTIONS.md](ATTRIBUTIONS.md) for adapted sources.
|
|
228
|
+
MIT. See [ATTRIBUTIONS.md](ATTRIBUTIONS.md) for the list of adapted sources.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: aikit rule observability
|
|
2
|
+
|
|
3
|
+
# Posts (or updates) a sticky PR comment with the aikit rule-adherence report.
|
|
4
|
+
# Requires .aikit/events.jsonl to be present in the PR branch (or downloadable
|
|
5
|
+
# from a previous job artifact). Customise the "Fetch telemetry" step to suit
|
|
6
|
+
# how your team aggregates events across runs.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [main]
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pull-requests: write
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
rule-report:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: "20"
|
|
25
|
+
|
|
26
|
+
- name: Install haac-aikit
|
|
27
|
+
run: npm install -g haac-aikit
|
|
28
|
+
|
|
29
|
+
# CUSTOMISE: point this at wherever your team stores rolled-up telemetry.
|
|
30
|
+
# Examples: download an artifact, restore from cache, pull from S3.
|
|
31
|
+
- name: Fetch telemetry
|
|
32
|
+
run: |
|
|
33
|
+
mkdir -p .aikit
|
|
34
|
+
if [ -f .aikit/events.jsonl ]; then
|
|
35
|
+
echo "Using committed telemetry."
|
|
36
|
+
else
|
|
37
|
+
echo "No telemetry found — report will say 'no_telemetry'."
|
|
38
|
+
touch .aikit/events.jsonl
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
- name: Generate rule-adherence report
|
|
42
|
+
id: report
|
|
43
|
+
run: |
|
|
44
|
+
aikit report --format=markdown > /tmp/aikit-report.md
|
|
45
|
+
{
|
|
46
|
+
echo 'report<<HAAC_EOF'
|
|
47
|
+
cat /tmp/aikit-report.md
|
|
48
|
+
echo HAAC_EOF
|
|
49
|
+
} >> "$GITHUB_OUTPUT"
|
|
50
|
+
|
|
51
|
+
- name: Post or update sticky PR comment
|
|
52
|
+
uses: marocchino/sticky-pull-request-comment@v2
|
|
53
|
+
with:
|
|
54
|
+
header: aikit-rule-observability
|
|
55
|
+
message: ${{ steps.report.outputs.report }}
|