continuous-improvement 3.17.0 → 3.19.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/.claude-plugin/marketplace.json +1 -1
- package/README.md +165 -99
- package/bin/audit-actions.mjs +433 -0
- package/bin/check-command-count.mjs +114 -0
- package/bin/generate-plugin-manifests.mjs +1 -0
- package/bin/portfolio-health.mjs +298 -0
- package/commands/reconcile.md +34 -7
- package/hooks/gateguard.mjs +137 -3
- package/hooks/typecheck-stop.mjs +117 -0
- package/lib/gateguard-state.mjs +5 -1
- package/lib/plugin-metadata.mjs +10 -2
- package/lib/typecheck-gate.mjs +62 -0
- package/package.json +12 -6
- package/plugins/beginner.json +1 -1
- package/plugins/continuous-improvement/.claude-plugin/marketplace.json +1 -1
- package/plugins/continuous-improvement/.claude-plugin/plugin.json +1 -1
- package/plugins/continuous-improvement/commands/reconcile.md +34 -7
- package/plugins/continuous-improvement/hooks/gateguard.mjs +137 -3
- package/plugins/continuous-improvement/hooks/hooks.json +6 -1
- package/plugins/continuous-improvement/hooks/typecheck-stop.mjs +117 -0
- package/plugins/continuous-improvement/lib/gateguard-state.mjs +5 -1
- package/plugins/continuous-improvement/lib/plugin-metadata.mjs +10 -2
- package/plugins/continuous-improvement/lib/typecheck-gate.mjs +62 -0
- package/plugins/continuous-improvement/skills/README.md +1 -1
- package/plugins/continuous-improvement/skills/gateguard/SKILL.md +10 -0
- package/plugins/continuous-improvement/skills/reconcile/SKILL.md +52 -4
- package/plugins/expert.json +1 -1
- package/skills/gateguard.md +10 -0
- package/skills/reconcile.md +52 -4
- package/templates/actions_security_checklist.md +39 -0
- package/templates/experiment_template.md +38 -0
- package/templates/portfolio_event.schema.json +69 -0
- package/templates/release_receipt_template.md +37 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision helpers for the typecheck Stop gate (RISA 4 / G4).
|
|
3
|
+
*
|
|
4
|
+
* The hook (src/hooks/typecheck-stop.mts) does the I/O — git, spawning the
|
|
5
|
+
* typecheck, emitting the decision. Everything here is pure and unit-tested so
|
|
6
|
+
* the mode/selection/formatting logic is provable without spawning a compiler.
|
|
7
|
+
*
|
|
8
|
+
* Mode via CLAUDE_TYPECHECK_GATE: "off" (default) | "warn" | "block".
|
|
9
|
+
* - off : no-op. The default. The global ~/.claude typecheck-changed.sh
|
|
10
|
+
* already emits an advisory systemMessage; this hook stays silent
|
|
11
|
+
* until opted in, so there is no double-advisory and no regression.
|
|
12
|
+
* - warn : print a one-line notice to stderr; never blocks.
|
|
13
|
+
* - block : emit {"decision":"block","reason":...} so the failure re-enters
|
|
14
|
+
* model context — the fix headless/autonomous -p loops need.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveTypecheckMode(raw) {
|
|
17
|
+
const value = (raw ?? "").trim().toLowerCase();
|
|
18
|
+
return value === "block" || value === "warn" ? value : "off";
|
|
19
|
+
}
|
|
20
|
+
// Matches the extensions typecheck-changed.sh screens for. `.d.ts` ends in
|
|
21
|
+
// `.ts` so it counts — a changed ambient declaration can still break the build.
|
|
22
|
+
const TS_FILE_RE = /\.(ts|tsx|mts|cts)$/;
|
|
23
|
+
export function hasChangedTsFile(files) {
|
|
24
|
+
return files.some((file) => TS_FILE_RE.test(file.trim()));
|
|
25
|
+
}
|
|
26
|
+
// Split a `git diff --name-only` blob into a clean path list (drops blank lines).
|
|
27
|
+
export function parseChangedFiles(gitOutput) {
|
|
28
|
+
return (gitOutput ?? "")
|
|
29
|
+
.split(/\r?\n/)
|
|
30
|
+
.map((line) => line.trim())
|
|
31
|
+
.filter((line) => line.length > 0);
|
|
32
|
+
}
|
|
33
|
+
// Prefer the project's own `typecheck` npm script (authoritative — it encodes
|
|
34
|
+
// the project's exact flags), else a local tsc, else null (a TS project with no
|
|
35
|
+
// runnable typecheck stays silent rather than guessing).
|
|
36
|
+
export function pickTypecheckKind(hasNpmTypecheckScript, hasLocalTsc) {
|
|
37
|
+
if (hasNpmTypecheckScript)
|
|
38
|
+
return "npm";
|
|
39
|
+
if (hasLocalTsc)
|
|
40
|
+
return "tsc";
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
export function formatTypecheckReason(output, maxLines = 15) {
|
|
44
|
+
const tail = (output ?? "")
|
|
45
|
+
.split(/\r?\n/)
|
|
46
|
+
.filter((line) => line.length > 0)
|
|
47
|
+
.slice(-maxLines)
|
|
48
|
+
.join("\n");
|
|
49
|
+
return `Typecheck FAILED on changed TS files — fix before ending the turn:\n${tail}`;
|
|
50
|
+
}
|
|
51
|
+
// The single decision point. `ranTypecheck` is false when the gate short-circuited
|
|
52
|
+
// (mode off, no TS project, no changed TS file, no runnable typecheck, or the run
|
|
53
|
+
// timed out) — all of which allow. A conclusive non-zero rc maps to the mode.
|
|
54
|
+
export function decideTypecheckAction(input) {
|
|
55
|
+
if (input.mode === "off")
|
|
56
|
+
return "allow";
|
|
57
|
+
if (!input.ranTypecheck)
|
|
58
|
+
return "allow";
|
|
59
|
+
if (input.rc === 0)
|
|
60
|
+
return "allow";
|
|
61
|
+
return input.mode;
|
|
62
|
+
}
|
|
@@ -30,7 +30,7 @@ skill set on disk.
|
|
|
30
30
|
- `grill-with-docs` — Enforces Law 1 (Research Before Executing) and Law 7 (Learn From Every Session) of the 7 Laws of AI Agent Discipline. Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates CONTEXT.md + ADRs inline as decisions crystallise. Ported from mattpocock/skills under MIT.
|
|
31
31
|
- `handoff` — Enforces Law 5 (Reflect After Every Session) of the 7 Laws of AI Agent Discipline. Compact the current conversation into a handoff document for another agent to pick up. Ported from mattpocock/skills under MIT.
|
|
32
32
|
- `intent-driven-development` — Enforces Law 2 (Plan Is Sacred) of the 7 Laws of AI Agent Discipline. Turn an ambiguous or high-impact change into scoped, verifiable acceptance criteria (observable AC-NNN, explicit in/out scope, named verification methods, and a [revised] protocol that forbids silently dropping a criterion) before or alongside implementation, so the plan that gets built is the plan that was agreed, not an invented default. Use when clarifying a feature, defining acceptance criteria, de-risking a security/data/migration/integration change, or preparing implementation requirements for another agent. Do not trigger for trivial edits, straightforward fixes, active debugging, or code review.
|
|
33
|
-
- `reconcile` — Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations,
|
|
33
|
+
- `reconcile` — Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations, then carries the known-good state through to a landed PR: stage by filename, commit one concern, push the feature branch, verify the push landed, open the PR, and after the PR merges fast-forward the default branch and check it out.
|
|
34
34
|
- `recovery-classification` — Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. After any failure in the verification ladder or auto-loop, classify the failure class before retrying — provider, tool-schema, deterministic-policy, git, worktree, runtime — so retry-vs-pause-vs-self-heal-vs-stop is an intentional decision, not a generic 'try again'.
|
|
35
35
|
- `roast` — Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Convene a 5-persona adversarial council (Contrarian, Expansionist, Logician, Researcher, Buyer) that attacks an idea from every angle, then a Judge returns one GO / RESHAPE / KILL verdict plus the cheapest 48-hour test to de-risk it — so you pressure-test an idea before sinking time into building the wrong thing.
|
|
36
36
|
- `safety-guard` — Enforces Law 3 (One Thing at a Time) of the 7 Laws of AI Agent Discipline by scoping edits to a directory and blocking destructive shell commands. Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
|
|
@@ -150,6 +150,14 @@ The block reason prints the exact `gateguard-session.json` path and the clearanc
|
|
|
150
150
|
|
|
151
151
|
The inline `_gateguard_facts_presented: true` retry still works on harnesses that forward unknown tool params, but Claude Code's strict tool schema (`additionalProperties: false`) rejects it with `InputValidationError` — use one of the above on Claude Code.
|
|
152
152
|
|
|
153
|
+
### Excluding low-risk paths
|
|
154
|
+
|
|
155
|
+
Set the `CI_GATEGUARD_EXCLUDE` environment variable to opt specific low-risk paths out of the gate entirely — an LLM-maintained prose wiki, a generated scratch directory, anything where the fact-forcing pause costs more than it saves. The value is a comma-separated list of path substrings, each matched case-insensitively against the forward-slash-normalized file path, so `/mywiki/` excludes `D:\Vault\MyWiki\notes\x.md`. Unset or empty (the default) changes nothing: every mutating file call is gated exactly as before, and a call that touches a mix of excluded and non-excluded paths still gates the non-excluded ones. Set it per project in `.claude/settings.json` under `env`, or globally in `~/.claude/settings.json`.
|
|
156
|
+
|
|
157
|
+
### Locking edits to the current repo
|
|
158
|
+
|
|
159
|
+
A fact-list can't catch a wrong-repo or wrong-worktree write — you can present perfect facts about the wrong file, in the wrong checkout. Set `CI_GATEGUARD_TARGET_LOCK=block` to make the runtime hook (`hooks/gateguard.mjs`) refuse any mutating call whose **absolute** target canonicalizes outside the session project root (`CLAUDE_PROJECT_DIR`, or the git toplevel). Relative paths resolve under the current directory (= the root) and always pass; only an absolute path into a different tree is denied, and the deny reason names both the stray target and the expected root. This runs before the fact gate and independent of clearance — a wrong-repo write is wrong even with facts. Unset (the default) checks nothing, so legitimate out-of-root edits (`~/.claude`, a `/tmp` scratch file, a sibling repo) are unaffected; turn it on per session in a multi-worktree or headless run where cross-repo writes are the real risk. Paths already covered by `CI_GATEGUARD_EXCLUDE` are never target-locked.
|
|
160
|
+
|
|
153
161
|
### Limitations and guarantees
|
|
154
162
|
|
|
155
163
|
- **Honor system.** Clearance is recorded by `ci_gateguard_clear`, the `gateguard-clear.mjs` CLI, a manual state-file write, or the inline `_gateguard_facts_presented` flag where the harness allows it (see "Clearing the gate" above). The hook can't verify the investigation actually happened; the 50-file cap — counted per session — bounds damage from stuck loops or rogue agents.
|
|
@@ -175,6 +183,8 @@ The standalone `gateguard-ai` Python/CLI package referenced in earlier drafts of
|
|
|
175
183
|
- Let the gate fire naturally. Don't try to pre-answer the gate questions — the investigation itself is what improves quality.
|
|
176
184
|
- Customize gate messages for your domain. If your project has specific conventions, add them to the gate prompts.
|
|
177
185
|
- Use `.gateguard.yml` to ignore paths like `.venv/`, `node_modules/`, `.git/`.
|
|
186
|
+
- For the shipped runtime hook, set `CI_GATEGUARD_EXCLUDE` (comma-separated path substrings) to exclude low-risk paths from the gate — see [Excluding low-risk paths](#excluding-low-risk-paths).
|
|
187
|
+
- In multi-worktree or headless runs, set `CI_GATEGUARD_TARGET_LOCK=block` so a write into the wrong repo/worktree is refused — see [Locking edits to the current repo](#locking-edits-to-the-current-repo).
|
|
178
188
|
|
|
179
189
|
## Related Skills
|
|
180
190
|
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reconcile
|
|
3
3
|
tier: "2"
|
|
4
|
-
description: Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations,
|
|
4
|
+
description: Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations, then carries the known-good state through to a landed PR: stage by filename, commit one concern, push the feature branch, verify the push landed, open the PR, and after the PR merges fast-forward the default branch and check it out.
|
|
5
5
|
origin: continuous-improvement
|
|
6
6
|
user-invocable: true
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# Reconcile — Ground
|
|
9
|
+
# Reconcile — Ground Truth, Then Commit, Push, and Open the PR
|
|
10
10
|
|
|
11
|
-
Law 1 says research before executing. The most expensive skipped research is the state of your own repo: a branch that shifted under you, a push that silently did not land, a stash from a session you forgot. This skill establishes git ground truth first, acts only on a known state,
|
|
11
|
+
Law 1 says research before executing. The most expensive skipped research is the state of your own repo: a branch that shifted under you, a push that silently did not land, a stash from a session you forgot. This skill establishes git ground truth first, acts only on a known state, stops at every operation that is hard to reverse, and then carries that known-good state all the way through a single-concern commit, a push, and an open PR — ending back on an up-to-date default branch once the PR merges.
|
|
12
12
|
|
|
13
13
|
## When to Activate
|
|
14
14
|
|
|
15
15
|
- Before any branch/merge/rebase/push when more than one session, loop, or agent may be writing to the tree.
|
|
16
16
|
- When the working tree looks different from what you expect (unexpected branch, surprise modifications, a half-finished merge).
|
|
17
17
|
- Before cleaning up: consolidating branches, dropping stashes, removing worktrees.
|
|
18
|
+
- When finished work needs to land: stage it, commit one concern, push a feature branch, open a PR, and return to an up-to-date default branch.
|
|
18
19
|
- After a push, to confirm it actually landed on the remote.
|
|
19
20
|
|
|
20
21
|
## Establish Ground Truth First
|
|
@@ -24,7 +25,7 @@ Read before you write. Capture the full state in one pass:
|
|
|
24
25
|
```
|
|
25
26
|
git branch --show-current
|
|
26
27
|
git status --porcelain=v1
|
|
27
|
-
git rev-list --left-right --count @{u}...HEAD # behind / ahead of upstream
|
|
28
|
+
git rev-list --left-right --count '@{u}...HEAD' # behind / ahead of upstream (quote the ref — bare @{u} trips the Bash parser)
|
|
28
29
|
git stash list
|
|
29
30
|
git worktree list
|
|
30
31
|
ls .git/MERGE_HEAD .git/rebase-merge .git/rebase-apply 2>/dev/null # in-progress operation?
|
|
@@ -57,10 +58,43 @@ Branch from a base only after confirming `local <base>` equals `origin/<base>`
|
|
|
57
58
|
STOP and get explicit authorization before:
|
|
58
59
|
|
|
59
60
|
- Pushing to a protected branch (e.g. `main`) — this repo's flow is feature branch + PR, never direct push.
|
|
61
|
+
- Merging the PR you opened, or force-deleting a branch (`git branch -D`) — both stay human decisions, never auto-actions on green CI.
|
|
60
62
|
- `git push --force` / `--force-with-lease`, `git reset --hard`, `git clean -fd`, `worktree remove` on a dirty worktree, or dropping a stash with uncommitted value.
|
|
61
63
|
|
|
62
64
|
If a rebase has diverged and force-push is gated, do not force-recover — supersede via a new branch + new PR.
|
|
63
65
|
|
|
66
|
+
## Commit and Open the PR
|
|
67
|
+
|
|
68
|
+
Once ground truth is known and the halt gates are clear, carry the work to an open PR without leaving the known-good state. This tail is self-contained — it reimplements the commit → push → PR steps with plain git/`gh` and depends on no companion plugin.
|
|
69
|
+
|
|
70
|
+
1. **Cut or confirm a feature branch from a fresh base.** Never commit onto a protected branch. Sync the default branch first so the feature branch is not born stale:
|
|
71
|
+
```
|
|
72
|
+
git switch main && git pull --ff-only origin main # master on older repos
|
|
73
|
+
git switch -c <type>/<slug> # only if not already on a feature branch
|
|
74
|
+
```
|
|
75
|
+
Confirm `local main` equals `origin/main` before branching — a squash-merge otherwise bundles ahead-of-origin commits.
|
|
76
|
+
|
|
77
|
+
2. **Stage by explicit filename.** One concern per commit. On an `autocrlf` tree `git add -A` / `git add .` commits phantom line-ending-only changes — name each path and read real drift with `git diff --stat`.
|
|
78
|
+
```
|
|
79
|
+
git add path/one path/two
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
3. **Commit with a Windows-safe message.** Lead with the observable outcome. Use a single-line `-m` (repeat `-m` for paragraphs) or `git commit -F <tempfile>` — never a multi-line here-doc/here-string, which CRLF and shell quoting corrupt on Windows.
|
|
83
|
+
```
|
|
84
|
+
git commit -m "feat(scope): <observable outcome>"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. **Push the feature branch** (never the protected branch), then verify it landed via the section below:
|
|
88
|
+
```
|
|
89
|
+
git push -u origin <type>/<slug>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
5. **Open one PR** citing the plan or issue, then stop:
|
|
93
|
+
```
|
|
94
|
+
gh pr create --fill --base main
|
|
95
|
+
```
|
|
96
|
+
**Stop here.** The merge is a human decision. `reconcile` never merges the PR, never uses `--admin` / `--force` / `--no-verify`, never auto-merges on green CI, and never deploys.
|
|
97
|
+
|
|
64
98
|
## Verify the Push Actually Landed
|
|
65
99
|
|
|
66
100
|
A push that printed no error is still a claim. Confirm:
|
|
@@ -72,9 +106,23 @@ git ls-remote origin refs/heads/<branch> # remote tip must equal local HEAD
|
|
|
72
106
|
|
|
73
107
|
If the remote ref is absent or behind, the push did not land — investigate before reporting success.
|
|
74
108
|
|
|
109
|
+
## Sync the Default Branch After the PR Merges
|
|
110
|
+
|
|
111
|
+
"All the latest work on main" is only true once the PR actually merges — and on a protected branch that merge is a human action, not something `reconcile` performs. After the merge lands, return to an up-to-date default branch:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
git switch main # or master on older repos
|
|
115
|
+
git pull --ff-only origin main # fast-forward only; never a merge commit or --force
|
|
116
|
+
git rev-parse HEAD # confirm this equals the squash-merge SHA from the PR
|
|
117
|
+
git branch -d <type>/<slug> # delete the merged feature branch (safe -d, never -D)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`--ff-only` is deliberate: if the pull would not fast-forward, main diverged under you — stop and re-survey from **Establish Ground Truth First** instead of forcing it. You end on the default branch with every merged change present and the feature branch cleaned up.
|
|
121
|
+
|
|
75
122
|
## Pairs With
|
|
76
123
|
|
|
77
124
|
- **`recall`** (Law 1) — before a risky git op, recall whether the same operation failed on this repo before.
|
|
78
125
|
- **`gateguard`** (Law 1) — the runtime gate (`hooks/gateguard.mjs`); `reconcile` is the procedure you run once a destructive git action is in play.
|
|
79
126
|
- **`safety-guard`** — destructive-operation guardrails for production and autonomous runs.
|
|
80
127
|
- **`audit`** (Law 4) — when an audit ends in a fix, `reconcile` is the safe path from branch to landed PR.
|
|
128
|
+
- **`commit-commands:commit-push-pr`** — the external-plugin equivalent of the commit → push → PR tail; `reconcile` reimplements it inline so the flow works with no companion installed. For a TDD-gated single-defect variant, use `/ship`.
|
package/plugins/expert.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "continuous-improvement",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"mode": "expert",
|
|
5
5
|
"description": "Expert mode: tune confidence, manage instincts, and persist plans on disk. Adds safety, token-budget, and strategic-compact skills plus the /learn-eval command so long sessions stay sharp and learnings survive context resets.",
|
|
6
6
|
"tools": [
|
package/skills/gateguard.md
CHANGED
|
@@ -150,6 +150,14 @@ The block reason prints the exact `gateguard-session.json` path and the clearanc
|
|
|
150
150
|
|
|
151
151
|
The inline `_gateguard_facts_presented: true` retry still works on harnesses that forward unknown tool params, but Claude Code's strict tool schema (`additionalProperties: false`) rejects it with `InputValidationError` — use one of the above on Claude Code.
|
|
152
152
|
|
|
153
|
+
### Excluding low-risk paths
|
|
154
|
+
|
|
155
|
+
Set the `CI_GATEGUARD_EXCLUDE` environment variable to opt specific low-risk paths out of the gate entirely — an LLM-maintained prose wiki, a generated scratch directory, anything where the fact-forcing pause costs more than it saves. The value is a comma-separated list of path substrings, each matched case-insensitively against the forward-slash-normalized file path, so `/mywiki/` excludes `D:\Vault\MyWiki\notes\x.md`. Unset or empty (the default) changes nothing: every mutating file call is gated exactly as before, and a call that touches a mix of excluded and non-excluded paths still gates the non-excluded ones. Set it per project in `.claude/settings.json` under `env`, or globally in `~/.claude/settings.json`.
|
|
156
|
+
|
|
157
|
+
### Locking edits to the current repo
|
|
158
|
+
|
|
159
|
+
A fact-list can't catch a wrong-repo or wrong-worktree write — you can present perfect facts about the wrong file, in the wrong checkout. Set `CI_GATEGUARD_TARGET_LOCK=block` to make the runtime hook (`hooks/gateguard.mjs`) refuse any mutating call whose **absolute** target canonicalizes outside the session project root (`CLAUDE_PROJECT_DIR`, or the git toplevel). Relative paths resolve under the current directory (= the root) and always pass; only an absolute path into a different tree is denied, and the deny reason names both the stray target and the expected root. This runs before the fact gate and independent of clearance — a wrong-repo write is wrong even with facts. Unset (the default) checks nothing, so legitimate out-of-root edits (`~/.claude`, a `/tmp` scratch file, a sibling repo) are unaffected; turn it on per session in a multi-worktree or headless run where cross-repo writes are the real risk. Paths already covered by `CI_GATEGUARD_EXCLUDE` are never target-locked.
|
|
160
|
+
|
|
153
161
|
### Limitations and guarantees
|
|
154
162
|
|
|
155
163
|
- **Honor system.** Clearance is recorded by `ci_gateguard_clear`, the `gateguard-clear.mjs` CLI, a manual state-file write, or the inline `_gateguard_facts_presented` flag where the harness allows it (see "Clearing the gate" above). The hook can't verify the investigation actually happened; the 50-file cap — counted per session — bounds damage from stuck loops or rogue agents.
|
|
@@ -175,6 +183,8 @@ The standalone `gateguard-ai` Python/CLI package referenced in earlier drafts of
|
|
|
175
183
|
- Let the gate fire naturally. Don't try to pre-answer the gate questions — the investigation itself is what improves quality.
|
|
176
184
|
- Customize gate messages for your domain. If your project has specific conventions, add them to the gate prompts.
|
|
177
185
|
- Use `.gateguard.yml` to ignore paths like `.venv/`, `node_modules/`, `.git/`.
|
|
186
|
+
- For the shipped runtime hook, set `CI_GATEGUARD_EXCLUDE` (comma-separated path substrings) to exclude low-risk paths from the gate — see [Excluding low-risk paths](#excluding-low-risk-paths).
|
|
187
|
+
- In multi-worktree or headless runs, set `CI_GATEGUARD_TARGET_LOCK=block` so a write into the wrong repo/worktree is refused — see [Locking edits to the current repo](#locking-edits-to-the-current-repo).
|
|
178
188
|
|
|
179
189
|
## Related Skills
|
|
180
190
|
|
package/skills/reconcile.md
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reconcile
|
|
3
3
|
tier: "2"
|
|
4
|
-
description: Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations,
|
|
4
|
+
description: Enforces Law 1 (Research Before Executing) of the 7 Laws of AI Agent Discipline. Establishes git ground truth — branch, status, stashes, worktrees, ahead/behind — before any mutation, halts on protected or destructive operations, then carries the known-good state through to a landed PR: stage by filename, commit one concern, push the feature branch, verify the push landed, open the PR, and after the PR merges fast-forward the default branch and check it out.
|
|
5
5
|
origin: continuous-improvement
|
|
6
6
|
user-invocable: true
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# Reconcile — Ground
|
|
9
|
+
# Reconcile — Ground Truth, Then Commit, Push, and Open the PR
|
|
10
10
|
|
|
11
|
-
Law 1 says research before executing. The most expensive skipped research is the state of your own repo: a branch that shifted under you, a push that silently did not land, a stash from a session you forgot. This skill establishes git ground truth first, acts only on a known state,
|
|
11
|
+
Law 1 says research before executing. The most expensive skipped research is the state of your own repo: a branch that shifted under you, a push that silently did not land, a stash from a session you forgot. This skill establishes git ground truth first, acts only on a known state, stops at every operation that is hard to reverse, and then carries that known-good state all the way through a single-concern commit, a push, and an open PR — ending back on an up-to-date default branch once the PR merges.
|
|
12
12
|
|
|
13
13
|
## When to Activate
|
|
14
14
|
|
|
15
15
|
- Before any branch/merge/rebase/push when more than one session, loop, or agent may be writing to the tree.
|
|
16
16
|
- When the working tree looks different from what you expect (unexpected branch, surprise modifications, a half-finished merge).
|
|
17
17
|
- Before cleaning up: consolidating branches, dropping stashes, removing worktrees.
|
|
18
|
+
- When finished work needs to land: stage it, commit one concern, push a feature branch, open a PR, and return to an up-to-date default branch.
|
|
18
19
|
- After a push, to confirm it actually landed on the remote.
|
|
19
20
|
|
|
20
21
|
## Establish Ground Truth First
|
|
@@ -24,7 +25,7 @@ Read before you write. Capture the full state in one pass:
|
|
|
24
25
|
```
|
|
25
26
|
git branch --show-current
|
|
26
27
|
git status --porcelain=v1
|
|
27
|
-
git rev-list --left-right --count @{u}...HEAD # behind / ahead of upstream
|
|
28
|
+
git rev-list --left-right --count '@{u}...HEAD' # behind / ahead of upstream (quote the ref — bare @{u} trips the Bash parser)
|
|
28
29
|
git stash list
|
|
29
30
|
git worktree list
|
|
30
31
|
ls .git/MERGE_HEAD .git/rebase-merge .git/rebase-apply 2>/dev/null # in-progress operation?
|
|
@@ -57,10 +58,43 @@ Branch from a base only after confirming `local <base>` equals `origin/<base>`
|
|
|
57
58
|
STOP and get explicit authorization before:
|
|
58
59
|
|
|
59
60
|
- Pushing to a protected branch (e.g. `main`) — this repo's flow is feature branch + PR, never direct push.
|
|
61
|
+
- Merging the PR you opened, or force-deleting a branch (`git branch -D`) — both stay human decisions, never auto-actions on green CI.
|
|
60
62
|
- `git push --force` / `--force-with-lease`, `git reset --hard`, `git clean -fd`, `worktree remove` on a dirty worktree, or dropping a stash with uncommitted value.
|
|
61
63
|
|
|
62
64
|
If a rebase has diverged and force-push is gated, do not force-recover — supersede via a new branch + new PR.
|
|
63
65
|
|
|
66
|
+
## Commit and Open the PR
|
|
67
|
+
|
|
68
|
+
Once ground truth is known and the halt gates are clear, carry the work to an open PR without leaving the known-good state. This tail is self-contained — it reimplements the commit → push → PR steps with plain git/`gh` and depends on no companion plugin.
|
|
69
|
+
|
|
70
|
+
1. **Cut or confirm a feature branch from a fresh base.** Never commit onto a protected branch. Sync the default branch first so the feature branch is not born stale:
|
|
71
|
+
```
|
|
72
|
+
git switch main && git pull --ff-only origin main # master on older repos
|
|
73
|
+
git switch -c <type>/<slug> # only if not already on a feature branch
|
|
74
|
+
```
|
|
75
|
+
Confirm `local main` equals `origin/main` before branching — a squash-merge otherwise bundles ahead-of-origin commits.
|
|
76
|
+
|
|
77
|
+
2. **Stage by explicit filename.** One concern per commit. On an `autocrlf` tree `git add -A` / `git add .` commits phantom line-ending-only changes — name each path and read real drift with `git diff --stat`.
|
|
78
|
+
```
|
|
79
|
+
git add path/one path/two
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
3. **Commit with a Windows-safe message.** Lead with the observable outcome. Use a single-line `-m` (repeat `-m` for paragraphs) or `git commit -F <tempfile>` — never a multi-line here-doc/here-string, which CRLF and shell quoting corrupt on Windows.
|
|
83
|
+
```
|
|
84
|
+
git commit -m "feat(scope): <observable outcome>"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. **Push the feature branch** (never the protected branch), then verify it landed via the section below:
|
|
88
|
+
```
|
|
89
|
+
git push -u origin <type>/<slug>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
5. **Open one PR** citing the plan or issue, then stop:
|
|
93
|
+
```
|
|
94
|
+
gh pr create --fill --base main
|
|
95
|
+
```
|
|
96
|
+
**Stop here.** The merge is a human decision. `reconcile` never merges the PR, never uses `--admin` / `--force` / `--no-verify`, never auto-merges on green CI, and never deploys.
|
|
97
|
+
|
|
64
98
|
## Verify the Push Actually Landed
|
|
65
99
|
|
|
66
100
|
A push that printed no error is still a claim. Confirm:
|
|
@@ -72,9 +106,23 @@ git ls-remote origin refs/heads/<branch> # remote tip must equal local HEAD
|
|
|
72
106
|
|
|
73
107
|
If the remote ref is absent or behind, the push did not land — investigate before reporting success.
|
|
74
108
|
|
|
109
|
+
## Sync the Default Branch After the PR Merges
|
|
110
|
+
|
|
111
|
+
"All the latest work on main" is only true once the PR actually merges — and on a protected branch that merge is a human action, not something `reconcile` performs. After the merge lands, return to an up-to-date default branch:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
git switch main # or master on older repos
|
|
115
|
+
git pull --ff-only origin main # fast-forward only; never a merge commit or --force
|
|
116
|
+
git rev-parse HEAD # confirm this equals the squash-merge SHA from the PR
|
|
117
|
+
git branch -d <type>/<slug> # delete the merged feature branch (safe -d, never -D)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`--ff-only` is deliberate: if the pull would not fast-forward, main diverged under you — stop and re-survey from **Establish Ground Truth First** instead of forcing it. You end on the default branch with every merged change present and the feature branch cleaned up.
|
|
121
|
+
|
|
75
122
|
## Pairs With
|
|
76
123
|
|
|
77
124
|
- **`recall`** (Law 1) — before a risky git op, recall whether the same operation failed on this repo before.
|
|
78
125
|
- **`gateguard`** (Law 1) — the runtime gate (`hooks/gateguard.mjs`); `reconcile` is the procedure you run once a destructive git action is in play.
|
|
79
126
|
- **`safety-guard`** — destructive-operation guardrails for production and autonomous runs.
|
|
80
127
|
- **`audit`** (Law 4) — when an audit ends in a fix, `reconcile` is the safe path from branch to landed PR.
|
|
128
|
+
- **`commit-commands:commit-push-pr`** — the external-plugin equivalent of the commit → push → PR tail; `reconcile` reimplements it inline so the flow works with no companion installed. For a TDD-gated single-defect variant, use `/ship`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# GitHub Actions Security Checklist
|
|
2
|
+
|
|
3
|
+
> Apply to every workflow in `.github/workflows/`. Each item is checkable by reading the YAML — no runtime access needed. The `audit-actions` command automates the mechanical checks; this checklist is the human review layer.
|
|
4
|
+
|
|
5
|
+
## Permissions
|
|
6
|
+
|
|
7
|
+
- [ ] Workflow (or every job) declares explicit `permissions:` — never relies on the default token grant
|
|
8
|
+
- [ ] Default is `permissions: contents: read`; write scopes are added per-job only where provably needed
|
|
9
|
+
- [ ] No `permissions: write-all`
|
|
10
|
+
- [ ] Workflows triggered by `pull_request_target`, `issue_comment`, or `issues` do NOT get write tokens or secrets unless a maintainer-approval gate exists
|
|
11
|
+
|
|
12
|
+
## Untrusted input
|
|
13
|
+
|
|
14
|
+
- [ ] No direct interpolation of `github.event.*` text (issue/PR title, body, comment, branch name, commit message) inside `run:` shell — pass through `env:` and quote as `"$VAR"`
|
|
15
|
+
- [ ] Untrusted content passed to agents/LLMs is wrapped in a prompt boundary and stripped of tool-invocation-looking text
|
|
16
|
+
- [ ] `actions/checkout` of PR head refs in privileged contexts is treated as executing untrusted code
|
|
17
|
+
|
|
18
|
+
## Supply chain
|
|
19
|
+
|
|
20
|
+
- [ ] Third-party actions are pinned to a full commit SHA (tags are mutable); first-party `actions/*` at minimum pinned to a major version
|
|
21
|
+
- [ ] No `curl | bash` of unpinned remote scripts
|
|
22
|
+
- [ ] Artifacts downloaded from other workflows are treated as untrusted input
|
|
23
|
+
|
|
24
|
+
## Runaway control
|
|
25
|
+
|
|
26
|
+
- [ ] Every job has `timeout-minutes`
|
|
27
|
+
- [ ] Workflows that deploy or mutate state declare `concurrency:` with a stable group key
|
|
28
|
+
- [ ] Scheduled/agentic workflows have an explicit cost ceiling (matrix size, iteration cap)
|
|
29
|
+
|
|
30
|
+
## Agentic workflows
|
|
31
|
+
|
|
32
|
+
- [ ] Agent runs triggered by issue/PR/comment text run with read-only tokens
|
|
33
|
+
- [ ] A human approves before any agent-generated change is pushed or merged
|
|
34
|
+
- [ ] Prompt boundary and tool boundary are logged for each agent run
|
|
35
|
+
|
|
36
|
+
## Secrets
|
|
37
|
+
|
|
38
|
+
- [ ] Secrets are not exposed to workflows runnable by untrusted PRs
|
|
39
|
+
- [ ] No secrets echoed to logs or written to artifacts
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Experiment
|
|
2
|
+
|
|
3
|
+
> One file per experiment. Copy to `.experiments/<YYYY-MM-DD>-<slug>.md`. No experiment record = no claim of learning.
|
|
4
|
+
|
|
5
|
+
## Definition
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Experiment name | |
|
|
10
|
+
| Lane | trading / quran / workflow / infra |
|
|
11
|
+
| Repo | |
|
|
12
|
+
| Owner | |
|
|
13
|
+
| Feature flag (if any) | |
|
|
14
|
+
| Start date | |
|
|
15
|
+
| Stop date (hard stop — decide even if inconclusive) | |
|
|
16
|
+
|
|
17
|
+
## Hypothesis
|
|
18
|
+
|
|
19
|
+
State as: "If we [change], then [segment] will [measurable behavior], because [reasoning]."
|
|
20
|
+
|
|
21
|
+
## Metrics
|
|
22
|
+
|
|
23
|
+
- Primary metric (one only):
|
|
24
|
+
- Pass threshold (exact number):
|
|
25
|
+
- Guardrail metric (what must NOT get worse):
|
|
26
|
+
- Segment (who is measured):
|
|
27
|
+
|
|
28
|
+
## Result
|
|
29
|
+
|
|
30
|
+
Fill after stop date. Do not leave open past the stop date.
|
|
31
|
+
|
|
32
|
+
- Observed primary metric:
|
|
33
|
+
- Guardrail status:
|
|
34
|
+
- Evidence links (dashboards, exports, screenshots):
|
|
35
|
+
|
|
36
|
+
## Decision
|
|
37
|
+
|
|
38
|
+
One of: **ship** / **iterate** / **kill**. State the decision and the single next action.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/naimkatiman/continuous-improvement/main/templates/portfolio_event.schema.json",
|
|
4
|
+
"title": "PortfolioEvent",
|
|
5
|
+
"description": "Shared event schema for all repos in the portfolio. Every CI run, deploy, incident, experiment, agent action, security finding, release, decision, and metric snapshot is one event.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["eventId", "repo", "eventType", "occurredAt", "source"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"eventId": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Globally unique id (uuid or <repo>-<timestamp>-<n>)."
|
|
13
|
+
},
|
|
14
|
+
"repo": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "GitHub repo in owner/name form, e.g. naimkatiman/tradeclaw."
|
|
17
|
+
},
|
|
18
|
+
"eventType": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["ci", "deploy", "incident", "experiment", "agent", "security", "release", "decision", "metric"]
|
|
21
|
+
},
|
|
22
|
+
"occurredAt": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "date-time",
|
|
25
|
+
"description": "ISO 8601 UTC timestamp."
|
|
26
|
+
},
|
|
27
|
+
"source": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "What emitted the event: github-actions, wrangler, manual, agent:<name>, cron:<name>."
|
|
30
|
+
},
|
|
31
|
+
"actor": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Human or agent responsible, e.g. naimkatiman or agent:portfolio-health."
|
|
34
|
+
},
|
|
35
|
+
"status": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["success", "failure", "in_progress", "cancelled", "n/a"],
|
|
38
|
+
"description": "Outcome where applicable."
|
|
39
|
+
},
|
|
40
|
+
"severity": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": ["info", "low", "medium", "high", "critical"],
|
|
43
|
+
"description": "Required in practice for incident and security events."
|
|
44
|
+
},
|
|
45
|
+
"title": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "One-line human-readable summary."
|
|
48
|
+
},
|
|
49
|
+
"evidenceUrl": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "Link to the receipt: CI run, release receipt file, experiment file, dashboard."
|
|
52
|
+
},
|
|
53
|
+
"commitSha": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"metricName": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "For metric events: stable snake_case metric name."
|
|
59
|
+
},
|
|
60
|
+
"metricValue": {
|
|
61
|
+
"type": "number",
|
|
62
|
+
"description": "For metric events: numeric value."
|
|
63
|
+
},
|
|
64
|
+
"metadata": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"description": "Event-type-specific payload. Keep flat and JSON-serializable."
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Release Receipt
|
|
2
|
+
|
|
3
|
+
> One receipt per release/deploy. Copy this file to `.releases/<YYYY-MM-DD>-<version-or-slug>.md`, fill every field, commit it with the release. A release without a receipt did not happen.
|
|
4
|
+
|
|
5
|
+
## Identity
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Repo | |
|
|
10
|
+
| Version / tag | |
|
|
11
|
+
| Commit SHA | |
|
|
12
|
+
| Environment | production / staging / preview |
|
|
13
|
+
| Released at (UTC) | |
|
|
14
|
+
| Owner | |
|
|
15
|
+
|
|
16
|
+
## What shipped
|
|
17
|
+
|
|
18
|
+
- User-visible impact (one sentence, outcome not mechanism):
|
|
19
|
+
- Feature flags changed (name, old value, new value):
|
|
20
|
+
- Migrations run (file names, or "none"):
|
|
21
|
+
|
|
22
|
+
## Verification
|
|
23
|
+
|
|
24
|
+
- Tests run (exact commands + result):
|
|
25
|
+
- Security scans run (tool + result, or "none"):
|
|
26
|
+
- Manual verification performed:
|
|
27
|
+
|
|
28
|
+
## Risk
|
|
29
|
+
|
|
30
|
+
- Known risks accepted at release time:
|
|
31
|
+
- Rollback command (exact, copy-pasteable):
|
|
32
|
+
- Monitoring link (dashboard/logs to watch after release):
|
|
33
|
+
|
|
34
|
+
## Sign-off
|
|
35
|
+
|
|
36
|
+
- [ ] All fields above are filled (no blanks — use "none" explicitly)
|
|
37
|
+
- [ ] Rollback command was verified to exist (not just guessed)
|