nitm-ai-dev-toolkit 5.1.2 → 5.2.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.
@@ -0,0 +1,306 @@
1
+ 'use strict';
2
+
3
+ // Relevance-aware patch and doctor. This module decides; bin/cli.js plans and writes.
4
+ // - .nitm/retired.json: paths the project retired (never re-added) and an optional tracker override
5
+ // - detectProject(): trackers, Playwright, Prisma, UI and stack facts read from the project
6
+ // - relevanceOf(): add | irrelevant | review for one template path
7
+ // - auditWrapper(): whether a harness wrapper is thin (link to its snippet plus key points) or inlines policy
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { execFileSync } = require('child_process');
12
+
13
+ const RETIRED_FILE = path.join('.nitm', 'retired.json');
14
+ const TRACKERS = ['github', 'gitlab', 'bitbucket', 'jira', 'linear'];
15
+ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
16
+ const MAX_KEY_POINTS = 5;
17
+ const MAX_SUMMARY_WORDS = 30;
18
+
19
+ // Tracker CLI skills ship only for the tracker they talk to. gh-cli also covers GitHub pull requests.
20
+ const TRACKER_SKILLS = { 'gh-cli': 'github', 'glab-cli': 'gitlab', 'bkt-cli': 'bitbucket', acli: 'jira', 'linear-cli': 'linear' };
21
+ // Files named after a tool or stack. They apply only when that tool or stack is detected.
22
+ const STEM_TOPICS = {
23
+ 'playwright-test': 'playwright',
24
+ 'prisma-migrations': 'prisma',
25
+ 'component-structure': 'ui',
26
+ 'ui-accessibility': 'ui',
27
+ };
28
+ const TOPIC_NOTES = {
29
+ playwright: 'no Playwright setup detected',
30
+ prisma: 'no Prisma setup detected',
31
+ ui: 'no UI framework detected',
32
+ };
33
+ // Empty MCP templates ship no servers, so a missing copy adds nothing.
34
+ const MCP_TEMPLATES = ['.mcp.json', '.cursor/mcp.json', '.vscode/mcp.json'];
35
+
36
+ const HOST_TRACKERS = { 'github.com': 'github', 'gitlab.com': 'gitlab', 'bitbucket.org': 'bitbucket' };
37
+ const UI_DEPS = ['react', 'react-dom', 'react-native', 'expo', 'next', 'vue', 'nuxt', 'svelte', '@sveltejs/kit',
38
+ '@angular/core', 'solid-js', 'astro', 'preact'];
39
+ const PLAYWRIGHT_DEPS = ['playwright', '@playwright/test'];
40
+ const PLAYWRIGHT_CONFIGS = ['playwright.config.ts', 'playwright.config.js', 'playwright.config.mjs', 'playwright.config.cjs'];
41
+ const PRISMA_DEPS = ['prisma', '@prisma/client'];
42
+ const PRISMA_FILES = ['schema.prisma', path.join('prisma', 'schema.prisma')];
43
+ // Root manifests that prove a stack exists (for ui decisions) and that may name Playwright.
44
+ const STACK_MANIFESTS = ['package.json', 'pyproject.toml', 'requirements.txt', 'setup.py', 'composer.json',
45
+ 'go.mod', 'Cargo.toml', 'Gemfile', 'pom.xml', 'build.gradle', 'build.gradle.kts'];
46
+
47
+ // Harness wrappers and the shared source each one links to. Snippets hold the policy; a skill with the
48
+ // same name (orient-to-recent-work) is the source when no snippet exists.
49
+ const WRAPPER_KINDS = [
50
+ { dir: '.claude/rules', snippets: 'rules-snippets' },
51
+ { dir: '.claude/commands', snippets: 'prompt-snippets' },
52
+ { dir: '.claude/agents', snippets: 'agents-snippets' },
53
+ { dir: '.cursor/rules', snippets: 'rules-snippets' },
54
+ { dir: '.cursor/commands', snippets: 'prompt-snippets' },
55
+ { dir: '.cursor/agents', snippets: 'agents-snippets' },
56
+ { dir: '.github/instructions', snippets: 'rules-snippets' },
57
+ { dir: '.github/prompts', snippets: 'prompt-snippets' },
58
+ { dir: '.github/agents', snippets: 'agents-snippets' },
59
+ { dir: '.opencode/rules', snippets: 'rules-snippets' },
60
+ { dir: '.opencode/commands', snippets: 'prompt-snippets' },
61
+ { dir: '.opencode/agents', snippets: 'agents-snippets' },
62
+ ];
63
+
64
+ function readJsonFile(p) {
65
+ try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch (_) { return null; }
66
+ }
67
+
68
+ function readText(p) {
69
+ try { return fs.readFileSync(p, 'utf8'); } catch (_) { return ''; }
70
+ }
71
+
72
+ // ---- retirement list ----
73
+
74
+ // Canonical form: forward slashes, no leading ./, no doubled or inner / segments, no trailing /. Climbing
75
+ // segments and absolute paths are refused on the raw input, before normalising could fold them away.
76
+ function safeRetiredPath(value, where) {
77
+ const raw = typeof value === 'string' ? value.replace(/\\/g, '/') : '';
78
+ const absolute = path.posix.isAbsolute(raw) || path.win32.isAbsolute(raw);
79
+ const climbs = raw.split('/').includes('..');
80
+ const rel = raw ? path.posix.normalize(raw).replace(/^(\.\/)+/, '').replace(/\/+$/, '') : '';
81
+ if (!rel || rel === '.' || absolute || climbs) {
82
+ throw new Error(`${where}.path must be a relative path inside the project (got ${JSON.stringify(value)})`);
83
+ }
84
+ return rel;
85
+ }
86
+
87
+ function normalizeRetired(entry, index) {
88
+ const where = `${RETIRED_FILE} retired[${index}]`;
89
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
90
+ throw new Error(`${where} must be an object with path, reason and date`);
91
+ }
92
+ const rel = safeRetiredPath(entry.path, where);
93
+ if (typeof entry.reason !== 'string' || !entry.reason.trim()) {
94
+ throw new Error(`${where}.reason is required: say why the file was retired`);
95
+ }
96
+ if (typeof entry.date !== 'string' || !DATE_RE.test(entry.date)) {
97
+ throw new Error(`${where}.date is required as YYYY-MM-DD`);
98
+ }
99
+ return { path: rel, reason: entry.reason.trim(), date: entry.date };
100
+ }
101
+
102
+ // Reads .nitm/retired.json. Absent means nothing retired. A file that exists but is invalid throws, so
103
+ // patch never falls back to re-adding files the project retired.
104
+ function readRetired(cwd) {
105
+ const p = path.join(cwd, RETIRED_FILE);
106
+ if (!fs.existsSync(p)) return { trackers: undefined, entries: [] };
107
+ let data;
108
+ try {
109
+ data = JSON.parse(fs.readFileSync(p, 'utf8'));
110
+ } catch (ex) {
111
+ throw new Error(`${RETIRED_FILE} exists but is not valid JSON (${ex.message}). Fix or remove it; nothing was written.`);
112
+ }
113
+ if (!data || typeof data !== 'object' || Array.isArray(data)) {
114
+ throw new Error(`${RETIRED_FILE} must be a JSON object with "retired" and optional "trackers"`);
115
+ }
116
+ let trackers;
117
+ if (data.trackers !== undefined && data.trackers !== null) {
118
+ if (!Array.isArray(data.trackers) || data.trackers.some((t) => !TRACKERS.includes(t))) {
119
+ throw new Error(`${RETIRED_FILE}: "trackers" must be a list drawn from ${TRACKERS.join(', ')} (use [] for none)`);
120
+ }
121
+ trackers = [...new Set(data.trackers)];
122
+ }
123
+ const list = data.retired === undefined ? [] : data.retired;
124
+ if (!Array.isArray(list)) throw new Error(`${RETIRED_FILE}: "retired" must be a list`);
125
+ return { trackers, entries: list.map(normalizeRetired) };
126
+ }
127
+
128
+ // The retirement entry covering a template path (exact file, or any file under a retired directory).
129
+ function retiredFor(key, entries) {
130
+ return entries.find((e) => key === e.path || key.startsWith(e.path + '/')) || null;
131
+ }
132
+
133
+ // ---- project facts ----
134
+
135
+ // package.json at the root and one level down (apps/*, packages/*), so monorepo dependencies count.
136
+ function packageJsons(cwd) {
137
+ const out = [];
138
+ const pkg = readJsonFile(path.join(cwd, 'package.json'));
139
+ if (pkg) out.push(pkg);
140
+ for (const parent of ['apps', 'packages']) {
141
+ let entries = [];
142
+ try {
143
+ entries = fs.readdirSync(path.join(cwd, parent), { withFileTypes: true });
144
+ } catch (_) { continue; }
145
+ for (const e of entries) {
146
+ const child = readJsonFile(path.join(cwd, parent, e.name, 'package.json'));
147
+ if (e.isDirectory() && child) out.push(child);
148
+ }
149
+ }
150
+ return out;
151
+ }
152
+
153
+ function dependencyNames(cwd) {
154
+ const names = new Set();
155
+ for (const pkg of packageJsons(cwd)) {
156
+ for (const name of [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})]) {
157
+ names.add(name);
158
+ }
159
+ }
160
+ return names;
161
+ }
162
+
163
+ // The tracker implied by the git origin host, or null when there is no origin or the host is unknown.
164
+ function remoteTrackers(cwd) {
165
+ let url;
166
+ try {
167
+ url = execFileSync('git', ['-C', cwd, 'remote', 'get-url', 'origin'],
168
+ { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 }).trim();
169
+ } catch (_) {
170
+ return null;
171
+ }
172
+ const match = url.match(/^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:[^@/]+@)?([^/:]+)/i);
173
+ const tracker = match && HOST_TRACKERS[match[1].toLowerCase()];
174
+ return tracker ? [tracker] : null;
175
+ }
176
+
177
+ // Facts the relevance rules read. `trackers` is null when unknown (the rules then ask for a decision),
178
+ // an array otherwise (possibly empty when the project has no tracker).
179
+ function detectProject(cwd, retired) {
180
+ const deps = dependencyNames(cwd);
181
+ const rootManifests = STACK_MANIFESTS.map((f) => readText(path.join(cwd, f))).join('\n').toLowerCase();
182
+ const configured = retired && retired.trackers !== undefined;
183
+ const trackers = configured ? retired.trackers : remoteTrackers(cwd);
184
+ const trackerSource = configured ? `configured in ${RETIRED_FILE}` : (trackers ? 'git origin' : 'not detected');
185
+ return {
186
+ trackers,
187
+ trackerSource,
188
+ playwright: PLAYWRIGHT_DEPS.some((d) => deps.has(d)) || /playwright/.test(rootManifests)
189
+ || PLAYWRIGHT_CONFIGS.some((f) => fs.existsSync(path.join(cwd, f))),
190
+ prisma: PRISMA_DEPS.some((d) => deps.has(d)) || PRISMA_FILES.some((f) => fs.existsSync(path.join(cwd, f))),
191
+ ui: UI_DEPS.some((d) => deps.has(d)),
192
+ stackKnown: STACK_MANIFESTS.some((f) => fs.existsSync(path.join(cwd, f))),
193
+ };
194
+ }
195
+
196
+ // ---- relevance ----
197
+
198
+ // What a template path depends on: 'tracker:<name>', 'playwright', 'prisma', 'ui', 'mcp', or null (generic).
199
+ function topicOf(rel) {
200
+ const n = rel.split(path.sep).join('/');
201
+ if (MCP_TEMPLATES.includes(n)) return 'mcp';
202
+ const skill = /^\.agents\/skills\/([^/]+)\//.exec(n);
203
+ if (skill && TRACKER_SKILLS[skill[1]]) return `tracker:${TRACKER_SKILLS[skill[1]]}`;
204
+ return STEM_TOPICS[path.posix.basename(n).split('.')[0]] || null;
205
+ }
206
+
207
+ // 'add' applies to the project; 'irrelevant' does not (never added); 'review' cannot be decided from the
208
+ // project yet (never added until someone decides).
209
+ function relevanceOf(rel, facts) {
210
+ const topic = topicOf(rel);
211
+ if (!topic) return { status: 'add', reason: '' };
212
+ if (topic === 'mcp') return { status: 'irrelevant', reason: 'empty MCP template, no servers configured' };
213
+ if (topic.startsWith('tracker:')) {
214
+ const tracker = topic.slice('tracker:'.length);
215
+ if (facts.trackers === null) {
216
+ return { status: 'review', reason: `tracker not detected; set "trackers" in ${RETIRED_FILE}` };
217
+ }
218
+ if (facts.trackers.includes(tracker)) return { status: 'add', reason: '' };
219
+ return { status: 'irrelevant', reason: `project tracker is ${facts.trackers.join(', ') || 'none'}` };
220
+ }
221
+ const detected = { playwright: facts.playwright, prisma: facts.prisma, ui: facts.ui }[topic];
222
+ if (detected) return { status: 'add', reason: '' };
223
+ if (topic === 'ui' && !facts.stackKnown) return { status: 'review', reason: 'no stack manifest found' };
224
+ return { status: 'irrelevant', reason: TOPIC_NOTES[topic] };
225
+ }
226
+
227
+ // ---- thin wrappers ----
228
+
229
+ // The wrapper's kind and the sources it must link to: its snippet, then a same-named skill.
230
+ function wrapperSources(rel) {
231
+ const n = rel.split(path.sep).join('/');
232
+ const kind = WRAPPER_KINDS.find((k) => n.startsWith(k.dir + '/') && !n.slice(k.dir.length + 1).includes('/'));
233
+ if (!kind) return null;
234
+ const base = path.posix.basename(n);
235
+ const name = base.replace(/\.(agent|instructions|prompt)\.md$/, '').replace(/\.mdc$/, '').replace(/\.md$/, '');
236
+ const snippet = `.claude/${kind.snippets}/${name}.md`;
237
+ const skill = `.agents/skills/${name}/SKILL.md`;
238
+ return [{ rel: snippet, needle: `${kind.snippets}/${name}.md` }, { rel: skill, needle: skill }];
239
+ }
240
+
241
+ function bodyOf(content) {
242
+ if (!content.startsWith('---\n')) return content;
243
+ const end = content.indexOf('\n---', 3); // the closing delimiter; empty frontmatter ("---\n---") included
244
+ return end < 0 ? content : content.slice(end + 4);
245
+ }
246
+
247
+ // `targets` are the sources that exist in the project, each as { rel, needle }.
248
+ // thin: links a source, with at most one short summary line, a few key points and no table or other policy
249
+ // text; inlined: more prose, a table or too many key points outside the link; diverged: links no existing source.
250
+ function auditWrapper(content, targets) {
251
+ const linked = targets.find((t) => bodyOf(content).includes(t.needle));
252
+ if (!linked) return { status: 'diverged', reason: `does not link ${targets.map((t) => t.rel).join(' or ')}` };
253
+ const prose = [];
254
+ let bullets = 0;
255
+ // "Agent Dispatch" names the agent to activate and "Arguments" the command syntax: both are activation metadata.
256
+ let metadata = false;
257
+ for (const raw of bodyOf(content).split('\n')) {
258
+ const line = raw.trim();
259
+ if (/^#+\s/.test(line)) { metadata = /^#+\s+(agent dispatch|arguments)\b/i.test(line); continue; }
260
+ if (metadata || line === '$ARGUMENTS') continue;
261
+ if (!line || line.startsWith('>') || line.includes(linked.needle)) continue;
262
+ if (/^([-*]|\d+\.)\s/.test(line)) { bullets++; continue; }
263
+ if (/:$/.test(line) && line.split(/\s+/).length <= 3) continue; // a label such as "Key points:"
264
+ prose.push(line);
265
+ }
266
+ const summaryOnly = prose.length === 1 && prose[0].split(/\s+/).length <= MAX_SUMMARY_WORDS;
267
+ if (prose.length > 0 && !summaryOnly) {
268
+ return { status: 'inlined', reason: `${prose.length} line(s) of policy text or table outside the link` };
269
+ }
270
+ if (bullets > MAX_KEY_POINTS) {
271
+ return { status: 'inlined', reason: `${bullets} key points (max ${MAX_KEY_POINTS}); move the rest into the source` };
272
+ }
273
+ return { status: 'thin', reason: '' };
274
+ }
275
+
276
+ // Wrappers among the planned entries that exist in the project and are not thin. Read-only: the caller
277
+ // reports them and proposes moving the inlined content into the snippet.
278
+ function auditWrappers(cwd, plan) {
279
+ const out = [];
280
+ for (const e of plan) {
281
+ if (e.action === 'retired') continue;
282
+ const sources = wrapperSources(e.rel);
283
+ const file = path.join(cwd, e.rel);
284
+ if (!sources || !fs.existsSync(file)) continue;
285
+ const targets = sources.filter((s) => fs.existsSync(path.join(cwd, s.rel)));
286
+ const result = targets.length
287
+ ? auditWrapper(fs.readFileSync(file, 'utf8'), targets)
288
+ : { status: 'diverged', reason: `no ${sources[0].rel} or ${sources[1].rel} to link` };
289
+ if (result.status !== 'thin') out.push({ rel: e.rel, status: result.status, reason: result.reason });
290
+ }
291
+ return out;
292
+ }
293
+
294
+ module.exports = {
295
+ RETIRED_FILE,
296
+ TRACKERS,
297
+ MAX_KEY_POINTS,
298
+ readRetired,
299
+ retiredFor,
300
+ detectProject,
301
+ topicOf,
302
+ relevanceOf,
303
+ wrapperSources,
304
+ auditWrapper,
305
+ auditWrappers,
306
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitm-ai-dev-toolkit",
3
- "version": "5.1.2",
3
+ "version": "5.2.0",
4
4
  "description": "Scaffold AI agent config (Cursor, GitHub Copilot, Claude Code, OpenCode, Codex) into any repo, then hand off to your AI agent to finish setup.",
5
5
  "bin": {
6
6
  "nitm-ai-dev-toolkit": "bin/cli.js"
@@ -115,11 +115,13 @@ The CLI runs the same patch flow without an AI session: `npx nitm-ai-dev-toolkit
115
115
 
116
116
  For each category, compare template files against project files:
117
117
 
118
- a. **Classify each file**:
119
- - **🆕 New**: Exists in template but not in project → candidate for addition
120
- - **📝 Updated**: Exists in both but template has newer content → candidate for merge
121
- - **✅ Current**: Exists in both and content matches → no action needed
122
- - **🔧 Customized**: Exists in both, project version has non-placeholder customizations → careful merge
118
+ a. **Classify each file** (relevance-aware; never a wholesale copy). `npx nitm-ai-dev-toolkit patch --dry-run` makes this classification and prints each reason. Read that plan before deciding anything, and see Relevance and Retirement in `bootstrap.md`:
119
+ - **add**: missing, and it applies to this project (tracker, Playwright, Prisma, UI, and MCP relevance)
120
+ - **update**: the toolkit wrote it and the project has not changed it since; the new template replaces it
121
+ - **current**: identical to the template; no action
122
+ - **needs review**: differs from the template (locally changed), or missing while relevance is undecided; never overwritten, and never added without a decision
123
+ - **not relevant**: does not apply to this project; never added. A present copy is a retirement candidate
124
+ - **retired**: listed in `.nitm/retired.json`; never added, updated or overwritten
123
125
  - **⚠️ Missing in Template**: Exists in project but not in template → project-specific, keep as-is except the approved obsolete toolkit Ponytail removal above
124
126
 
125
127
  b. **For updated files, generate a structured diff**:
@@ -130,7 +132,7 @@ The CLI runs the same patch flow without an AI session: `npx nitm-ai-dev-toolkit
130
132
 
131
133
  c. **Smart Merge Rules**:
132
134
  - **Never overwrite** project-specific values that replaced `{{PLACEHOLDER}}`
133
- - **Always add** new files that don't exist in the project
135
+ - **Add only** files classified *add*. Never add a not-relevant or retired file, and never add a file whose relevance is undecided without the operator's decision
134
136
  - **Merge structural additions** into existing customized files
135
137
  - **Flag for review** any removals from files that have been customized
136
138
  - **Preserve custom agents/skills** that were added by the project
@@ -144,13 +146,13 @@ The CLI runs the same patch flow without an AI session: `npx nitm-ai-dev-toolkit
144
146
  **Project Type**: repo | monorepo
145
147
  **Categories Scanned**: [list]
146
148
 
147
- ### 🆕 New Files (X files)
149
+ ### 🆕 Add (X files; apply to this project)
148
150
 
149
151
  | File | Category | Description |
150
152
  | ---------------------------- | -------- | ------------------------ |
151
153
  | `.cursor/rules/new-rule.mdc` | Rules | New coding standard rule |
152
154
 
153
- ### 📝 Updated Files (X files)
155
+ ### 📝 Update (X files; unchanged since the toolkit wrote them)
154
156
 
155
157
  | File | Changes | Risk |
156
158
  | -------------------------------------------------------- | ------------------------------ | -------------- |
@@ -161,16 +163,30 @@ The CLI runs the same patch flow without an AI session: `npx nitm-ai-dev-toolkit
161
163
 
162
164
  [No action needed]
163
165
 
164
- ### 🔧 Customized Files Requiring Review (X files)
166
+ ### 🔧 Needs Review (X files; locally changed or undecided; not written)
165
167
 
166
168
  | File | Template Changes | Project Customizations | Merge Strategy |
167
169
  | ----------- | ----------------- | ---------------------------- | -------------- |
168
170
  | `AGENTS.md` | New section added | Has project-specific content | Manual merge |
169
171
 
172
+ ### 🚫 Not Relevant or Retired (X files; not written)
173
+
174
+ | File | Reason | Action |
175
+ | ------------------------------------- | ---------------------------- | --------------------------------------- |
176
+ | `.claude/commands/playwright-test.md` | No Playwright setup detected | Keep out; retire if present (approval) |
177
+ | `.agents/skills/linear-cli/SKILL.md` | Project tracker is GitHub | Retire in `.nitm/retired.json` |
178
+
179
+ ### 🩹 Harness Wrappers to Review (X files; proposals only)
180
+
181
+ | Wrapper | Finding | Proposal |
182
+ | ----------------------------- | ------------------------------------ | ------------------------------------------------ |
183
+ | `.claude/rules/api-server.md` | Policy text outside the snippet link | Move the text into its snippet; keep a thin link |
184
+
170
185
  ### Summary
171
186
 
172
- - **Auto-apply**: X new files + Y updated files with no conflicts
173
- - **Review needed**: Z customized files with structural changes
187
+ - **Auto-apply**: X add + Y update entries, as printed by `patch`
188
+ - **Review needed**: Z needs-review files and W wrapper proposals
189
+ - **Not written**: N not-relevant or retired entries
174
190
  - **No action**: W files already current
175
191
  ```
176
192
 
@@ -178,9 +194,9 @@ The CLI runs the same patch flow without an AI session: `npx nitm-ai-dev-toolkit
178
194
  - If `--dry-run` flag: Output the report without making changes
179
195
  - Otherwise: Present the report and ask the user to confirm with (Y/n)
180
196
  - On confirmation:
181
- a. **New files**: Copy directly from template
182
- b. **Updated files (no customization)**: Replace with template version
183
- c. **Updated files (customized)**: Apply structural additions while preserving project values
197
+ a. **Add and update**: run `npx nitm-ai-dev-toolkit patch`. It writes only the add and update entries it printed; do not copy template files by hand
198
+ b. **Retirements**: after approval, record each path in `.nitm/retired.json` with a reason and date. Do not delete files to retire them
199
+ c. **Needs review**: propose a merge per file (structural additions, preserved project values) and apply it only after the operator approves that file. Wrappers that inline policy: propose moving the content into the snippet and reducing the wrapper to a thin link (see Thin Wrapper Policy in `bootstrap.md`)
184
200
  d. **OpenCode plugins**: Apply only the approved obsolete Ponytail cleanup above after backing up the known obsolete toolkit copies and local config; preserve all unrelated local/global plugins. Never add Ponytail to project config.
185
201
  e. **Toolkit version**: Keep the `.toolkit-version` value the CLI writes for the verified target version (the installed package version, 4.0.0 or later; never hard-coded) only after the approved migration and OpenCode preflight pass (or OpenCode is confirmed out of scope).
186
202
  f. **Git commit**: Stage and commit all changes with message:
@@ -255,6 +255,8 @@ Follow the rules defined in [.claude/rules-snippets/{{NAME}}.md](../../.claude/r
255
255
 
256
256
  ### Step 7: Create .opencode/ Directory (confirmed OpenCode use only)
257
257
 
258
+ Create wrappers below only for entries the patch plan classifies *add* (never retired or not-relevant snippets). Each wrapper stays thin (see Thin Wrapper Policy in `bootstrap.md`).
259
+
258
260
  For the v3 route, merge only relevant native OpenCode host fields; preserve existing wrapper bodies, modes, unrelated frontmatter, and shared snippet bodies/frontmatter. The wrapper examples below apply only to approved missing files, not replacement of existing wrappers.
259
261
 
260
262
  1. Merge `.opencode/opencode.jsonc` using native V2 fields:
@@ -312,12 +314,13 @@ For the v3 route, merge only relevant native OpenCode host fields; preserve exis
312
314
 
313
315
  ### Step 8: Install Pre-Commit Hook
314
316
 
315
- Install the CHANGELOG/secrets enforcement hook to run before every commit:
317
+ Install the CHANGELOG/secrets enforcement hook before every commit, only with the operator's approval, only in a git repository, and never over an existing `.git/hooks/pre-commit`. If one exists, show the difference and propose chaining or merging instead:
316
318
 
317
319
  1. Copy `scripts/pre-commit-check.sh` from the template to the target project's `scripts/` directory
318
320
  2. Install as a git hook:
319
321
 
320
322
  ```bash
323
+ # only when .git/hooks/pre-commit does not exist yet
321
324
  cp scripts/pre-commit-check.sh .git/hooks/pre-commit
322
325
  chmod +x .git/hooks/pre-commit
323
326
  ```
@@ -330,10 +333,12 @@ This enforces:
330
333
 
331
334
  Use `git commit --no-verify` to bypass.
332
335
 
333
- ### Step 9: Install Project Hooks
336
+ ### Step 9: Install Project Hooks (only with approval)
337
+
338
+ The `hooks/` files are Claude Code plugin hooks (`${CLAUDE_PLUGIN_ROOT}`) and the Ponytail runtime. They fire only when installed through the Ponytail plugin, not from project settings. Copy only the files the operator approves for a project that uses that plugin, and never overwrite an existing hook file.
334
339
 
335
- 1. Create `hooks/` directory in the target project
336
- 2. Copy all files from the template's `hooks/*` directory (preserve sub-structure)
340
+ 1. Create `hooks/` in the target project when copying
341
+ 2. Copy the approved files from the template's `hooks/*` directory (preserve sub-structure); skip any file that already exists
337
342
  3. Make `.js` files executable on Unix: `chmod +x hooks/*.js`
338
343
 
339
344
  ### Step 10: Clean Up Duplicate Skills
@@ -20,6 +20,28 @@ You are helping to bootstrap AI instructions for this monorepo by analyzing the
20
20
  - Codex MCP uses native `[mcp_servers.name]` TOML, not `.mcp.json`. Treat other harness MCP templates as references only; do not activate servers, copy credentials, or install hooks automatically.
21
21
  - Update and audit only confirmed harness targets. For Codex-only setup, the native targets are root/nested `AGENTS.md`, `.agents/skills/`, and `.codex/config.toml`. `--env codex` also includes `.github/instructions/` and `.claude/rules-snippets/` solely as AGENTS-linked standards and their wrapper sources, not automatically loaded rules or evidence of Copilot/Claude use; other harness command, agent, and config directories are excluded. Tool-specific steps below are conditional.
22
22
 
23
+ ## Thin Wrapper Policy
24
+
25
+ Canonical policy lives only in `.claude/rules-snippets/`, `.claude/prompt-snippets/`, and `.claude/agents-snippets/`. Every harness wrapper (`.claude/{rules,commands,agents}/`, `.cursor/{rules,commands,agents}/`, `.github/{instructions,prompts,agents}/`, `.opencode/{rules,commands,agents}/`, and Codex and Copilot entry files) is a thin link to its snippet: frontmatter, a title, the link line, at most five key points, and optionally one short summary line. Its agent-dispatch table is activation metadata and may stay.
26
+
27
+ - **Create or change policy in the snippet first, then the wrapper.** Never write a wrapper with a copy of the policy, and never let a wrapper diverge from its snippet.
28
+ - **Skills that restate a snippet's policy point to the snippet** (or, where the skill is the source, the snippet points to the skill). Keep one source of policy text.
29
+ - **Existing wrappers that inline policy or diverge from their snippet** are reported (`npx nitm-ai-dev-toolkit doctor` lists them). Propose moving the content into the snippet and reducing the wrapper to a link. Change nothing without the operator's approval.
30
+
31
+ ## Relevance and Retirement
32
+
33
+ The template ships files for every stack, tracker and test tool. Decide what applies to this monorepo and each app; do not copy the whole template.
34
+
35
+ - **Relevance comes from the project:** the tracker (git origin host, or `"trackers"` in `.nitm/retired.json`), Playwright, Prisma, the UI framework (read from the root and `apps/*`, `packages/*` package manifests), and whether MCP servers are configured. `npx nitm-ai-dev-toolkit patch --dry-run` prints each template file's classification with its reason (add, update, needs review, not relevant, retired). Use that plan; do not copy template files by hand.
36
+ - **Retire what does not apply** by recording it in `.nitm/retired.json` after the operator agrees, with a reason and date:
37
+
38
+ ```json
39
+ { "retired": [{ "path": ".agents/skills/linear-cli", "reason": "GitHub Issues is the tracker", "date": "2026-10-27" }] }
40
+ ```
41
+
42
+ A directory path retires every file under it. Patch and upgrade never re-add retired paths, and doctor reports them as retired, not missing. Never delete files to retire them.
43
+ - **Override tracker detection** with `"trackers": ["github"]` (or `[]` for none) when the git origin does not name the tracker.
44
+
23
45
  ## Your Task
24
46
 
25
47
  1. **Analyze the Monorepo**:
@@ -333,11 +355,16 @@ Present the replacements and confirm before applying.
333
355
 
334
356
  10. **Recommend and Install AI Agent Skills**:
335
357
 
336
- Based on detected ecosystem and frameworks, recommend relevant skills from [skills.sh](https://skills.sh/) and [agentskills.io](https://agentskills.io/).
358
+ Recommend skills from [skills.sh](https://skills.sh/) and [agentskills.io](https://agentskills.io/) only for needs this monorepo or app has: its tracker, framework, language, and test tooling. Never install a whole repository with `--skill '*'`. The toolkit already ships the core workflow skills (TDD, debugging, planning, review) in `.agents/skills/`, so do not recommend them again.
359
+
360
+ **Rules for every recommendation:**
361
+ - One named skill per install (`--skill <name>`). Confirm the name exists in its source repository first. If you cannot confirm it, leave that install out and say so.
362
+ - List the detected need next to each skill. Recommend nothing without a need.
363
+ - Install nothing before the operator approves that skill. Approving one skill does not approve the others.
337
364
 
338
365
  **Important:** Use the detected agent flags from step 9 in all `npx skills add` commands. This prevents creating unnecessary configurations for agents the user doesn't have installed.
339
366
 
340
- **Core Skills (Always Recommend):**
367
+ **Generic workflow skills (optional; the toolkit already ships equivalents):**
341
368
 
342
369
  | Skill Repository | Purpose |
343
370
  | -------------------------- | -------------------------------------------------- |
@@ -348,8 +375,7 @@ Based on detected ecosystem and frameworks, recommend relevant skills from [skil
348
375
  **Example commands** (replace `{{AGENT_FLAGS}}` with confirmed harness flags from step 9, e.g., `-a codex`):
349
376
 
350
377
  ```bash
351
- npx -y skills add {{AGENT_FLAGS}} obra/superpowers --skill '*'
352
- npx -y skills add {{AGENT_FLAGS}} trailofbits/skills --skill '*'
378
+ npx -y skills add {{AGENT_FLAGS}} <owner/repo> --skill <confirmed name> # one line per approved skill
353
379
  ```
354
380
 
355
381
  **Issue Tracker Skills Health Check (if {{ISSUE_TRACKER}} is configured):**
@@ -373,10 +399,10 @@ This template bundles issue tracker skills in `.agents/skills/`. Verify the corr
373
399
  - Configured tracker: Linear
374
400
  - Found skill: acli (not matching)
375
401
  - Expected skill: linear-cli
376
- Remove acli and keep linear-cli? (Y/n)
402
+ Retire acli and keep linear-cli? (Y/n)
377
403
  ```
378
- 4. **Prune unused CLI skills:** On confirmation, delete the mismatched skill directory and update AGENTS.md Skills table
379
- 5. **If missing:** Warn that the expected CLI skill is not present and offer to copy it from the template bundle
404
+ 4. **Retire mismatched CLI skills:** On confirmation, record each in `.nitm/retired.json` (reason and date) and update the AGENTS.md Skills table. Delete a directory only with separate approval and a backup
405
+ 5. **If missing:** Warn that the expected CLI skill is not present; add it only when `patch --dry-run` shows it applies and the operator approves
380
406
 
381
407
  **Framework-Specific Skills:**
382
408
 
@@ -411,13 +437,13 @@ When recommending framework-specific skills, include the detected agent flags. E
411
437
  | React | `vercel-labs/agent-skills` | `npx -y skills add {{AGENT_FLAGS}} vercel-labs/agent-skills --skill "vercel-react-best-practices"` |
412
438
  | Vue | `onmax/nuxt-skills` (vue) | `npx -y skills add {{AGENT_FLAGS}} onmax/nuxt-skills --skill "vue"` |
413
439
  | Nuxt | `onmax/nuxt-skills` (nuxt) | `npx -y skills add {{AGENT_FLAGS}} onmax/nuxt-skills --skill "nuxt"` |
414
- | Expo | `expo/skills` | `npx -y skills add {{AGENT_FLAGS}} expo/skills --skill '*'` |
415
- | TypeScript | `pproenca/dot-skills` (typescript) | `npx -y skills add {{AGENT_FLAGS}} pproenca/dot-skills --skill '*'` |
416
- | Advanced Types | `wshobson/agents` (ts-advanced-types) | `npx -y skills add {{AGENT_FLAGS}} wshobson/agents --skill '*'` |
440
+ | Expo | `expo/skills` | `npx -y skills add {{AGENT_FLAGS}} expo/skills --skill <name confirmed in the repository>` |
441
+ | TypeScript | `pproenca/dot-skills` (typescript) | `npx -y skills add {{AGENT_FLAGS}} pproenca/dot-skills --skill "typescript"` |
442
+ | Advanced Types | `wshobson/agents` (ts-advanced-types) | `npx -y skills add {{AGENT_FLAGS}} wshobson/agents --skill "ts-advanced-types"` |
417
443
 
418
444
  **Skill Creation for Unsupported Frameworks:**
419
445
 
420
- Use `npx -y skills add {{AGENT_FLAGS}} anthropics/skills --skill '*'` (includes `skill-creator`) to create custom skills.
446
+ To create a custom skill for an unsupported framework, install only `skill-creator` from `anthropics/skills`: `npx -y skills add {{AGENT_FLAGS}} anthropics/skills --skill "skill-creator"`.
421
447
 
422
448
  **Monorepo-Specific Considerations:**
423
449
 
@@ -438,28 +464,26 @@ Using flags: {{AGENT_FLAGS}}
438
464
 
439
465
  Based on your monorepo ({{BUILD_SYSTEM}}/{{LANGUAGE}}):
440
466
 
441
- Core Skills (recommended for all projects):
442
- npx -y skills add {{AGENT_FLAGS}} obra/superpowers --skill '*'
443
- npx -y skills add {{AGENT_FLAGS}} trailofbits/skills --skill '*'
444
- npx -y skills add {{AGENT_FLAGS}} softaworks/agent-toolkit --skill '*'
467
+ Approved installs (none until the operator approves each one):
468
+ npx -y skills add {{AGENT_FLAGS}} <owner/repo> --skill <confirmed name> # one line per approved skill
445
469
 
446
470
  Issue Tracker Skills (bundled — {{ISSUE_TRACKER}}):
447
471
  ✅ .agents/skills/issue-tracker/SKILL.md (shared strategy)
448
472
  ✅ Matching CLI reference: .agents/skills/acli/SKILL.md, .agents/skills/gh-cli/SKILL.md, or .agents/skills/linear-cli/SKILL.md
449
- ⚠️ Prune any issue-tracker CLI skills that do not match {{ISSUE_TRACKER}} (if any)
473
+ ⚠️ Retire any issue-tracker CLI skills that do not match {{ISSUE_TRACKER}} (if any; record them in .nitm/retired.json)
450
474
 
451
- Framework-Specific Skills:
452
- - web (Next.js): npx -y skills add {{AGENT_FLAGS}} vercel-labs/agent-skills --skill '*'
453
- - api (Hono): npx -y skills add {{AGENT_FLAGS}} elysiajs/skills --skill '*'
475
+ Framework-Specific Skills (one named skill each, after confirming its name):
476
+ - web (Next.js): npx -y skills add {{AGENT_FLAGS}} vercel-labs/agent-skills --skill <confirmed name>
477
+ - api (Hono): npx -y skills add {{AGENT_FLAGS}} elysiajs/skills --skill <confirmed name>
454
478
 
455
- Install All? (Y/n)
479
+ Approve each skill by name (or none). Nothing is installed without approval.
456
480
  ```
457
481
 
458
482
  **Example with detected agents:**
459
483
 
460
484
  - If Cursor and Copilot are confirmed: `AGENT_FLAGS="-a cursor -a github-copilot"`
461
485
  - If only Codex is confirmed: `AGENT_FLAGS="-a codex"`
462
- - Codex-only command: `npx -y skills add -a codex obra/superpowers --skill '*'`
486
+ - Codex-only command: `npx -y skills add -a codex <owner/repo> --skill <confirmed name>`
463
487
 
464
488
  **On Confirmation:**
465
489
 
@@ -530,11 +554,12 @@ Next Steps:
530
554
  | django-expert | Django patterns | No Django apps detected |
531
555
  | php | PHP patterns | JavaScript/TypeScript monorepo |
532
556
 
533
- Remove flagged skills? (Y/n)
557
+ Retire flagged skills? (Y/n)
534
558
  ```
535
559
 
536
560
  **On Confirmation:**
537
- - Remove unnecessary skill directories
561
+ - Record each approved skill in `.nitm/retired.json` (reason and date) so `patch` leaves it out; this removes nothing from the template
562
+ - Delete a skill directory only with separate approval and a backup
538
563
  - Update root AGENTS.md to remove references
539
564
  - Report cleanup results
540
565
 
@@ -566,8 +591,8 @@ Next Steps:
566
591
  ```
567
592
 
568
593
  **On Confirmation (only if Copilot is confirmed in use):**
569
- - Generate missing Copilot instruction files with appropriate templates; skip creation for a Codex-only audit even when shared reference standards are present
570
- - Include app-specific scoping (applyTo paths)
594
+ - Write the policy of each missing Copilot instruction into `.claude/rules-snippets/<name>.md` first, then create `.github/instructions/<name>.instructions.md` as a thin wrapper (frontmatter with `applyTo`, a title, a link to the snippet, at most five key points); skip creation for a Codex-only audit even when shared reference standards are present
595
+ - Include app-specific scoping (applyTo paths) in the wrapper frontmatter only
571
596
  - Include framework-specific patterns from skills
572
597
  - Report created files
573
598
 
@@ -1,6 +1,6 @@
1
1
  # Claude Code Skills
2
2
 
3
- This folder is for skills installed via `npx -y skills add -a claude-code <owner/repo> --skill '*'`.
3
+ This folder is for skills installed via `npx -y skills add -a claude-code <owner/repo> --skill <confirmed name>`.
4
4
 
5
5
  ## About Skills
6
6
 
@@ -12,10 +12,10 @@ Install skills from [skills.sh](https://skills.sh/) using the `-a claude-code` f
12
12
 
13
13
  ```bash
14
14
  # For Claude Code only
15
- npx -y skills add -a claude-code <owner/repo> --skill '*'
15
+ npx -y skills add -a claude-code <owner/repo> --skill <confirmed name>
16
16
 
17
17
  # For multiple agents (e.g., Claude Code + GitHub Copilot)
18
- npx -y skills add -a claude-code -a github-copilot <owner/repo> --skill '*'
18
+ npx -y skills add -a claude-code -a github-copilot <owner/repo> --skill <confirmed name>
19
19
  ```
20
20
 
21
21
  **Tip:** The skills CLI automatically detects installed agents. If you omit `-a claude-code`, you'll be prompted to choose from detected agents.
@@ -37,14 +37,14 @@ Universal workflow skills are pre-installed in `.agents/skills/`. These include:
37
37
 
38
38
  ```bash
39
39
  # Frontend skills
40
- npx -y skills add -a claude-code onmax/nuxt-skills --skill '*'
41
- npx -y skills add -a claude-code vercel-labs/agent-skills --skill '*'
40
+ npx -y skills add -a claude-code onmax/nuxt-skills --skill vue
41
+ npx -y skills add -a claude-code vercel-labs/agent-skills --skill vercel-react-best-practices
42
42
 
43
43
  # Security skills
44
- npx -y skills add -a claude-code trailofbits/skills --skill '*'
44
+ npx -y skills add -a claude-code trailofbits/skills --skill <confirmed name>
45
45
 
46
46
  # Framework-specific
47
- npx -y skills add -a claude-code better-auth/skills --skill '*'
47
+ npx -y skills add -a claude-code better-auth/skills --skill <confirmed name>
48
48
  ```
49
49
 
50
50
  See the main README.md for a full list of recommended skills.