@phuc1403/musketeer 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -49
- package/manifest.json +333 -301
- package/package.json +1 -1
- package/template/.claude/agents/code-reviewer.md +182 -166
- package/template/.claude/hooks/git-skill-reminder.cjs +53 -0
- package/template/.claude/hooks/inject-design-docs.cjs +13 -13
- package/template/.claude/hooks/inject-ubiquitous-language.cjs +52 -0
- package/template/.claude/hooks/lib/colors.cjs +180 -122
- package/template/.claude/hooks/lib/transcript-parser.cjs +300 -277
- package/template/.claude/skills/code-review/SKILL.md +201 -54
- package/template/.claude/skills/code-review/references/checklist-workflow.md +96 -0
- package/template/.claude/skills/code-review/references/checklists/api.md +52 -52
- package/template/.claude/skills/code-review/references/checklists/base.md +100 -100
- package/template/.claude/skills/code-review/references/checklists/web-app.md +54 -54
- package/template/.claude/skills/code-review/references/code-review-reception.md +113 -0
- package/template/.claude/skills/code-review/references/codebase-scan-workflow.md +30 -0
- package/template/.claude/skills/code-review/references/edge-case-scouting.md +119 -0
- package/template/.claude/skills/code-review/references/input-mode-resolution.md +135 -0
- package/template/.claude/skills/code-review/references/parallel-review-workflow.md +76 -0
- package/template/.claude/skills/code-review/references/requesting-code-review.md +116 -0
- package/template/.claude/skills/code-review/references/spec-compliance-review.md +43 -0
- package/template/.claude/skills/code-review/references/task-management-reviews.md +140 -0
- package/template/.claude/skills/code-review/references/verification-before-completion.md +139 -0
- package/template/.claude/skills/context-map/SKILL.md +1 -1
- package/template/.claude/skills/git/SKILL.md +131 -115
- package/template/.claude/skills/git/references/branch-management.md +88 -88
- package/template/.claude/skills/git/references/commit-standards.md +46 -46
- package/template/.claude/skills/git/references/context-efficiency.md +54 -0
- package/template/.claude/skills/git/references/gh-cli-guide.md +109 -109
- package/template/.claude/skills/git/references/safety-protocols.md +69 -69
- package/template/.claude/skills/git/references/workflow-commit.md +58 -58
- package/template/.claude/skills/git/references/workflow-merge-pr.md +136 -0
- package/template/.claude/skills/git/references/workflow-merge.md +48 -48
- package/template/.claude/skills/git/references/workflow-pr.md +58 -58
- package/template/.claude/skills/git/references/workflow-push.md +52 -52
- package/template/.claude/skills/knowledge-crunching/SKILL.md +56 -92
- package/template/.claude/skills/knowledge-crunching/assets/ubiquitous-language.template.md +3 -0
- package/template/.claude/skills/skill-creator/LICENSE.txt +201 -201
- package/template/.claude/skills/skill-creator/SKILL.md +154 -149
- package/template/.claude/skills/skill-creator/agents/analyzer.md +274 -274
- package/template/.claude/skills/skill-creator/agents/comparator.md +202 -202
- package/template/.claude/skills/skill-creator/agents/grader.md +223 -223
- package/template/.claude/skills/skill-creator/assets/eval_review.html +146 -146
- package/template/.claude/skills/skill-creator/eval-viewer/generate_review.py +471 -471
- package/template/.claude/skills/skill-creator/eval-viewer/viewer.html +1325 -1325
- package/template/.claude/skills/skill-creator/references/benchmark-optimization-guide.md +86 -86
- package/template/.claude/skills/skill-creator/references/distribution-guide.md +79 -79
- package/template/.claude/skills/skill-creator/references/eval-infrastructure-guide.md +129 -129
- package/template/.claude/skills/skill-creator/references/eval-schemas.md +121 -121
- package/template/.claude/skills/skill-creator/references/mcp-skills-integration.md +71 -71
- package/template/.claude/skills/skill-creator/references/metadata-quality-criteria.md +94 -94
- package/template/.claude/skills/skill-creator/references/plugin-marketplace-hosting.md +104 -104
- package/template/.claude/skills/skill-creator/references/plugin-marketplace-overview.md +89 -89
- package/template/.claude/skills/skill-creator/references/plugin-marketplace-schema.md +93 -93
- package/template/.claude/skills/skill-creator/references/plugin-marketplace-sources.md +103 -103
- package/template/.claude/skills/skill-creator/references/plugin-marketplace-troubleshooting.md +76 -76
- package/template/.claude/skills/skill-creator/references/script-quality-criteria.md +106 -106
- package/template/.claude/skills/skill-creator/references/skill-anatomy-and-requirements.md +77 -77
- package/template/.claude/skills/skill-creator/references/skill-creation-workflow.md +152 -151
- package/template/.claude/skills/skill-creator/references/skill-design-patterns.md +75 -75
- package/template/.claude/skills/skill-creator/references/skillmark-benchmark-criteria.md +102 -102
- package/template/.claude/skills/skill-creator/references/structure-organization-criteria.md +114 -114
- package/template/.claude/skills/skill-creator/references/testing-and-iteration.md +78 -78
- package/template/.claude/skills/skill-creator/references/token-efficiency-criteria.md +74 -74
- package/template/.claude/skills/skill-creator/references/troubleshooting-guide.md +81 -81
- package/template/.claude/skills/skill-creator/references/validation-checklist.md +83 -83
- package/template/.claude/skills/skill-creator/references/writing-effective-instructions.md +88 -88
- package/template/.claude/skills/skill-creator/references/yaml-frontmatter-reference.md +92 -92
- package/template/.claude/skills/skill-creator/scripts/aggregate_benchmark.py +401 -401
- package/template/.claude/skills/skill-creator/scripts/encoding_utils.py +36 -36
- package/template/.claude/skills/skill-creator/scripts/generate_report.py +326 -326
- package/template/.claude/skills/skill-creator/scripts/improve_description.py +248 -248
- package/template/.claude/skills/skill-creator/scripts/init_skill.py +360 -360
- package/template/.claude/skills/skill-creator/scripts/package_skill.py +143 -143
- package/template/.claude/skills/skill-creator/scripts/quick_validate.py +110 -110
- package/template/.claude/skills/skill-creator/scripts/run_eval.py +310 -310
- package/template/.claude/skills/skill-creator/scripts/run_loop.py +332 -332
- package/template/.claude/skills/skill-creator/scripts/utils.py +47 -47
- package/template/.claude/statusline.cjs +0 -0
- package/template/.claude/hooks/inject-context.cjs +0 -52
- package/template/.claude/skills/code-review/references/adversarial-review.md +0 -223
- package/template/.claude/skills/knowledge-crunching/assets/context.template.md +0 -59
- package/template/.claude/skills/knowledge-crunching/references/crunching-dialogue.md +0 -113
- /package/template/.claude/hooks/{usage-context-awareness.cjs → usage-quota-cache-refresh.cjs} +0 -0
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
"""Shared utilities for skill-creator scripts."""
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def parse_skill_md(skill_path: Path) -> tuple[str, str, str]:
|
|
8
|
-
"""Parse a SKILL.md file, returning (name, description, full_content)."""
|
|
9
|
-
content = (skill_path / "SKILL.md").read_text()
|
|
10
|
-
lines = content.split("\n")
|
|
11
|
-
|
|
12
|
-
if lines[0].strip() != "---":
|
|
13
|
-
raise ValueError("SKILL.md missing frontmatter (no opening ---)")
|
|
14
|
-
|
|
15
|
-
end_idx = None
|
|
16
|
-
for i, line in enumerate(lines[1:], start=1):
|
|
17
|
-
if line.strip() == "---":
|
|
18
|
-
end_idx = i
|
|
19
|
-
break
|
|
20
|
-
|
|
21
|
-
if end_idx is None:
|
|
22
|
-
raise ValueError("SKILL.md missing frontmatter (no closing ---)")
|
|
23
|
-
|
|
24
|
-
name = ""
|
|
25
|
-
description = ""
|
|
26
|
-
frontmatter_lines = lines[1:end_idx]
|
|
27
|
-
i = 0
|
|
28
|
-
while i < len(frontmatter_lines):
|
|
29
|
-
line = frontmatter_lines[i]
|
|
30
|
-
if line.startswith("name:"):
|
|
31
|
-
name = line[len("name:"):].strip().strip('"').strip("'")
|
|
32
|
-
elif line.startswith("description:"):
|
|
33
|
-
value = line[len("description:"):].strip()
|
|
34
|
-
# Handle YAML multiline indicators (>, |, >-, |-)
|
|
35
|
-
if value in (">", "|", ">-", "|-"):
|
|
36
|
-
continuation_lines: list[str] = []
|
|
37
|
-
i += 1
|
|
38
|
-
while i < len(frontmatter_lines) and (frontmatter_lines[i].startswith(" ") or frontmatter_lines[i].startswith("\t")):
|
|
39
|
-
continuation_lines.append(frontmatter_lines[i].strip())
|
|
40
|
-
i += 1
|
|
41
|
-
description = " ".join(continuation_lines)
|
|
42
|
-
continue
|
|
43
|
-
else:
|
|
44
|
-
description = value.strip('"').strip("'")
|
|
45
|
-
i += 1
|
|
46
|
-
|
|
47
|
-
return name, description, content
|
|
1
|
+
"""Shared utilities for skill-creator scripts."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def parse_skill_md(skill_path: Path) -> tuple[str, str, str]:
|
|
8
|
+
"""Parse a SKILL.md file, returning (name, description, full_content)."""
|
|
9
|
+
content = (skill_path / "SKILL.md").read_text()
|
|
10
|
+
lines = content.split("\n")
|
|
11
|
+
|
|
12
|
+
if lines[0].strip() != "---":
|
|
13
|
+
raise ValueError("SKILL.md missing frontmatter (no opening ---)")
|
|
14
|
+
|
|
15
|
+
end_idx = None
|
|
16
|
+
for i, line in enumerate(lines[1:], start=1):
|
|
17
|
+
if line.strip() == "---":
|
|
18
|
+
end_idx = i
|
|
19
|
+
break
|
|
20
|
+
|
|
21
|
+
if end_idx is None:
|
|
22
|
+
raise ValueError("SKILL.md missing frontmatter (no closing ---)")
|
|
23
|
+
|
|
24
|
+
name = ""
|
|
25
|
+
description = ""
|
|
26
|
+
frontmatter_lines = lines[1:end_idx]
|
|
27
|
+
i = 0
|
|
28
|
+
while i < len(frontmatter_lines):
|
|
29
|
+
line = frontmatter_lines[i]
|
|
30
|
+
if line.startswith("name:"):
|
|
31
|
+
name = line[len("name:"):].strip().strip('"').strip("'")
|
|
32
|
+
elif line.startswith("description:"):
|
|
33
|
+
value = line[len("description:"):].strip()
|
|
34
|
+
# Handle YAML multiline indicators (>, |, >-, |-)
|
|
35
|
+
if value in (">", "|", ">-", "|-"):
|
|
36
|
+
continuation_lines: list[str] = []
|
|
37
|
+
i += 1
|
|
38
|
+
while i < len(frontmatter_lines) and (frontmatter_lines[i].startswith(" ") or frontmatter_lines[i].startswith("\t")):
|
|
39
|
+
continuation_lines.append(frontmatter_lines[i].strip())
|
|
40
|
+
i += 1
|
|
41
|
+
description = " ".join(continuation_lines)
|
|
42
|
+
continue
|
|
43
|
+
else:
|
|
44
|
+
description = value.strip('"').strip("'")
|
|
45
|
+
i += 1
|
|
46
|
+
|
|
47
|
+
return name, description, content
|
|
Binary file
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SessionStart hook (dotnet company): auto-load the repo-root `CONTEXT.md` — the
|
|
3
|
-
// bounded-context model produced by the knowledge-crunching skill — into every
|
|
4
|
-
// session, so the domain's ubiquitous language and invariants "lead the code".
|
|
5
|
-
//
|
|
6
|
-
// If the root CONTEXT.md is missing, ALERT the user (systemMessage) so they
|
|
7
|
-
// create one. Any other error fails open (emits nothing, exit 0) so it can never
|
|
8
|
-
// block a session.
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const path = require("path");
|
|
11
|
-
|
|
12
|
-
const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
13
|
-
const file = path.join(root, "CONTEXT.md");
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
let content;
|
|
17
|
-
try {
|
|
18
|
-
content = fs.readFileSync(file, "utf-8");
|
|
19
|
-
} catch {
|
|
20
|
-
// Not found — surface a visible warning to the user, inject nothing.
|
|
21
|
-
process.stdout.write(
|
|
22
|
-
JSON.stringify({
|
|
23
|
-
systemMessage:
|
|
24
|
-
"musketeer: no CONTEXT.md at the repo root — the bounded-context model is missing. " +
|
|
25
|
-
"Run the knowledge-crunching skill (/knowledge-crunching) to create one.",
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
process.exit(0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const additionalContext =
|
|
32
|
-
"Bounded-context model (root CONTEXT.md) — injected every session. It is the " +
|
|
33
|
-
"ubiquitous language and model rules of this bounded context, kept vendor- and " +
|
|
34
|
-
"decision-neutral. Treat it as canonical for domain naming, concepts, and invariants: " +
|
|
35
|
-
"name new code after it, and when a concept is renamed update CONTEXT.md and the code in " +
|
|
36
|
-
"the same turn. It bounds what the DOMAIN model sees, not what infrastructure may do " +
|
|
37
|
-
"(an ACL can legitimately key on more).\n\n" +
|
|
38
|
-
"===== CONTEXT.md =====\n" +
|
|
39
|
-
content.trimEnd();
|
|
40
|
-
|
|
41
|
-
process.stdout.write(
|
|
42
|
-
JSON.stringify({
|
|
43
|
-
hookSpecificOutput: {
|
|
44
|
-
hookEventName: "SessionStart",
|
|
45
|
-
additionalContext,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
process.exit(0);
|
|
50
|
-
} catch {
|
|
51
|
-
process.exit(0); // fail open
|
|
52
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: adversarial-review
|
|
3
|
-
description: Stage 3 red-team review that actively tries to break code — finds security holes, false assumptions, failure modes, race conditions. Spawns adversarial reviewer subagent with destructive mindset. Includes scope gate for trivial changes.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Adversarial Review (Stage 3)
|
|
7
|
-
|
|
8
|
-
Runs after every Stage 2 (Code Quality) pass. Subject to scope gate below.
|
|
9
|
-
|
|
10
|
-
## Scope Gate
|
|
11
|
-
|
|
12
|
-
Skip adversarial review when ALL of these are true:
|
|
13
|
-
- Changed files <= 2
|
|
14
|
-
- Lines changed <= 30
|
|
15
|
-
- No security-sensitive files touched (auth, crypto, input parsing, SQL, env)
|
|
16
|
-
- No new dependencies added
|
|
17
|
-
|
|
18
|
-
When skipped, note: `Adversarial: skipped (below threshold)` in review output.
|
|
19
|
-
|
|
20
|
-
**NEVER skip when:**
|
|
21
|
-
- Any file in: `auth/`, `middleware/`, `security/`, `crypto/`
|
|
22
|
-
- `package.json`, `package-lock.json`, or lockfile changed
|
|
23
|
-
- Environment variables added/changed
|
|
24
|
-
- Database schema modified
|
|
25
|
-
- API route added/changed
|
|
26
|
-
|
|
27
|
-
## Mindset
|
|
28
|
-
|
|
29
|
-
> "You are hired to tear apart the implementer's work. Your job is to find every way this code can fail, be exploited, or produce incorrect results. Assume the implementer made mistakes. Prove it."
|
|
30
|
-
|
|
31
|
-
This is NOT a standard code review. Standard reviews check if code meets requirements. Adversarial review assumes requirements are met and asks: **"How can this still break?"**
|
|
32
|
-
|
|
33
|
-
## What to Attack
|
|
34
|
-
|
|
35
|
-
### Security Holes
|
|
36
|
-
- Injection vectors (SQL, command, XSS, template)
|
|
37
|
-
- Auth bypass paths (missing checks, privilege escalation)
|
|
38
|
-
- Secrets exposure (logs, error messages, stack traces)
|
|
39
|
-
- Input trust boundaries (user input treated as safe)
|
|
40
|
-
- SSRF, path traversal, deserialization attacks
|
|
41
|
-
|
|
42
|
-
### False Assumptions
|
|
43
|
-
- "This will never be null" -- prove it can be
|
|
44
|
-
- "This list always has elements" -- find the empty case
|
|
45
|
-
- "Users always call A before B" -- find the out-of-order path
|
|
46
|
-
- "This config value exists" -- find the missing env var
|
|
47
|
-
- "This third-party API always returns 200" -- find the failure mode
|
|
48
|
-
- "This API shape won't change" -- find the breaking caller
|
|
49
|
-
|
|
50
|
-
### Failure Modes & Resource Exhaustion
|
|
51
|
-
- What happens when disk is full?
|
|
52
|
-
- What happens when network times out mid-operation?
|
|
53
|
-
- What happens when the database connection drops during a transaction?
|
|
54
|
-
- Unbounded allocations from user-controlled input
|
|
55
|
-
- Missing timeouts on external calls
|
|
56
|
-
- Event loop blocking (sync operations in async context)
|
|
57
|
-
- Connection/handle leaks on error paths
|
|
58
|
-
- Regex catastrophic backtracking (ReDoS)
|
|
59
|
-
|
|
60
|
-
### Race Conditions
|
|
61
|
-
- Shared mutable state without locks
|
|
62
|
-
- Time-of-check-to-time-of-use (TOCTOU)
|
|
63
|
-
- Async operations with implicit ordering assumptions
|
|
64
|
-
- Cache invalidation during concurrent writes
|
|
65
|
-
|
|
66
|
-
### Data Corruption
|
|
67
|
-
- Partial writes on failure (no transaction/rollback)
|
|
68
|
-
- Type coercion surprises (string "0" as falsy)
|
|
69
|
-
- Floating point comparison for equality
|
|
70
|
-
- Timezone-naive datetime operations
|
|
71
|
-
|
|
72
|
-
### Supply Chain & Dependencies
|
|
73
|
-
- New dependencies: postinstall scripts, maintainer reputation, bundle size
|
|
74
|
-
- Lockfile changes: version drift, removed integrity hashes
|
|
75
|
-
- Transitive deps pulling in known-vulnerable packages
|
|
76
|
-
|
|
77
|
-
### Observability Blind Spots
|
|
78
|
-
- Swallowed errors (`catch {}` with no log)
|
|
79
|
-
- Missing structured context in error logs
|
|
80
|
-
- PII in log output
|
|
81
|
-
|
|
82
|
-
## Process
|
|
83
|
-
|
|
84
|
-
### 1. Spawn Adversarial Reviewer
|
|
85
|
-
|
|
86
|
-
Dispatch `code-reviewer` subagent with adversarial prompt:
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
You are an adversarial code reviewer. Your ONLY job is to find ways this code
|
|
90
|
-
can fail, be exploited, or produce incorrect results.
|
|
91
|
-
|
|
92
|
-
DO NOT praise the code. DO NOT note what works well.
|
|
93
|
-
ONLY report problems. If you find nothing, say "No findings" -- but try harder first.
|
|
94
|
-
|
|
95
|
-
Focus on ADDED/MODIFIED lines (+ prefix in diff). Pre-existing code is out of scope
|
|
96
|
-
unless the change makes it newly exploitable.
|
|
97
|
-
|
|
98
|
-
Context (read for understanding, DO NOT review):
|
|
99
|
-
{CONTEXT_FILES}
|
|
100
|
-
|
|
101
|
-
Runtime: {RUNTIME} (e.g., Node.js single-threaded, browser, serverless)
|
|
102
|
-
Framework: {FRAMEWORK} (e.g., Express with global error handler at app.ts:45)
|
|
103
|
-
|
|
104
|
-
Review this diff:
|
|
105
|
-
{DIFF}
|
|
106
|
-
|
|
107
|
-
Changed files: {FILES}
|
|
108
|
-
|
|
109
|
-
Attack vectors to check:
|
|
110
|
-
1. Security holes (injection, auth bypass, secrets exposure)
|
|
111
|
-
2. False assumptions (null, empty, ordering, config, API contracts)
|
|
112
|
-
3. Failure modes + resource exhaustion (timeouts, leaks, unbounded input)
|
|
113
|
-
4. Race conditions (shared state, TOCTOU, async ordering)
|
|
114
|
-
5. Data corruption (partial writes, type coercion, encoding)
|
|
115
|
-
6. Supply chain (new deps, lockfile changes, transitive vulns)
|
|
116
|
-
7. Observability (swallowed errors, missing logs, PII in output)
|
|
117
|
-
|
|
118
|
-
For each finding, report:
|
|
119
|
-
- SEVERITY: Critical / Medium / Low
|
|
120
|
-
- CATEGORY: Security / Assumption / Failure / Race / Data / Supply / Observability
|
|
121
|
-
- LOCATION: file:line
|
|
122
|
-
- ATTACK: How to trigger the problem
|
|
123
|
-
- IMPACT: What happens when triggered
|
|
124
|
-
- FIX: Describe the fix approach (e.g., "add null check before line 42").
|
|
125
|
-
Do NOT write implementation code -- the implementer has full context.
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**If adversarial produces >10 findings on <100 lines changed:** likely too aggressive. Batch-reject noise, deep-review only Critical/Medium.
|
|
129
|
-
|
|
130
|
-
### 2. Adjudicate Findings
|
|
131
|
-
|
|
132
|
-
Main agent reviews each adversarial finding and assigns verdict:
|
|
133
|
-
|
|
134
|
-
| Verdict | Meaning | Action |
|
|
135
|
-
|---------|---------|--------|
|
|
136
|
-
| **Accept** | Valid flaw, reproducible or clearly reasoned | Must fix before merge |
|
|
137
|
-
| **Reject** | False positive, already handled, or impossible path | Document why, no action |
|
|
138
|
-
| **Defer** | Valid but low-risk, tracked for later | Create GitHub issue for tracking |
|
|
139
|
-
|
|
140
|
-
**Rules:**
|
|
141
|
-
- Every finding gets a verdict -- no silent dismissals
|
|
142
|
-
- Critical findings: Accept unless you can PROVE false positive
|
|
143
|
-
- Benefit of doubt goes to the adversary (safer to fix than to dismiss)
|
|
144
|
-
- If >50% of findings are Rejected, the adversary was too aggressive -- but still report all
|
|
145
|
-
|
|
146
|
-
**Calibration examples:**
|
|
147
|
-
|
|
148
|
-
| Verdict | Example | Reasoning |
|
|
149
|
-
|---------|---------|-----------|
|
|
150
|
-
| Accept | "SQL injection via string interpolation in query builder" | Clearly exploitable, concrete path shown |
|
|
151
|
-
| Reject | "Missing null check on config.apiUrl" | Config loaded at startup with schema validation (see config.ts:12), cannot be null at runtime |
|
|
152
|
-
| Defer | "No rate limiting on POST /api/upload" | Valid concern but internal-only tool currently; track for public exposure |
|
|
153
|
-
|
|
154
|
-
### 3. Report Format
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
## Adversarial Review -- Stage 3
|
|
158
|
-
|
|
159
|
-
### Summary
|
|
160
|
-
- Findings: N total (X Critical, Y Medium, Z Low)
|
|
161
|
-
- Accepted: A (must fix)
|
|
162
|
-
- Rejected: B (false positive)
|
|
163
|
-
- Deferred: C (tracked via GitHub issues)
|
|
164
|
-
|
|
165
|
-
### Accepted Findings (Must Fix)
|
|
166
|
-
|
|
167
|
-
#### [1] SEVERITY -- CATEGORY -- file:line
|
|
168
|
-
**Attack:** How to trigger
|
|
169
|
-
**Impact:** What happens
|
|
170
|
-
**Fix:** Approach description
|
|
171
|
-
**Verdict:** Accept -- [reason]
|
|
172
|
-
|
|
173
|
-
### Rejected Findings
|
|
174
|
-
|
|
175
|
-
#### [N] SEVERITY -- CATEGORY -- file:line
|
|
176
|
-
**Attack:** Claimed vector
|
|
177
|
-
**Verdict:** Reject -- [reason this is a false positive]
|
|
178
|
-
|
|
179
|
-
### Deferred Findings
|
|
180
|
-
|
|
181
|
-
#### [N] SEVERITY -- CATEGORY -- file:line
|
|
182
|
-
**Attack:** How to trigger
|
|
183
|
-
**Verdict:** Defer -- [reason] → GitHub issue #X
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### 4. Fix Accepted Findings
|
|
187
|
-
|
|
188
|
-
- Critical: Block merge. Fix immediately via `/fix` or manual edit.
|
|
189
|
-
- Medium: Fix before merge if feasible. Defer only with explicit user approval.
|
|
190
|
-
- Low: Track. Fix in follow-up if pattern repeats.
|
|
191
|
-
|
|
192
|
-
### Re-review Optimization
|
|
193
|
-
|
|
194
|
-
On fix cycles (re-running after accepted findings were fixed):
|
|
195
|
-
- Only pass the FIX diff to adversarial, not the full original diff
|
|
196
|
-
- Verify accepted findings are resolved
|
|
197
|
-
- Check for regression: did the fix introduce new issues?
|
|
198
|
-
|
|
199
|
-
## Integration with Pipeline
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
Stage 1 (Spec) → PASS
|
|
203
|
-
↓
|
|
204
|
-
Stage 2 (Quality) → PASS
|
|
205
|
-
↓
|
|
206
|
-
Scope gate → below threshold? → skip (note in report)
|
|
207
|
-
↓ (above threshold)
|
|
208
|
-
Stage 3 (Adversarial) → findings
|
|
209
|
-
├─ 0 Accepted → PASS → proceed
|
|
210
|
-
├─ Accepted Critical → BLOCK → fix → re-run Stage 3 (fix diff only)
|
|
211
|
-
└─ Accepted Medium/Low only → fix or defer → proceed
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**Task pipeline update:** When using task-managed reviews, adversarial review gets its own task between "Review implementation" and "Fix critical issues".
|
|
215
|
-
|
|
216
|
-
## What This Is NOT
|
|
217
|
-
|
|
218
|
-
- NOT a style review (Stage 2 handles that)
|
|
219
|
-
- NOT a spec compliance check (Stage 1 handles that)
|
|
220
|
-
- NOT dependency graph analysis or import tracing (scout handles that)
|
|
221
|
-
- NOT a general "suggestions for improvement" pass
|
|
222
|
-
|
|
223
|
-
This is a focused, hostile attempt to break the code. If the code survives, it's ready to ship.
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# {{CONTEXT_TITLE}}
|
|
2
|
-
|
|
3
|
-
<One line: the slice of the domain this context covers — the flow you crunched, in the expert's words.>
|
|
4
|
-
|
|
5
|
-
> Starter for a context that has **no `CONTEXT.md` yet**. It lives at the
|
|
6
|
-
> root folder as `CONTEXT.md`. If the context already has one, edit that — never a second.
|
|
7
|
-
|
|
8
|
-
## Language
|
|
9
|
-
|
|
10
|
-
The vocabulary of *this* context, crunched with the domain expert. Each entry must clear this bar:
|
|
11
|
-
|
|
12
|
-
- **One meaning.** A term denotes exactly one thing here. If it means two things, split it into two.
|
|
13
|
-
- **Defined in the expert's words**, present tense — never with implementation or vendor terms, and
|
|
14
|
-
never using the term to define itself.
|
|
15
|
-
- **Says what it is _not_** whenever it's easily confused with a neighbour — the sharpest
|
|
16
|
-
disambiguator there is.
|
|
17
|
-
- **Carries its governing rule** when one exists ("… finishes when …") — the language should imply the
|
|
18
|
-
behavior, not just label a noun.
|
|
19
|
-
- **Bound to code:** name the `TypeName` that embodies it. The type and the term are the same word.
|
|
20
|
-
- **`_Avoid_:` rejected synonyms** so the wrong word can't creep back (add a half-line *why* if it
|
|
21
|
-
isn't obvious).
|
|
22
|
-
|
|
23
|
-
Group related terms under `###` subsections. Reference other defined terms by their exact name.
|
|
24
|
-
|
|
25
|
-
Worked example of the bar (delete once you have your own):
|
|
26
|
-
|
|
27
|
-
### Connectivity
|
|
28
|
-
|
|
29
|
-
**Net**:
|
|
30
|
-
A conductor that carries one signal to every `Pin` connected to it; a signal crossing a `Net` counts as
|
|
31
|
-
one **hop**. _Not_ a physical wire segment — one `Net` may span many segments.
|
|
32
|
-
_Avoid_: wire, trace, connection
|
|
33
|
-
|
|
34
|
-
**Pin**:
|
|
35
|
-
A single connection point on a `ComponentInstance`. Belongs to exactly one `ComponentInstance` and
|
|
36
|
-
connects to exactly one `Net` — that one-to-one-to-one rule is an invariant.
|
|
37
|
-
_Avoid_: leg, terminal (terminal means the physical metal, not the model concept)
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
### <your first group>
|
|
42
|
-
|
|
43
|
-
**<Term>**:
|
|
44
|
-
<One sentence in the expert's words; fold in the governing rule if any, and what it is _not_ if it's
|
|
45
|
-
confusable; name the `TypeName` that embodies it.>
|
|
46
|
-
_Avoid_: <rejected synonyms>
|
|
47
|
-
|
|
48
|
-
## Deferred
|
|
49
|
-
|
|
50
|
-
Concepts that exist in the domain but this scenario doesn't need yet — distilled out, the way Evans
|
|
51
|
-
dropped `Topology` for the probe simulation. Bring one back only when a feature actually pulls it in.
|
|
52
|
-
|
|
53
|
-
- **<Term>** — <what it is; why it isn't needed yet>
|
|
54
|
-
|
|
55
|
-
## Flagged ambiguities
|
|
56
|
-
|
|
57
|
-
Open questions or contradictions between experts, to resolve in a later loop.
|
|
58
|
-
|
|
59
|
-
- <the question — and who or what would settle it>
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# The Crunching Dialogue
|
|
2
|
-
|
|
3
|
-
How to run Step 4's per-concept loop well: the kinds of questions that actually move the model, and
|
|
4
|
-
the full PCB session translated from Evans' diagrams into the code/test/glossary this skill produces.
|
|
5
|
-
|
|
6
|
-
> The model fragments below are written in **language-neutral pseudocode** so the modeling moves stay
|
|
7
|
-
> the point. In a real session, write them as actual runnable types and tests in the bounded context's
|
|
8
|
-
> own language and test framework.
|
|
9
|
-
|
|
10
|
-
## Verifying-question catalog
|
|
11
|
-
|
|
12
|
-
Each loop turn asks **one** question whose answer would change the code if your guess is wrong. Pick
|
|
13
|
-
the type that fits the fragment you just proposed. A good question is falsifiable, concrete, and
|
|
14
|
-
answerable in a sentence — not "does this look right?"
|
|
15
|
-
|
|
16
|
-
| Type | What it pins down | Template | PCB example |
|
|
17
|
-
|---|---|---|---|
|
|
18
|
-
| **Cardinality** | how many relate to how many | "Does one X belong to exactly one Y, or many?" | "A `Pin` belongs to one `ComponentInstance` and one `Net`?" |
|
|
19
|
-
| **Synonym** | two words, one concept | "Are X and Y the same thing?" | "Is `ref-des` the same as `component instance`?" |
|
|
20
|
-
| **Ownership of behavior** | which object does the work | "What pushes the signal — X or Y?" | "Does the `Net` carry the signal further, or does the component push it?" |
|
|
21
|
-
| **Exclusion / relevance** | is this concept needed *now* | "Does X matter for this scenario?" | "Does `Topology` come into the probe simulation?" |
|
|
22
|
-
| **Simplification** | how little can we model | "Is a simplified Z enough instead of full X?" | "Can a list of push-throughs stand in for chip internals?" |
|
|
23
|
-
| **Computation goal** | what the output must be | "What exactly do you need from this?" | "What are we looking for — paths longer than 2–3 hops?" |
|
|
24
|
-
| **Definition of a unit** | what one increment is | "What counts as one X?" | "What counts as one hop?" |
|
|
25
|
-
| **Lifetime / sameness** | shared vs per-instance data | "Is this the same for every instance, or per instance?" | "Are the pushes the same for all instances of a component?" |
|
|
26
|
-
|
|
27
|
-
Rules of thumb:
|
|
28
|
-
- If you can't think of a question, you don't understand the fragment well enough to code it — go
|
|
29
|
-
smaller.
|
|
30
|
-
- Prefer a question that could get a "no." A question that can only be answered "yes" teaches nothing.
|
|
31
|
-
- After a "no," restate the corrected understanding before moving on, so the correction is shared.
|
|
32
|
-
|
|
33
|
-
## The PCB session, translated to code
|
|
34
|
-
|
|
35
|
-
Evans drew object-interaction and class diagrams. This skill produces the same model as code + tests +
|
|
36
|
-
glossary. Below, each beat of the original dialogue maps to what you would actually write.
|
|
37
|
-
|
|
38
|
-
### Beat 1 — the glimmer ("nets")
|
|
39
|
-
The experts kept asking for reports about *nets*. That recurring noun, not their "read a file and
|
|
40
|
-
sort it" framing, was the first model element. You name it back and ask a cardinality question rather
|
|
41
|
-
than scaffolding a type immediately.
|
|
42
|
-
|
|
43
|
-
> "A `Net` is a conductor that connects components and carries a signal to everything on it — yes?"
|
|
44
|
-
|
|
45
|
-
### Beat 2 — reconcile terminology, fix cardinality
|
|
46
|
-
"Component" vs "component instance" vs "ref-des" collide. You reconcile them (synonym question), then
|
|
47
|
-
pin the pin↔instance↔net cardinality (cardinality question). Only once confirmed do you write:
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
ComponentInstance // expert's "ref-des" — reconciled to one name
|
|
51
|
-
pins -> read-only list of Pin
|
|
52
|
-
|
|
53
|
-
Pin
|
|
54
|
-
owner -> ComponentInstance // exactly one (confirmed)
|
|
55
|
-
net -> Net (optional) // exactly one (confirmed)
|
|
56
|
-
|
|
57
|
-
Net
|
|
58
|
-
pins -> read-only list of Pin // connects many pins
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Beat 3 — narrow to one scenario (probe simulation)
|
|
62
|
-
You drop everything not needed to simulate a signal. You ask the *ownership* question and learn the
|
|
63
|
-
**component pushes the signal through** — the `Net` does not do it alone.
|
|
64
|
-
|
|
65
|
-
### Beat 4 — simplify what you can't model
|
|
66
|
-
You can't model chip internals; you ask the *simplification* question and the expert offers
|
|
67
|
-
"push-throughs": a list of (fromPin → toPin) for a component **type** (not per instance — that's the
|
|
68
|
-
lifetime question). The behavior, driven by a test:
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
test "signal propagates through pushes and across nets":
|
|
72
|
-
// arrange a tiny board: in-pin → component pushes to out-pin → net to next component
|
|
73
|
-
hops = simulation.probe(startPin)
|
|
74
|
-
assert hops == 2 // each Net crossing counts as one hop
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Beat 5 — pin the computation goal and the unit
|
|
78
|
-
The *computation-goal* question yields the rule: flag any signal path longer than 2–3 hops. The
|
|
79
|
-
*unit* question yields: **one hop = one Net crossing.** So the `Net` increments the hop count as the
|
|
80
|
-
signal passes:
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
Net
|
|
84
|
-
carry(hopsSoFar) -> hopsSoFar + 1 // crossing this Net is one hop
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Beat 6 — distill: drop `Topology`
|
|
88
|
-
`Topology` exists in the domain but isn't used by the probe simulation, so you explicitly leave it
|
|
89
|
-
out ("I'll drop it for now; we'll bring it back for routing"). The model is a distillation, not a
|
|
90
|
-
transcription — it excludes the hundreds of facts the engineers know but this problem doesn't need.
|
|
91
|
-
|
|
92
|
-
## What "on the same page" looks like at the end of a loop
|
|
93
|
-
|
|
94
|
-
A loop turn is complete only when **all three** agree:
|
|
95
|
-
1. the **expert** has answered the verifying question,
|
|
96
|
-
2. the **code** (type/method/test) reflects that answer, and
|
|
97
|
-
3. the **`CONTEXT.md` `## Language`** records the term, its definition in their words, the rejected
|
|
98
|
-
synonyms (`_Avoid_:`), and the `TypeName` that embodies it.
|
|
99
|
-
|
|
100
|
-
If any of the three lags, close the gap before proposing the next concept.
|
|
101
|
-
|
|
102
|
-
## Drift triggers in existing code
|
|
103
|
-
|
|
104
|
-
When the module's domain layer already has a model, read it against the language and let each mismatch
|
|
105
|
-
become a verifying-question loop turn — surface it, verify with the user, then change code +
|
|
106
|
-
`CONTEXT.md` together:
|
|
107
|
-
|
|
108
|
-
- **Synonym drift** — code says `Learner`, experts now say `Student`. Reconcile, pick one, record the
|
|
109
|
-
rejected synonym under `_Avoid_:`.
|
|
110
|
-
- **Conflated concept** — one type doing two jobs the experts name separately → candidate split.
|
|
111
|
-
- **Leaked invariant** — a rule enforced in a service/controller that an aggregate should own.
|
|
112
|
-
- **Dead concept** — a type no scenario exercises anymore → deprecate (move to `CONTEXT.md`'s
|
|
113
|
-
`## Deferred` with the reason).
|
/package/template/.claude/hooks/{usage-context-awareness.cjs → usage-quota-cache-refresh.cjs}
RENAMED
|
File without changes
|