@se-studio/skills 1.9.20 → 1.10.2
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/CHANGELOG.md +32 -0
- package/agent-guard/README.md +47 -0
- package/agent-guard/bin.mjs +34 -0
- package/agent-guard/claude-pretool.mjs +97 -0
- package/agent-guard/cli.mjs +37 -0
- package/agent-guard/merge-gate.mjs +181 -0
- package/agent-guard/rules.mjs +399 -0
- package/agent-guard/shell.mjs +168 -0
- package/agent-guard/worktrees-clean.mjs +273 -0
- package/package.json +5 -1
- package/references/agent-session/customer-agents-block.md +22 -3
- package/references/agent-session/customer-code-review.md +2 -2
- package/references/agent-session/customer-guardrails/README.md +23 -0
- package/references/agent-session/customer-guardrails/claude-settings.json +15 -0
- package/references/agent-session/customer-guardrails/merge-gate-audit.yml +50 -0
- package/references/agent-session/customer-guardrails/pre-commit +7 -0
- package/references/agent-session/customer-guardrails/pre-push +11 -0
- package/references/agent-session/projects.registry.json +1 -1
- package/skills/architecture-review/SKILL.md +69 -0
- package/skills/site-workflows-new-project/SKILL.md +1 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Remove worktrees and branches whose work has merged (AGENTS.md, "Parallel features").
|
|
4
|
+
* pnpm worktrees:clean dry run: list what is safe to remove and why the rest is kept
|
|
5
|
+
* pnpm worktrees:clean --apply remove safe worktrees and their local branches
|
|
6
|
+
* pnpm worktrees:clean --apply --remote also delete their remote branches
|
|
7
|
+
* --discard-ignored also remove worktrees whose only extras are unlisted ignored files
|
|
8
|
+
* --base <branch> integration branch (default: dev, else develop)
|
|
9
|
+
*
|
|
10
|
+
* Run from the primary checkout of any repo. A worktree is removed only when its work is
|
|
11
|
+
* provably merged, nothing is uncommitted (generated next-env.d.ts churn excepted) and nothing
|
|
12
|
+
* is unpushed. Anything with an open PR, unpushed commits or unmerged work is kept. Git-ignored files
|
|
13
|
+
* (`.env.local`, keys, notes) are not protected by `git worktree remove`, so a worktree holding any that
|
|
14
|
+
* are not known build output is kept unless you pass --discard-ignored after reading the dry run.
|
|
15
|
+
*/
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
|
|
20
|
+
/** Files that tooling rewrites on its own; changes to them are not work worth keeping. */
|
|
21
|
+
const GENERATED = new Set(['apps/example-empty/next-env.d.ts', 'next-env.d.ts']);
|
|
22
|
+
|
|
23
|
+
const isGenerated = (porcelainLine) => GENERATED.has(porcelainLine.slice(3).trim());
|
|
24
|
+
|
|
25
|
+
/** Ignored paths that are disposable build/install output. Anything else ignored may be work or a secret. */
|
|
26
|
+
const DISPOSABLE_IGNORED = [
|
|
27
|
+
/(^|\/)(node_modules|\.next|\.turbo|dist|\.vercel|coverage|\.cache)(\/|$)/,
|
|
28
|
+
/(^|\/)bin\/(ffmpeg|ffprobe)$/,
|
|
29
|
+
/^\.husky\/_\//,
|
|
30
|
+
/^apps\/example-empty\/public\/dotlottie\//,
|
|
31
|
+
/(^|\/)src\/generated(\/|$)/,
|
|
32
|
+
/^packages\/contentful-cms\/(src|skills)\//,
|
|
33
|
+
/\.tsbuildinfo$/,
|
|
34
|
+
/^\.(agents|claude|cursor|grok)\/(skills|references)(\/|$)/,
|
|
35
|
+
];
|
|
36
|
+
/** Names that suggest credentials or personal data, wherever they sit (even inside dist/ or .next/). */
|
|
37
|
+
const PRECIOUS_NAME =
|
|
38
|
+
/^(\.env(\..*)?|.*\.(key|pem|p12|pfx|keystore|secret|secrets)|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|credentials(\..*)?|\.npmrc|\.netrc)$/i;
|
|
39
|
+
export const preciousIgnored = (files) =>
|
|
40
|
+
files.filter((f) => PRECIOUS_NAME.test(f.split('/').pop()));
|
|
41
|
+
|
|
42
|
+
const isDisposable = (f) => DISPOSABLE_IGNORED.some((re) => re.test(f));
|
|
43
|
+
|
|
44
|
+
/** Collapsed `!! dir/` lines are judged by the files inside them (see `ignoredFiles`), not by the directory name. */
|
|
45
|
+
export const unlistedIgnored = (lines) =>
|
|
46
|
+
lines
|
|
47
|
+
.filter((l) => l.startsWith('!! '))
|
|
48
|
+
.map((l) => l.slice(3).trim())
|
|
49
|
+
.filter((f) => !f.endsWith('/') && !isDisposable(f));
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Pure decision. `info`:
|
|
53
|
+
* branch string | null (null = detached HEAD)
|
|
54
|
+
* status `git status --porcelain --ignored` lines, or null when git failed
|
|
55
|
+
* ignoredFiles every ignored file inside collapsed ignored dirs (node_modules excluded), or null when git failed
|
|
56
|
+
* base integration branch name the PR must have targeted
|
|
57
|
+
* unpushed commits on the branch that are on no remote ref (0 when pushed), or null when git failed
|
|
58
|
+
* tipInBase branch tip is an ancestor of origin/<base>
|
|
59
|
+
* remoteTip origin/<branch> sha or null
|
|
60
|
+
* localTip sha
|
|
61
|
+
* prs [{ state: 'OPEN'|'MERGED'|'CLOSED', headRefOid, baseRefName }]
|
|
62
|
+
* @returns {{ action: 'remove' | 'keep', reason: string, force: boolean }}
|
|
63
|
+
*/
|
|
64
|
+
export function classifyWorktree(info, { discardIgnored = false } = {}) {
|
|
65
|
+
const keep = (reason) => ({ action: 'keep', reason, force: false });
|
|
66
|
+
const mergedPrs = (info.prs ?? []).filter(
|
|
67
|
+
(p) => p.state === 'MERGED' && p.baseRefName === info.base,
|
|
68
|
+
);
|
|
69
|
+
if ((info.prs ?? []).some((p) => p.state === 'OPEN')) return keep('open PR');
|
|
70
|
+
if (info.status == null) return keep('could not read git status');
|
|
71
|
+
const dirty = info.status.filter((l) => !l.startsWith('!! '));
|
|
72
|
+
const realDirty = dirty.filter((l) => !isGenerated(l));
|
|
73
|
+
if (realDirty.length > 0) return keep(`uncommitted changes (${realDirty.length})`);
|
|
74
|
+
if (info.ignoredFiles == null) return keep('could not list ignored files');
|
|
75
|
+
const risky = [
|
|
76
|
+
...new Set([
|
|
77
|
+
...unlistedIgnored(info.status),
|
|
78
|
+
...info.ignoredFiles.filter((f) => !isDisposable(f)),
|
|
79
|
+
...preciousIgnored(info.ignoredFiles),
|
|
80
|
+
]),
|
|
81
|
+
];
|
|
82
|
+
if (risky.length > 0 && !discardIgnored) {
|
|
83
|
+
return keep(
|
|
84
|
+
`git-ignored files would be lost: ${risky.slice(0, 3).join(', ')}${risky.length > 3 ? ', …' : ''} (--discard-ignored to override)`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (info.branch && info.unpushed == null) return keep('could not count unpushed commits');
|
|
88
|
+
if (info.branch && info.unpushed > 0) return keep(`${info.unpushed} unpushed commit(s)`);
|
|
89
|
+
|
|
90
|
+
// A merged PR into the base whose head is the remote tip (or ours) proves a squash/merge happened even
|
|
91
|
+
// when the branch tip is not an ancestor of the base; a local branch merely behind that tip has nothing to lose.
|
|
92
|
+
const mergedPrHead = mergedPrs.some(
|
|
93
|
+
(p) => p.headRefOid === info.remoteTip || p.headRefOid === info.localTip,
|
|
94
|
+
);
|
|
95
|
+
// Ancestry alone is not proof: a brand-new branch with no commits yet is also "in" the base.
|
|
96
|
+
if (mergedPrs.length === 0)
|
|
97
|
+
return keep(`no merged PR into ${info.base} (cannot prove the work merged)`);
|
|
98
|
+
if (!info.tipInBase && !mergedPrHead)
|
|
99
|
+
return keep('PR merged but this branch has commits beyond the merged head');
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
action: 'remove',
|
|
103
|
+
reason: info.tipInBase ? 'merged into base' : 'merged PR head',
|
|
104
|
+
force: dirty.length > 0, // only generated tracked files are modified; ignored files never need --force
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function run(cwd, cmd, args) {
|
|
109
|
+
// trimEnd only: `git status --porcelain` lines start with a significant space (" M file").
|
|
110
|
+
// A built .next or dist can list hundreds of thousands of ignored files; Node's 1 MB default would
|
|
111
|
+
// make the listing fail and the tool keep every such worktree.
|
|
112
|
+
return execFileSync(cmd, args, {
|
|
113
|
+
cwd,
|
|
114
|
+
encoding: 'utf8',
|
|
115
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
116
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
117
|
+
}).trimEnd();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function tryRun(cwd, cmd, args) {
|
|
121
|
+
try {
|
|
122
|
+
return run(cwd, cmd, args);
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function listWorktrees(repo) {
|
|
129
|
+
const out = run(repo, 'git', ['worktree', 'list', '--porcelain']);
|
|
130
|
+
const trees = [];
|
|
131
|
+
let cur = null;
|
|
132
|
+
for (const line of out.split('\n')) {
|
|
133
|
+
if (line.startsWith('worktree ')) {
|
|
134
|
+
cur = { path: line.slice(9), branch: null };
|
|
135
|
+
trees.push(cur);
|
|
136
|
+
} else if (line.startsWith('branch ')) {
|
|
137
|
+
cur.branch = line.slice(7).replace('refs/heads/', '');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return trees.slice(1); // the first entry is the primary checkout
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function ghPrs(repo, branch) {
|
|
144
|
+
const out = tryRun(repo, 'gh', [
|
|
145
|
+
'pr',
|
|
146
|
+
'list',
|
|
147
|
+
'--state',
|
|
148
|
+
'all',
|
|
149
|
+
'--head',
|
|
150
|
+
branch,
|
|
151
|
+
'--json',
|
|
152
|
+
'state,headRefOid,baseRefName',
|
|
153
|
+
]);
|
|
154
|
+
return out ? JSON.parse(out) : [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Gather facts for one worktree. `prsFor` is injectable so tests need no network. */
|
|
158
|
+
export function inspectWorktree(repo, wt, { base, prsFor = ghPrs }) {
|
|
159
|
+
const sh = (args, cwd = repo) => tryRun(cwd, 'git', args);
|
|
160
|
+
const localTip = sh(['rev-parse', 'HEAD'], wt.path);
|
|
161
|
+
const remoteTip = wt.branch
|
|
162
|
+
? sh(['rev-parse', '-q', '--verify', `refs/remotes/origin/${wt.branch}`])
|
|
163
|
+
: null;
|
|
164
|
+
const statusOut = sh(['status', '--porcelain', '--ignored'], wt.path);
|
|
165
|
+
let unpushed = 0;
|
|
166
|
+
if (wt.branch) {
|
|
167
|
+
const local = `refs/heads/${wt.branch}`;
|
|
168
|
+
const count = remoteTip
|
|
169
|
+
? sh(['rev-list', '--count', `${remoteTip}..${local}`])
|
|
170
|
+
: sh(['rev-list', '--count', local, '--not', '--remotes']);
|
|
171
|
+
unpushed = count === null ? null : Number(count);
|
|
172
|
+
}
|
|
173
|
+
// git collapses an ignored directory to one `!! dir/` line, hiding what is inside it.
|
|
174
|
+
const ignoredOut = sh(
|
|
175
|
+
[
|
|
176
|
+
'ls-files',
|
|
177
|
+
'-z',
|
|
178
|
+
'--others',
|
|
179
|
+
'--ignored',
|
|
180
|
+
'--exclude-standard',
|
|
181
|
+
'--',
|
|
182
|
+
'.',
|
|
183
|
+
':(exclude)node_modules',
|
|
184
|
+
':(exclude,glob)**/node_modules/**',
|
|
185
|
+
],
|
|
186
|
+
wt.path,
|
|
187
|
+
);
|
|
188
|
+
const tipInBase =
|
|
189
|
+
localTip !== null && sh(['merge-base', '--is-ancestor', localTip, `origin/${base}`]) !== null;
|
|
190
|
+
return {
|
|
191
|
+
name: path.basename(wt.path),
|
|
192
|
+
path: wt.path,
|
|
193
|
+
branch: wt.branch,
|
|
194
|
+
base,
|
|
195
|
+
status: statusOut === null ? null : statusOut.split('\n').filter(Boolean),
|
|
196
|
+
ignoredFiles: ignoredOut === null ? null : ignoredOut.split('\0').filter(Boolean),
|
|
197
|
+
unpushed,
|
|
198
|
+
tipInBase,
|
|
199
|
+
remoteTip,
|
|
200
|
+
localTip,
|
|
201
|
+
prs: wt.branch ? prsFor(repo, wt.branch) : [],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function clean(
|
|
206
|
+
repo,
|
|
207
|
+
{ apply = false, remote = false, discardIgnored = false, base, prsFor } = {},
|
|
208
|
+
) {
|
|
209
|
+
const gitDir = tryRun(repo, 'git', ['rev-parse', '--absolute-git-dir']);
|
|
210
|
+
const common = tryRun(repo, 'git', ['rev-parse', '--path-format=absolute', '--git-common-dir']);
|
|
211
|
+
if (gitDir !== common)
|
|
212
|
+
throw new Error(
|
|
213
|
+
'Run worktrees:clean from the primary checkout, not from inside a linked worktree.',
|
|
214
|
+
);
|
|
215
|
+
if (tryRun(repo, 'git', ['fetch', '-q', '--prune', 'origin']) === null) {
|
|
216
|
+
throw new Error('git fetch failed; refusing to judge merge state from stale remote refs.');
|
|
217
|
+
}
|
|
218
|
+
const baseBranch =
|
|
219
|
+
base ??
|
|
220
|
+
(tryRun(repo, 'git', ['rev-parse', '-q', '--verify', 'refs/remotes/origin/dev'])
|
|
221
|
+
? 'dev'
|
|
222
|
+
: 'develop');
|
|
223
|
+
const results = [];
|
|
224
|
+
for (const wt of listWorktrees(repo)) {
|
|
225
|
+
const info = inspectWorktree(repo, wt, { base: baseBranch, prsFor });
|
|
226
|
+
const verdict = classifyWorktree(info, { discardIgnored });
|
|
227
|
+
const result = { ...info, ...verdict, removed: false };
|
|
228
|
+
if (apply && verdict.action === 'remove') {
|
|
229
|
+
try {
|
|
230
|
+
run(repo, 'git', ['worktree', 'remove', ...(verdict.force ? ['--force'] : []), info.path]);
|
|
231
|
+
if (info.branch) {
|
|
232
|
+
tryRun(repo, 'git', ['branch', '-D', info.branch]);
|
|
233
|
+
if (remote && info.remoteTip) {
|
|
234
|
+
// Fails if someone pushed to the branch since we looked.
|
|
235
|
+
tryRun(repo, 'git', [
|
|
236
|
+
'push',
|
|
237
|
+
`--force-with-lease=${info.branch}:${info.remoteTip}`,
|
|
238
|
+
'origin',
|
|
239
|
+
`:refs/heads/${info.branch}`,
|
|
240
|
+
]);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
result.removed = true;
|
|
244
|
+
} catch (err) {
|
|
245
|
+
result.action = 'keep';
|
|
246
|
+
result.reason = `could not remove: ${String(err.stderr ?? err.message).split('\n')[0]}`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
results.push(result);
|
|
250
|
+
}
|
|
251
|
+
tryRun(repo, 'git', ['worktree', 'prune']);
|
|
252
|
+
return results;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function main() {
|
|
256
|
+
const argv = process.argv.slice(2);
|
|
257
|
+
const baseIdx = argv.indexOf('--base');
|
|
258
|
+
const results = clean(process.cwd(), {
|
|
259
|
+
apply: argv.includes('--apply'),
|
|
260
|
+
remote: argv.includes('--remote'),
|
|
261
|
+
discardIgnored: argv.includes('--discard-ignored'),
|
|
262
|
+
base: baseIdx >= 0 ? argv[baseIdx + 1] : undefined,
|
|
263
|
+
});
|
|
264
|
+
for (const r of results) {
|
|
265
|
+
const mark = r.removed ? 'removed' : r.action === 'remove' ? 'would remove' : 'keep';
|
|
266
|
+
console.log(`${mark.padEnd(12)} ${r.name} (${r.branch ?? 'detached'}): ${r.reason}`);
|
|
267
|
+
}
|
|
268
|
+
if (!argv.includes('--apply') && results.some((r) => r.action === 'remove')) {
|
|
269
|
+
console.log('\nDry run. Re-run with --apply (and --remote for remote branches).');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/skills",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "SE Studio agent skills for marketing site development with Contentful CMS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
"directory": "packages/skills"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"bin": {
|
|
12
|
+
"se-agent-guard": "agent-guard/bin.mjs"
|
|
13
|
+
},
|
|
11
14
|
"files": [
|
|
15
|
+
"agent-guard",
|
|
12
16
|
"skills",
|
|
13
17
|
"references",
|
|
14
18
|
"*.md"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
<!-- BEGIN:se-core-agents-block v2 -->
|
|
1
2
|
## Next.js docs (version-matched)
|
|
2
3
|
|
|
3
|
-
This site runs **Next.js 16.
|
|
4
|
+
This site runs **Next.js 16** (the minor is in `package.json`). Before writing Next.js code, read the relevant guide in `node_modules/next/dist/docs/` (in monorepos, resolve from the app that depends on `next`). Keep the managed `<!-- BEGIN:nextjs-agent-rules -->` block in `AGENTS.md`. Do **not** use `npx @next/codemod agents-md`, `.next-docs`, or `NEXT-AGENTS-MD-START` (Next 15 index: Pages Router, `middleware.ts`). Ignore `vercel-react-native-skills` if the vercel-labs pack installed it.
|
|
4
5
|
|
|
5
6
|
After `pnpm skills:sync`, strip `AGENTS.md` / `CLAUDE.md` that sit next to a skill `SKILL.md`. Cursor always-applies those filenames; Vercel packs must stay on-demand.
|
|
6
7
|
|
|
@@ -17,7 +18,7 @@ Default mode for this repo: **site-first**.
|
|
|
17
18
|
### Branch policy
|
|
18
19
|
|
|
19
20
|
- Agents may commit and push **`develop`** and **`feature/*`**.
|
|
20
|
-
- Merge feature → `develop` only
|
|
21
|
+
- Merge feature → `develop` only after Nick says go **in chat** (no `nick-go` GitHub label) **and** the PR passes the merge gate (see "Review and merge"). Merge commits only, never squash or rebase.
|
|
21
22
|
- Customer production (`main`, HSD `production`) **only** after the human-ask + confirm gate (`production-merge.md` in `@se-studio/skills`). The human must ask to merge integration → production in this conversation; the agent must restate site, branches, and that it publishes production; then wait for a second **yes**.
|
|
22
23
|
- **Never** treat “deploy”, “ship it”, or “rollout” as permission. **Never** ship from a production checkout (e.g. HSD `production-hsd-website`). Use the develop checkout only. se-core-product `dev` → `main` (npm promote) is ask + confirm in a **core** session — do not promote core from this customer session.
|
|
23
24
|
- Prefer **draft PRs** to `develop` over direct pushes when `gh` is available.
|
|
@@ -69,16 +70,32 @@ Non-UI changes skip visual gates and go to code review.
|
|
|
69
70
|
|
|
70
71
|
Before asking to merge to `develop`, run the review in `CODE_REVIEW.md` and stop. Findings: **BLOCKER** / **NIT**. Do not keep a second checklist in `AGENTS.md`. That file only points at `CODE_REVIEW.md`.
|
|
71
72
|
|
|
73
|
+
A change to placement, schema, caching, analytics or forms also needs a design review by someone who did not write it. Use skill `architecture-review` (post `## Design review` on the PR: PASS / BLOCKERS / N/A).
|
|
74
|
+
|
|
75
|
+
### Review and merge
|
|
76
|
+
|
|
77
|
+
1. **Review.** A real review (an agent or a human) is posted as a PR comment under a heading that says "review", names the **current head SHA**, and gives a verdict (PASS, BLOCKERS, NITs, LGTM or approved). Push a new commit and the old review no longer counts: review again, reading only the delta.
|
|
78
|
+
2. **Approve.** Nick's go in chat is the approval. The agent records it as a PR comment headed `## Merge approval`: who, where, when (Europe/London), the head SHA, and a link to the review comment (`#issuecomment-N` on this PR). Post the review before the approval. Never merge a PR marked **do not merge**.
|
|
79
|
+
3. **Check.** `pnpm exec se-agent-guard merge-gate <number>` runs the same gate the Claude hook and the post-merge audit use. Run it before merging; fix what it names.
|
|
80
|
+
4. **Merge.** `gh pr merge <number> --merge --match-head-commit <approved head sha>`. Merge commits only: never `--squash` or `--rebase`. To undo a merge, `git revert -m 1 <merge commit>`. A merge that skipped the gate is labelled `pushed-through` and reviewed after the fact.
|
|
81
|
+
5. **Clean up** (see "Parallel features").
|
|
82
|
+
|
|
83
|
+
Production merges (integration → `main`/`production`) also need a review and a `## Merge approval`, on top of ask + confirm (`production-merge.md`).
|
|
84
|
+
|
|
85
|
+
The guard (git hooks, Claude hook, audit workflow) comes from `@se-studio/skills` (`se-agent-guard`), pinned in this repo's lockfile. **Precondition:** `@se-studio/skills` is an exact-version devDependency and `pnpm install` has run (see `customer-guardrails/README.md`); until then these commands do not exist. Do not copy its scripts into the repo and do not bypass it (`--no-verify`, `core.hooksPath`). Fix the failing check instead.
|
|
86
|
+
|
|
72
87
|
### Parallel features
|
|
73
88
|
|
|
74
89
|
- One feature = one `feature/<scope>/<slug>` branch
|
|
75
|
-
- **Local git worktree** for feature work — do not implement on the primary `develop` checkout
|
|
90
|
+
- **Local git worktree** for feature work — do not implement on the primary `develop` checkout. A primary checkout is for `git fetch` and dependencies only
|
|
76
91
|
- Path: registry `worktreesRoot` / `<feature-slug>` (see se-core-product `packages/skills/references/agent-session/projects.registry.json`)
|
|
77
92
|
- Create: `git worktree add <worktreesRoot>/<feature-slug> -b feature/<scope>/<slug> origin/develop`
|
|
78
93
|
- Then seed env: `pnpm --dir ~/source/se/se-core-product local-env seed --project <key>` (no-clobber copy of `.env.local`; never invent a stub or symlink at develop)
|
|
79
94
|
- Opt out only if the user says “work in place” / “no worktree”
|
|
80
95
|
- **Cloud agents:** draft PR to `develop` (that is the ledger; do not write yaml in se-core-product)
|
|
81
96
|
- CMS edits: `--session <feature-slug>` (isolate cms-edit sessions)
|
|
97
|
+
- **Never audit, compare or branch from a primary checkout**: it is often behind or dirty. `git fetch`, then read `origin/develop`, or work in a fresh worktree at `origin/develop`.
|
|
98
|
+
- **Clean up once merged.** Remove the worktree, the local branch and the remote branch (the repo deletes the remote branch on merge). Do not leave stale worktrees. From the primary checkout run `pnpm exec se-agent-guard worktrees-clean` (a dry run that says what is safe to remove and why the rest is kept), then add `--apply --remote`. It only removes a worktree whose PR merged into `develop` and which has nothing uncommitted, unpushed or git-ignored-but-precious (`.env.local`, keys).
|
|
82
99
|
- In-flight work: open PRs + local `git worktree list`
|
|
83
100
|
|
|
84
101
|
### Process feedback
|
|
@@ -90,3 +107,5 @@ Site-local learnings: `docs/AGENT_PROCESS_NOTES.md`. Say **“promote process no
|
|
|
90
107
|
When **marketing** work is ready, agents **stop** and hand off. Merge `develop` → production only after ask + confirm (`production-merge.md`). One site at a time. No `vercel deploy`. cms-edit host extra gate: `cms-edit-prod-merge.md`.
|
|
91
108
|
|
|
92
109
|
When the promote depends on new/changed Contentful content, complete **release verification** (`release-verification.md` in `@se-studio/skills`): publish state (CDA vs CPA), content smoke (not HTTP-only), preview compare (≥3 pages on published-only build), and no unresolved failed production build. Nick override never skips publish-state or content smoke.
|
|
110
|
+
|
|
111
|
+
<!-- END:se-core-agents-block v2 -->
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use this prompt when reviewing a **customer marketing site** PR (or when the user asks for a code review). Label every finding **BLOCKER** or **NIT**. Blockers first. Unclear judgement calls → flag to Nick in chat.
|
|
4
4
|
|
|
5
|
-
Do **not** use Bugbot or a `nick-go` GitHub label. Merge to `develop` only when Nick says so in chat, a review covers the current head SHA, and the PR has a `## Merge approval` comment. Production still needs ask + confirm (`production-merge.md`).
|
|
5
|
+
Do **not** use Bugbot or a `nick-go` GitHub label. Merge to `develop` only when Nick says so in chat, a review (agent or human) covers the current head SHA, and the PR has a `## Merge approval` comment (see `AGENTS.md`, "Review and merge"). Merge commits only. Production still needs ask + confirm (`production-merge.md`).
|
|
6
6
|
|
|
7
7
|
Canonical architecture: `se-core-product` `docs/PHILOSOPHY.md`. Placement and handoffs: skill `site-workflows-agent-session`.
|
|
8
8
|
|
|
@@ -60,7 +60,7 @@ Run a lens only when the diff can touch it.
|
|
|
60
60
|
- Forms: preview posting to production CRM/forms destinations or GTM, or bypassing server-side submit.
|
|
61
61
|
- Hard-coded heading skips, `Visual` without size helpers, or needless duplicate mobile/desktop content.
|
|
62
62
|
- A new `src/app/**/page.tsx` for a marketing URL. That URL is a Contentful slug (often `indexed: false` for an experiment). Allowed app pages: the CMS catch-all, an article type or person type named in `src/lib/marketing-routes.json`, and the fixed misc set (page-test, preview, sitemap, robots, markdown, download, og, api, cms-dev).
|
|
63
|
-
- Arbitrary layout standing in for the grid or an unspecified text style: `max-w-[
|
|
63
|
+
- Arbitrary layout standing in for the grid or an unspecified text style (R5.13): a Fixed Figma width copied as `max-w-[…]`, `w-[…px]` on a grid item (a direct child of a section grid), or `max-w-cols-N` (including `max-w-[1440px]` and `max-w-[1920px]`); `w-cols-N` on a grid item (a `max-w-cols-N` cap that is the block's intended maximum, not the node's width, is fine, with or without `col-span`); the horizontal width or offset of a grid item within 8px of a column span or offset that is not built with `col-start` / `col-span` or a `grid-cols-subgrid` wrapper, including any horizontal offset faked with padding, margin, transform, position or a wrapper (`pl-[37px]`, `translate-x-[…]`), compared at the width of the node's Figma frame; one further than 8px off the grid with no cited override (an explicit approval comment from anyone, the author included, that names the node and gives the reason, linked in the PR or given in a code comment at the node, or a Figma annotation on the node or its frame saying it is intentionally off grid, quoted with the node id; take the citation on trust and flag it if absent; `se-exception:` on the layout lint is not a substitute); `leading-[…]` / `text-[32px]` with no `fontTable` class; section padding via `py-[…]` instead of `<Section>`; a nested `content-cols-grid`. A repo may override the snap-and-refusal part of R5.13 in its AGENTS.md, recorded as a deviation (code comment plus README "Deviations" entry); check the override on the base branch, not the PR head, and apply the rest of R5.13 regardless. Name the Figma node in the plan and wait. Do not guess a style and do not paste MCP classes.
|
|
64
64
|
- Failing typecheck, lint, or tests; new behaviour with no test where the site already tests that layer.
|
|
65
65
|
- Smoke/discovery/`server-config` hacks to unblock deploy smoke (belongs in `@se-studio/site-check`).
|
|
66
66
|
- **Remake / port simplicity** (PHILOSOPHY §5a / skill `se-marketing-sites-customer-simplicity`):
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Customer guardrail files (v1)
|
|
2
|
+
|
|
3
|
+
Four thin files a customer repo copies once. They only call the pinned `se-agent-guard` bin from `@se-studio/skills`, so the behaviour is versioned by the lockfile and cannot drift. A check that a repo still has them (`se-agent-guard check`, and a fleet-wide run from core) is planned and not shipped yet.
|
|
4
|
+
|
|
5
|
+
| Copy | To | Purpose |
|
|
6
|
+
|------|----|---------|
|
|
7
|
+
| `pre-commit` | `.githooks/pre-commit` or `.husky/pre-commit` | refuse commits on `main`/`develop`/`production`; then the repo's own staged checks |
|
|
8
|
+
| `pre-push` | `.githooks/pre-push` or `.husky/pre-push` | refuse pushes to `main`/`production`; type-check non-delete pushes |
|
|
9
|
+
| `claude-settings.json` | `.claude/settings.json` | Claude Code pre-tool guard (denies `vercel deploy`, `--no-verify`, ungated `gh pr merge`, and so on) |
|
|
10
|
+
| `merge-gate-audit.yml` | `.github/workflows/merge-gate-audit.yml` | labels `pushed-through` when a merge skipped the approval |
|
|
11
|
+
|
|
12
|
+
Requirements:
|
|
13
|
+
|
|
14
|
+
- `@se-studio/skills` is a `devDependency` with an **exact** version (the audit reads it from `package.json`).
|
|
15
|
+
- `package.json` sets `packageManager` (`pnpm/action-setup@v6` in the audit reads it; there is no `version:` input).
|
|
16
|
+
- The hooks directory is installed by `prepare` (`git config core.hooksPath .githooks` or husky). A failing `prepare` must not be silenced with `|| true`.
|
|
17
|
+
- `.claude/settings.json` must contain no tokens, and no allowlisted URL with an `access_token`.
|
|
18
|
+
- The repo's `validate` script is what CI runs (`pnpm validate`), not a hand-picked subset.
|
|
19
|
+
- Run `pnpm install` in every worktree. The git hooks fail closed without it (the commit is refused). The Claude hook cannot: Claude Code only blocks a tool call on exit code 2, so with no `node_modules` it fails open. The git hooks are the enforcement; the Claude hook is advice earlier.
|
|
20
|
+
- The `pre-push` template runs `pnpm run type-check`: the repo needs that script (or edit the line).
|
|
21
|
+
- Repo setting: merge commits only, squash and rebase off, delete branch on merge on.
|
|
22
|
+
|
|
23
|
+
Cursor and Grok have no pre-tool adapter yet. They are covered by the git hooks and the audit.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Bash|Edit|Write|NotebookEdit",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/node_modules/@se-studio/skills/agent-guard/claude-pretool.mjs\""
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Merge gate audit
|
|
2
|
+
|
|
3
|
+
# se-core guardrails v1. GitHub cannot make "## Merge approval" a required check on our plan,
|
|
4
|
+
# so this runs after every merge and labels + comments `pushed-through` on a breach
|
|
5
|
+
# (AGENTS.md, "Review and merge"). It runs the gate from the pinned @se-studio/skills.
|
|
6
|
+
#
|
|
7
|
+
# pull_request_target runs this file from the base branch and never checks out PR code,
|
|
8
|
+
# so a PR cannot change what runs here.
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
pull_request_target:
|
|
12
|
+
types: [closed]
|
|
13
|
+
branches:
|
|
14
|
+
- develop
|
|
15
|
+
- main
|
|
16
|
+
- production
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
issues: write # create/apply the pushed-through label
|
|
21
|
+
pull-requests: write # comment on the PR
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
audit:
|
|
25
|
+
name: Audit merge approval
|
|
26
|
+
if: github.event.pull_request.merged == true
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v6
|
|
30
|
+
with:
|
|
31
|
+
sparse-checkout: package.json
|
|
32
|
+
sparse-checkout-cone-mode: false
|
|
33
|
+
# No `version:`: the action reads `packageManager` from package.json (a second source conflicts).
|
|
34
|
+
- uses: pnpm/action-setup@v6
|
|
35
|
+
- uses: actions/setup-node@v6
|
|
36
|
+
with:
|
|
37
|
+
node-version: 24
|
|
38
|
+
- name: Check approval comment at head SHA
|
|
39
|
+
env:
|
|
40
|
+
GH_TOKEN: ${{ github.token }}
|
|
41
|
+
GH_REPO: ${{ github.repository }}
|
|
42
|
+
run: |
|
|
43
|
+
version=$(node -p "const p = require('./package.json'); (p.devDependencies ?? {})['@se-studio/skills'] ?? (p.dependencies ?? {})['@se-studio/skills'] ?? ''")
|
|
44
|
+
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
|
|
45
|
+
echo "@se-studio/skills must be an exact version in package.json (found: '$version')"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
# minimumReleaseAge=0: the sparse checkout does not see pnpm-workspace.yaml (which excludes
|
|
49
|
+
# @se-studio/*), and the exact pin above is what makes a fresh release safe to run.
|
|
50
|
+
pnpm dlx --config.minimumReleaseAge=0 "@se-studio/skills@${version}" merge-gate "${{ github.event.pull_request.number }}" --audit
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# se-core guardrails v1: copy to .githooks/pre-commit (or .husky/pre-commit).
|
|
3
|
+
# The guard comes from the pinned @se-studio/skills; do not copy its scripts into the repo.
|
|
4
|
+
set -e
|
|
5
|
+
pnpm exec se-agent-guard commit
|
|
6
|
+
# Then this repo's own staged-file checks, e.g.:
|
|
7
|
+
pnpm exec lint-staged
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# se-core guardrails v1: copy to .githooks/pre-push (or .husky/pre-push).
|
|
3
|
+
set -e
|
|
4
|
+
# Read the ref lines once: git pipes them on stdin and the guard needs them too.
|
|
5
|
+
refs=$(cat)
|
|
6
|
+
printf '%s\n' "$refs" | pnpm exec se-agent-guard push
|
|
7
|
+
# A push that only deletes branches carries no code to type-check.
|
|
8
|
+
if [ -n "$refs" ] && ! printf '%s\n' "$refs" | awk '$2 !~ /^0+$/ { found = 1 } END { exit !found }'; then
|
|
9
|
+
exit 0
|
|
10
|
+
fi
|
|
11
|
+
pnpm run type-check
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"key": "eagle",
|
|
120
120
|
"displayName": "Eagle Website",
|
|
121
121
|
"path": "~/source/customers/eaglecap/eagle-website",
|
|
122
|
-
"worktreesRoot": "~/source/customers/
|
|
122
|
+
"worktreesRoot": "~/source/customers/eaglecap/worktrees",
|
|
123
123
|
"branch": "develop",
|
|
124
124
|
"productionBranch": "main",
|
|
125
125
|
"type": "customer",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-review
|
|
3
|
+
description: "Review a PR against docs/PHILOSOPHY.md (placement, schema, rendering, caching, analytics/forms) and post a ## Design review with PASS / BLOCKERS / N/A. Use for 'design review', 'architecture review', 'review against the philosophy', or before merging a PR that docs/design-review.md says needs one. Any agent or human can run it; the author cannot review their own design."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architecture review
|
|
7
|
+
|
|
8
|
+
Check a change against the numbered rules in `docs/PHILOSOPHY.md` and report on the PR. This is the design half of the review in `AGENTS.md` ("Review before merge"). It is not the code review (`CODE_REVIEW_PROMPT.md`); post it separately or as a clearly headed section of the same comment.
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
This skill reviews a **PR** at a head SHA. For a proposal that has no PR yet (the "before it is built" half of R9.2), apply sections 3 and 4 to the written proposal, report in chat or on the issue with `Head SHA: n/a (proposal)`, and repeat on the PR once it exists.
|
|
13
|
+
|
|
14
|
+
## Who
|
|
15
|
+
|
|
16
|
+
Any agent or human who did **not** write the change. Check the PR author, the commits' `Co-Authored-By` trailers and the branch history. A fresh session cannot tell whether an earlier session of the same agent wrote it, so if you are unsure, ask.
|
|
17
|
+
|
|
18
|
+
## 1. Decide if it applies
|
|
19
|
+
|
|
20
|
+
Read `docs/design-review.md`. A review is needed when the PR adds or changes a mechanism, shared package behaviour, analytics / consent / forms, Contentful fetch / cache tags / revalidation, schema, placement, or package boundaries. Trivial tooling with no visitor- or editor-visible effect and no architecture surface: post the template in step 5 with `Verdict: N/A` and the reason, and stop.
|
|
21
|
+
|
|
22
|
+
## 2. Gather (from origin, not a stale checkout)
|
|
23
|
+
|
|
24
|
+
- `git fetch`, then review `origin/<head>` against `origin/<base>` (or `gh pr diff <n>`). Local primary checkouts are not a source of truth.
|
|
25
|
+
- Read the PR description, the diff, and the head SHA you are reviewing.
|
|
26
|
+
- Read `docs/PHILOSOPHY.md`. Do not rely on memory of it; the rules change by PR.
|
|
27
|
+
|
|
28
|
+
## 3. Check each affected area
|
|
29
|
+
|
|
30
|
+
Map the diff to the sections and ask only the questions that apply. Each range includes its lettered and `.0` variants (R2.1a, R3.0, R4.0, R4.5a, R6.0). Cite the rule number for every finding.
|
|
31
|
+
|
|
32
|
+
| Area | Rules | Core question |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Placement | R2.1 to R2.7 | Does a second site need this? Is a customer workaround, patch or fork hiding a core bug (R2.1b, R2.3, R2.5)? Is an extension point generic, not per-customer (R2.6)? Does the PR say which live sites it affects (R2.7)? |
|
|
35
|
+
| Site shape | R3.1 to R3.7 | Does it stay inside the T0/T1 tiers, with deviations commented and recorded (R3.6)? |
|
|
36
|
+
| Schema | R4.0 to R4.8 | Is it a numbered, idempotent migration (R4.5, R4.5a), in core first (R4.7), with a distinct type per different UI (R4.2a)? |
|
|
37
|
+
| Rendering | R5.1 to R5.28 | Four layers, server/client boundary, no catalogue fetch in a component (R5.23), fail closed (R5.21), no RTF flattening (R5.19), no invented links or copy (R5.20). |
|
|
38
|
+
| Data and caching | R6.1 to R6.8 | Fetch only through the sanctioned layer, core tag helpers, tag-only revalidation, routes stay static, memoisation carries tags. |
|
|
39
|
+
| Analytics, consent, forms | R7.1 to R7.8 | Goes through the consent-aware adapter, no non-essential load before consent, preview never posts to production destinations. |
|
|
40
|
+
| Change control | R9.1 to R9.5; section 8 for tests, changeset and env vars | No manual deploy; production merges follow the ask-then-confirm gate. |
|
|
41
|
+
|
|
42
|
+
Also ask what the rules do not cover: a new mechanism with no rule, two rules that pull opposite ways, or a judgement call. **Do not decide these yourself.** List them under "For Nick" (R9.5).
|
|
43
|
+
|
|
44
|
+
## 4. Measure, do not assert
|
|
45
|
+
|
|
46
|
+
Where a rule turns on a fact, get the fact: the build output marker for a route (`●` vs `ƒ`), the tag a fetch carries, the grep that shows a catalogue fetch inside a component. If you suspect a rule break but cannot prove it, do not downgrade it silently: list it under "For Nick".
|
|
47
|
+
|
|
48
|
+
## 5. Report it
|
|
49
|
+
|
|
50
|
+
Post on the PR only when asked to (or when the caller told you to post): `gh pr comment <n> --body-file <file>`, as its own comment or a headed section of the code review. Otherwise return the same text. The merge gate needs a review that names the head SHA, so always include it.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
## Design review
|
|
54
|
+
|
|
55
|
+
Head SHA: <full sha>
|
|
56
|
+
Scope: <what changed, one line>
|
|
57
|
+
Verdict: PASS | BLOCKERS | N/A
|
|
58
|
+
|
|
59
|
+
### BLOCKERS
|
|
60
|
+
- R<n.n> <file:line> <what breaks the rule, and the evidence>
|
|
61
|
+
|
|
62
|
+
### NITs
|
|
63
|
+
- ...
|
|
64
|
+
|
|
65
|
+
### For Nick
|
|
66
|
+
- <anything the rules do not settle>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
A rule break is a BLOCKER (R9.4, R9.5). A later review reads only the delta since the reviewed SHA, as in `CODE_REVIEW_PROMPT.md`. The `## Merge approval` comment cites the code review; the design review sits alongside it.
|
|
@@ -110,6 +110,7 @@ Also copy:
|
|
|
110
110
|
| [`customer-architecture.mdc`](../../references/agent-session/customer-architecture.mdc) | `.cursor/rules/architecture.mdc` |
|
|
111
111
|
| [`customer-code-review.md`](../../references/agent-session/customer-code-review.md) | `CODE_REVIEW.md` (repo root) |
|
|
112
112
|
| Starter notes | `docs/AGENT_PROCESS_NOTES.md` (see [`process-feedback.md`](../../references/agent-session/process-feedback.md)) |
|
|
113
|
+
| [`customer-guardrails/`](../../references/agent-session/customer-guardrails/README.md) | `pre-commit`, `pre-push` hooks, `.claude/settings.json`, `.github/workflows/merge-gate-audit.yml` (add `@se-studio/skills` as an exact-version devDependency first) |
|
|
113
114
|
|
|
114
115
|
Do **not** create `.cursor/BUGBOT.md`. Do **not** create `.cursorrules`. Do **not** require a `nick-go` label.
|
|
115
116
|
|