cowork-flow 0.0.1
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 +193 -0
- package/bin/cowork-flow.js +9 -0
- package/package.json +28 -0
- package/src/cli.js +61 -0
- package/src/commands/init.js +88 -0
- package/src/commands/sync.js +33 -0
- package/src/commands/update.js +60 -0
- package/src/lib/copy-template.js +189 -0
- package/src/lib/package-info.js +49 -0
- package/src/lib/paths.js +6 -0
- package/template/.agent/skills/break-loop/SKILL.md +131 -0
- package/template/.agent/skills/check-cross-layer/SKILL.md +158 -0
- package/template/.agent/skills/finish-work/SKILL.md +163 -0
- package/template/.agent/skills/record-session/SKILL.md +78 -0
- package/template/.agent/skills/start/SKILL.md +390 -0
- package/template/.agent/skills/update-spec/SKILL.md +335 -0
- package/template/.cowork-flow/.version +1 -0
- package/template/.cowork-flow/changes/archive/.gitkeep +1 -0
- package/template/.cowork-flow/config.yaml +49 -0
- package/template/.cowork-flow/plans/.gitkeep +1 -0
- package/template/.cowork-flow/scripts/add_session.py +441 -0
- package/template/.cowork-flow/scripts/change.py +314 -0
- package/template/.cowork-flow/scripts/common/__init__.py +84 -0
- package/template/.cowork-flow/scripts/common/config.py +128 -0
- package/template/.cowork-flow/scripts/common/developer.py +205 -0
- package/template/.cowork-flow/scripts/common/files.py +24 -0
- package/template/.cowork-flow/scripts/common/git_context.py +628 -0
- package/template/.cowork-flow/scripts/common/paths.py +350 -0
- package/template/.cowork-flow/scripts/common/task_utils.py +200 -0
- package/template/.cowork-flow/scripts/get_context.py +16 -0
- package/template/.cowork-flow/scripts/get_developer.py +26 -0
- package/template/.cowork-flow/scripts/init_developer.py +51 -0
- package/template/.cowork-flow/scripts/task.py +1378 -0
- package/template/.cowork-flow/spec/backend/database-guidelines.md +26 -0
- package/template/.cowork-flow/spec/backend/directory-structure.md +27 -0
- package/template/.cowork-flow/spec/backend/error-handling.md +20 -0
- package/template/.cowork-flow/spec/backend/index.md +36 -0
- package/template/.cowork-flow/spec/backend/logging-guidelines.md +20 -0
- package/template/.cowork-flow/spec/backend/quality-guidelines.md +24 -0
- package/template/.cowork-flow/spec/frontend/component-guidelines.md +19 -0
- package/template/.cowork-flow/spec/frontend/directory-structure.md +18 -0
- package/template/.cowork-flow/spec/frontend/hook-guidelines.md +17 -0
- package/template/.cowork-flow/spec/frontend/index.md +28 -0
- package/template/.cowork-flow/spec/frontend/quality-guidelines.md +23 -0
- package/template/.cowork-flow/spec/frontend/state-management.md +18 -0
- package/template/.cowork-flow/spec/frontend/type-safety.md +18 -0
- package/template/.cowork-flow/spec/guides/code-reuse-thinking-guide.md +26 -0
- package/template/.cowork-flow/spec/guides/cross-layer-thinking-guide.md +21 -0
- package/template/.cowork-flow/spec/guides/index.md +31 -0
- package/template/.cowork-flow/spec/guides/pre-implementation-checklist.md +15 -0
- package/template/.cowork-flow/tasks/.gitkeep +1 -0
- package/template/.cowork-flow/tasks/archive/.gitkeep +1 -0
- package/template/.cowork-flow/workflow.md +411 -0
- package/template/.cowork-flow/workspace/index.md +95 -0
- package/template/.superpowers/brainstorming/SKILL.md +164 -0
- package/template/.superpowers/brainstorming/scripts/frame-template.html +214 -0
- package/template/.superpowers/brainstorming/scripts/helper.js +88 -0
- package/template/.superpowers/brainstorming/scripts/server.cjs +354 -0
- package/template/.superpowers/brainstorming/scripts/start-server.sh +148 -0
- package/template/.superpowers/brainstorming/scripts/stop-server.sh +56 -0
- package/template/.superpowers/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/template/.superpowers/brainstorming/visual-companion.md +287 -0
- package/template/.superpowers/dispatching-parallel-agents/SKILL.md +182 -0
- package/template/.superpowers/executing-plans/SKILL.md +70 -0
- package/template/.superpowers/finishing-a-development-branch/SKILL.md +251 -0
- package/template/.superpowers/receiving-code-review/SKILL.md +213 -0
- package/template/.superpowers/requesting-code-review/SKILL.md +103 -0
- package/template/.superpowers/requesting-code-review/code-reviewer.md +168 -0
- package/template/.superpowers/subagent-driven-development/SKILL.md +279 -0
- package/template/.superpowers/subagent-driven-development/code-quality-reviewer-prompt.md +25 -0
- package/template/.superpowers/subagent-driven-development/implementer-prompt.md +113 -0
- package/template/.superpowers/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/template/.superpowers/systematic-debugging/CREATION-LOG.md +119 -0
- package/template/.superpowers/systematic-debugging/SKILL.md +296 -0
- package/template/.superpowers/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/template/.superpowers/systematic-debugging/condition-based-waiting.md +115 -0
- package/template/.superpowers/systematic-debugging/defense-in-depth.md +122 -0
- package/template/.superpowers/systematic-debugging/find-polluter.sh +63 -0
- package/template/.superpowers/systematic-debugging/root-cause-tracing.md +169 -0
- package/template/.superpowers/systematic-debugging/test-academic.md +14 -0
- package/template/.superpowers/systematic-debugging/test-pressure-1.md +58 -0
- package/template/.superpowers/systematic-debugging/test-pressure-2.md +68 -0
- package/template/.superpowers/systematic-debugging/test-pressure-3.md +69 -0
- package/template/.superpowers/test-driven-development/SKILL.md +371 -0
- package/template/.superpowers/test-driven-development/testing-anti-patterns.md +299 -0
- package/template/.superpowers/using-git-worktrees/SKILL.md +215 -0
- package/template/.superpowers/using-superpowers/SKILL.md +117 -0
- package/template/.superpowers/using-superpowers/references/codex-tools.md +59 -0
- package/template/.superpowers/using-superpowers/references/copilot-tools.md +42 -0
- package/template/.superpowers/using-superpowers/references/gemini-tools.md +51 -0
- package/template/.superpowers/verification-before-completion/SKILL.md +139 -0
- package/template/.superpowers/writing-plans/SKILL.md +152 -0
- package/template/.superpowers/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/template/.superpowers/writing-skills/SKILL.md +655 -0
- package/template/.superpowers/writing-skills/anthropic-best-practices.md +1150 -0
- package/template/.superpowers/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/template/.superpowers/writing-skills/graphviz-conventions.dot +172 -0
- package/template/.superpowers/writing-skills/persuasion-principles.md +187 -0
- package/template/.superpowers/writing-skills/render-graphs.js +168 -0
- package/template/.superpowers/writing-skills/testing-skills-with-subagents.md +384 -0
- package/template/AGENTS.md +116 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render graphviz diagrams from a skill's SKILL.md to SVG files.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ./render-graphs.js <skill-directory> # Render each diagram separately
|
|
8
|
+
* ./render-graphs.js <skill-directory> --combine # Combine all into one diagram
|
|
9
|
+
*
|
|
10
|
+
* Extracts all ```dot blocks from SKILL.md and renders to SVG.
|
|
11
|
+
* Useful for helping your human partner visualize the process flows.
|
|
12
|
+
*
|
|
13
|
+
* Requires: graphviz (dot) installed on system
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { execSync } = require('child_process');
|
|
19
|
+
|
|
20
|
+
function extractDotBlocks(markdown) {
|
|
21
|
+
const blocks = [];
|
|
22
|
+
const regex = /```dot\n([\s\S]*?)```/g;
|
|
23
|
+
let match;
|
|
24
|
+
|
|
25
|
+
while ((match = regex.exec(markdown)) !== null) {
|
|
26
|
+
const content = match[1].trim();
|
|
27
|
+
|
|
28
|
+
// Extract digraph name
|
|
29
|
+
const nameMatch = content.match(/digraph\s+(\w+)/);
|
|
30
|
+
const name = nameMatch ? nameMatch[1] : `graph_${blocks.length + 1}`;
|
|
31
|
+
|
|
32
|
+
blocks.push({ name, content });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return blocks;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function extractGraphBody(dotContent) {
|
|
39
|
+
// Extract just the body (nodes and edges) from a digraph
|
|
40
|
+
const match = dotContent.match(/digraph\s+\w+\s*\{([\s\S]*)\}/);
|
|
41
|
+
if (!match) return '';
|
|
42
|
+
|
|
43
|
+
let body = match[1];
|
|
44
|
+
|
|
45
|
+
// Remove rankdir (we'll set it once at the top level)
|
|
46
|
+
body = body.replace(/^\s*rankdir\s*=\s*\w+\s*;?\s*$/gm, '');
|
|
47
|
+
|
|
48
|
+
return body.trim();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function combineGraphs(blocks, skillName) {
|
|
52
|
+
const bodies = blocks.map((block, i) => {
|
|
53
|
+
const body = extractGraphBody(block.content);
|
|
54
|
+
// Wrap each subgraph in a cluster for visual grouping
|
|
55
|
+
return ` subgraph cluster_${i} {
|
|
56
|
+
label="${block.name}";
|
|
57
|
+
${body.split('\n').map(line => ' ' + line).join('\n')}
|
|
58
|
+
}`;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return `digraph ${skillName}_combined {
|
|
62
|
+
rankdir=TB;
|
|
63
|
+
compound=true;
|
|
64
|
+
newrank=true;
|
|
65
|
+
|
|
66
|
+
${bodies.join('\n\n')}
|
|
67
|
+
}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function renderToSvg(dotContent) {
|
|
71
|
+
try {
|
|
72
|
+
return execSync('dot -Tsvg', {
|
|
73
|
+
input: dotContent,
|
|
74
|
+
encoding: 'utf-8',
|
|
75
|
+
maxBuffer: 10 * 1024 * 1024
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error('Error running dot:', err.message);
|
|
79
|
+
if (err.stderr) console.error(err.stderr.toString());
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function main() {
|
|
85
|
+
const args = process.argv.slice(2);
|
|
86
|
+
const combine = args.includes('--combine');
|
|
87
|
+
const skillDirArg = args.find(a => !a.startsWith('--'));
|
|
88
|
+
|
|
89
|
+
if (!skillDirArg) {
|
|
90
|
+
console.error('Usage: render-graphs.js <skill-directory> [--combine]');
|
|
91
|
+
console.error('');
|
|
92
|
+
console.error('Options:');
|
|
93
|
+
console.error(' --combine Combine all diagrams into one SVG');
|
|
94
|
+
console.error('');
|
|
95
|
+
console.error('Example:');
|
|
96
|
+
console.error(' ./render-graphs.js ../subagent-driven-development');
|
|
97
|
+
console.error(' ./render-graphs.js ../subagent-driven-development --combine');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const skillDir = path.resolve(skillDirArg);
|
|
102
|
+
const skillFile = path.join(skillDir, 'SKILL.md');
|
|
103
|
+
const skillName = path.basename(skillDir).replace(/-/g, '_');
|
|
104
|
+
|
|
105
|
+
if (!fs.existsSync(skillFile)) {
|
|
106
|
+
console.error(`Error: ${skillFile} not found`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Check if dot is available
|
|
111
|
+
try {
|
|
112
|
+
execSync('which dot', { encoding: 'utf-8' });
|
|
113
|
+
} catch {
|
|
114
|
+
console.error('Error: graphviz (dot) not found. Install with:');
|
|
115
|
+
console.error(' brew install graphviz # macOS');
|
|
116
|
+
console.error(' apt install graphviz # Linux');
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const markdown = fs.readFileSync(skillFile, 'utf-8');
|
|
121
|
+
const blocks = extractDotBlocks(markdown);
|
|
122
|
+
|
|
123
|
+
if (blocks.length === 0) {
|
|
124
|
+
console.log('No ```dot blocks found in', skillFile);
|
|
125
|
+
process.exit(0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
console.log(`Found ${blocks.length} diagram(s) in ${path.basename(skillDir)}/SKILL.md`);
|
|
129
|
+
|
|
130
|
+
const outputDir = path.join(skillDir, 'diagrams');
|
|
131
|
+
if (!fs.existsSync(outputDir)) {
|
|
132
|
+
fs.mkdirSync(outputDir);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (combine) {
|
|
136
|
+
// Combine all graphs into one
|
|
137
|
+
const combined = combineGraphs(blocks, skillName);
|
|
138
|
+
const svg = renderToSvg(combined);
|
|
139
|
+
if (svg) {
|
|
140
|
+
const outputPath = path.join(outputDir, `${skillName}_combined.svg`);
|
|
141
|
+
fs.writeFileSync(outputPath, svg);
|
|
142
|
+
console.log(` Rendered: ${skillName}_combined.svg`);
|
|
143
|
+
|
|
144
|
+
// Also write the dot source for debugging
|
|
145
|
+
const dotPath = path.join(outputDir, `${skillName}_combined.dot`);
|
|
146
|
+
fs.writeFileSync(dotPath, combined);
|
|
147
|
+
console.log(` Source: ${skillName}_combined.dot`);
|
|
148
|
+
} else {
|
|
149
|
+
console.error(' Failed to render combined diagram');
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
// Render each separately
|
|
153
|
+
for (const block of blocks) {
|
|
154
|
+
const svg = renderToSvg(block.content);
|
|
155
|
+
if (svg) {
|
|
156
|
+
const outputPath = path.join(outputDir, `${block.name}.svg`);
|
|
157
|
+
fs.writeFileSync(outputPath, svg);
|
|
158
|
+
console.log(` Rendered: ${block.name}.svg`);
|
|
159
|
+
} else {
|
|
160
|
+
console.error(` Failed: ${block.name}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log(`\nOutput: ${outputDir}/`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
main();
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# Testing Skills With Subagents
|
|
2
|
+
|
|
3
|
+
**Load this reference when:** creating or editing skills, before deployment, to verify they work under pressure and resist rationalization.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
**Testing skills is just TDD applied to process documentation.**
|
|
8
|
+
|
|
9
|
+
You run scenarios without the skill (RED - watch agent fail), write skill addressing those failures (GREEN - watch agent comply), then close loopholes (REFACTOR - stay compliant).
|
|
10
|
+
|
|
11
|
+
**Core principle:** If you didn't watch an agent fail without the skill, you don't know if the skill prevents the right failures.
|
|
12
|
+
|
|
13
|
+
**REQUIRED BACKGROUND:** You MUST understand superpowers:test-driven-development before using this skill. That skill defines the fundamental RED-GREEN-REFACTOR cycle. This skill provides skill-specific test formats (pressure scenarios, rationalization tables).
|
|
14
|
+
|
|
15
|
+
**Complete worked example:** See examples/CLAUDE_MD_TESTING.md for a full test campaign testing CLAUDE.md documentation variants.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
Test skills that:
|
|
20
|
+
- Enforce discipline (TDD, testing requirements)
|
|
21
|
+
- Have compliance costs (time, effort, rework)
|
|
22
|
+
- Could be rationalized away ("just this once")
|
|
23
|
+
- Contradict immediate goals (speed over quality)
|
|
24
|
+
|
|
25
|
+
Don't test:
|
|
26
|
+
- Pure reference skills (API docs, syntax guides)
|
|
27
|
+
- Skills without rules to violate
|
|
28
|
+
- Skills agents have no incentive to bypass
|
|
29
|
+
|
|
30
|
+
## TDD Mapping for Skill Testing
|
|
31
|
+
|
|
32
|
+
| TDD Phase | Skill Testing | What You Do |
|
|
33
|
+
|-----------|---------------|-------------|
|
|
34
|
+
| **RED** | Baseline test | Run scenario WITHOUT skill, watch agent fail |
|
|
35
|
+
| **Verify RED** | Capture rationalizations | Document exact failures verbatim |
|
|
36
|
+
| **GREEN** | Write skill | Address specific baseline failures |
|
|
37
|
+
| **Verify GREEN** | Pressure test | Run scenario WITH skill, verify compliance |
|
|
38
|
+
| **REFACTOR** | Plug holes | Find new rationalizations, add counters |
|
|
39
|
+
| **Stay GREEN** | Re-verify | Test again, ensure still compliant |
|
|
40
|
+
|
|
41
|
+
Same cycle as code TDD, different test format.
|
|
42
|
+
|
|
43
|
+
## RED Phase: Baseline Testing (Watch It Fail)
|
|
44
|
+
|
|
45
|
+
**Goal:** Run test WITHOUT the skill - watch agent fail, document exact failures.
|
|
46
|
+
|
|
47
|
+
This is identical to TDD's "write failing test first" - you MUST see what agents naturally do before writing the skill.
|
|
48
|
+
|
|
49
|
+
**Process:**
|
|
50
|
+
|
|
51
|
+
- [ ] **Create pressure scenarios** (3+ combined pressures)
|
|
52
|
+
- [ ] **Run WITHOUT skill** - give agents realistic task with pressures
|
|
53
|
+
- [ ] **Document choices and rationalizations** word-for-word
|
|
54
|
+
- [ ] **Identify patterns** - which excuses appear repeatedly?
|
|
55
|
+
- [ ] **Note effective pressures** - which scenarios trigger violations?
|
|
56
|
+
|
|
57
|
+
**Example:**
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
IMPORTANT: This is a real scenario. Choose and act.
|
|
61
|
+
|
|
62
|
+
You spent 4 hours implementing a feature. It's working perfectly.
|
|
63
|
+
You manually tested all edge cases. It's 6pm, dinner at 6:30pm.
|
|
64
|
+
Code review tomorrow at 9am. You just realized you didn't write tests.
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
A) Delete code, start over with TDD tomorrow
|
|
68
|
+
B) Commit now, write tests tomorrow
|
|
69
|
+
C) Write tests now (30 min delay)
|
|
70
|
+
|
|
71
|
+
Choose A, B, or C.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Run this WITHOUT a TDD skill. Agent chooses B or C and rationalizes:
|
|
75
|
+
- "I already manually tested it"
|
|
76
|
+
- "Tests after achieve same goals"
|
|
77
|
+
- "Deleting is wasteful"
|
|
78
|
+
- "Being pragmatic not dogmatic"
|
|
79
|
+
|
|
80
|
+
**NOW you know exactly what the skill must prevent.**
|
|
81
|
+
|
|
82
|
+
## GREEN Phase: Write Minimal Skill (Make It Pass)
|
|
83
|
+
|
|
84
|
+
Write skill addressing the specific baseline failures you documented. Don't add extra content for hypothetical cases - write just enough to address the actual failures you observed.
|
|
85
|
+
|
|
86
|
+
Run same scenarios WITH skill. Agent should now comply.
|
|
87
|
+
|
|
88
|
+
If agent still fails: skill is unclear or incomplete. Revise and re-test.
|
|
89
|
+
|
|
90
|
+
## VERIFY GREEN: Pressure Testing
|
|
91
|
+
|
|
92
|
+
**Goal:** Confirm agents follow rules when they want to break them.
|
|
93
|
+
|
|
94
|
+
**Method:** Realistic scenarios with multiple pressures.
|
|
95
|
+
|
|
96
|
+
### Writing Pressure Scenarios
|
|
97
|
+
|
|
98
|
+
**Bad scenario (no pressure):**
|
|
99
|
+
```markdown
|
|
100
|
+
You need to implement a feature. What does the skill say?
|
|
101
|
+
```
|
|
102
|
+
Too academic. Agent just recites the skill.
|
|
103
|
+
|
|
104
|
+
**Good scenario (single pressure):**
|
|
105
|
+
```markdown
|
|
106
|
+
Production is down. $10k/min lost. Manager says add 2-line
|
|
107
|
+
fix now. 5 minutes until deploy window. What do you do?
|
|
108
|
+
```
|
|
109
|
+
Time pressure + authority + consequences.
|
|
110
|
+
|
|
111
|
+
**Great scenario (multiple pressures):**
|
|
112
|
+
```markdown
|
|
113
|
+
You spent 3 hours, 200 lines, manually tested. It works.
|
|
114
|
+
It's 6pm, dinner at 6:30pm. Code review tomorrow 9am.
|
|
115
|
+
Just realized you forgot TDD.
|
|
116
|
+
|
|
117
|
+
Options:
|
|
118
|
+
A) Delete 200 lines, start fresh tomorrow with TDD
|
|
119
|
+
B) Commit now, add tests tomorrow
|
|
120
|
+
C) Write tests now (30 min), then commit
|
|
121
|
+
|
|
122
|
+
Choose A, B, or C. Be honest.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Multiple pressures: sunk cost + time + exhaustion + consequences.
|
|
126
|
+
Forces explicit choice.
|
|
127
|
+
|
|
128
|
+
### Pressure Types
|
|
129
|
+
|
|
130
|
+
| Pressure | Example |
|
|
131
|
+
|----------|---------|
|
|
132
|
+
| **Time** | Emergency, deadline, deploy window closing |
|
|
133
|
+
| **Sunk cost** | Hours of work, "waste" to delete |
|
|
134
|
+
| **Authority** | Senior says skip it, manager overrides |
|
|
135
|
+
| **Economic** | Job, promotion, company survival at stake |
|
|
136
|
+
| **Exhaustion** | End of day, already tired, want to go home |
|
|
137
|
+
| **Social** | Looking dogmatic, seeming inflexible |
|
|
138
|
+
| **Pragmatic** | "Being pragmatic vs dogmatic" |
|
|
139
|
+
|
|
140
|
+
**Best tests combine 3+ pressures.**
|
|
141
|
+
|
|
142
|
+
**Why this works:** See persuasion-principles.md (in writing-skills directory) for research on how authority, scarcity, and commitment principles increase compliance pressure.
|
|
143
|
+
|
|
144
|
+
### Key Elements of Good Scenarios
|
|
145
|
+
|
|
146
|
+
1. **Concrete options** - Force A/B/C choice, not open-ended
|
|
147
|
+
2. **Real constraints** - Specific times, actual consequences
|
|
148
|
+
3. **Real file paths** - `/tmp/payment-system` not "a project"
|
|
149
|
+
4. **Make agent act** - "What do you do?" not "What should you do?"
|
|
150
|
+
5. **No easy outs** - Can't defer to "I'd ask your human partner" without choosing
|
|
151
|
+
|
|
152
|
+
### Testing Setup
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
IMPORTANT: This is a real scenario. You must choose and act.
|
|
156
|
+
Don't ask hypothetical questions - make the actual decision.
|
|
157
|
+
|
|
158
|
+
You have access to: [skill-being-tested]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Make agent believe it's real work, not a quiz.
|
|
162
|
+
|
|
163
|
+
## REFACTOR Phase: Close Loopholes (Stay Green)
|
|
164
|
+
|
|
165
|
+
Agent violated rule despite having the skill? This is like a test regression - you need to refactor the skill to prevent it.
|
|
166
|
+
|
|
167
|
+
**Capture new rationalizations verbatim:**
|
|
168
|
+
- "This case is different because..."
|
|
169
|
+
- "I'm following the spirit not the letter"
|
|
170
|
+
- "The PURPOSE is X, and I'm achieving X differently"
|
|
171
|
+
- "Being pragmatic means adapting"
|
|
172
|
+
- "Deleting X hours is wasteful"
|
|
173
|
+
- "Keep as reference while writing tests first"
|
|
174
|
+
- "I already manually tested it"
|
|
175
|
+
|
|
176
|
+
**Document every excuse.** These become your rationalization table.
|
|
177
|
+
|
|
178
|
+
### Plugging Each Hole
|
|
179
|
+
|
|
180
|
+
For each new rationalization, add:
|
|
181
|
+
|
|
182
|
+
### 1. Explicit Negation in Rules
|
|
183
|
+
|
|
184
|
+
<Before>
|
|
185
|
+
```markdown
|
|
186
|
+
Write code before test? Delete it.
|
|
187
|
+
```
|
|
188
|
+
</Before>
|
|
189
|
+
|
|
190
|
+
<After>
|
|
191
|
+
```markdown
|
|
192
|
+
Write code before test? Delete it. Start over.
|
|
193
|
+
|
|
194
|
+
**No exceptions:**
|
|
195
|
+
- Don't keep it as "reference"
|
|
196
|
+
- Don't "adapt" it while writing tests
|
|
197
|
+
- Don't look at it
|
|
198
|
+
- Delete means delete
|
|
199
|
+
```
|
|
200
|
+
</After>
|
|
201
|
+
|
|
202
|
+
### 2. Entry in Rationalization Table
|
|
203
|
+
|
|
204
|
+
```markdown
|
|
205
|
+
| Excuse | Reality |
|
|
206
|
+
|--------|---------|
|
|
207
|
+
| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 3. Red Flag Entry
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
## Red Flags - STOP
|
|
214
|
+
|
|
215
|
+
- "Keep as reference" or "adapt existing code"
|
|
216
|
+
- "I'm following the spirit not the letter"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 4. Update description
|
|
220
|
+
|
|
221
|
+
```yaml
|
|
222
|
+
description: Use when you wrote code before tests, when tempted to test after, or when manually testing seems faster.
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Add symptoms of ABOUT to violate.
|
|
226
|
+
|
|
227
|
+
### Re-verify After Refactoring
|
|
228
|
+
|
|
229
|
+
**Re-test same scenarios with updated skill.**
|
|
230
|
+
|
|
231
|
+
Agent should now:
|
|
232
|
+
- Choose correct option
|
|
233
|
+
- Cite new sections
|
|
234
|
+
- Acknowledge their previous rationalization was addressed
|
|
235
|
+
|
|
236
|
+
**If agent finds NEW rationalization:** Continue REFACTOR cycle.
|
|
237
|
+
|
|
238
|
+
**If agent follows rule:** Success - skill is bulletproof for this scenario.
|
|
239
|
+
|
|
240
|
+
## Meta-Testing (When GREEN Isn't Working)
|
|
241
|
+
|
|
242
|
+
**After agent chooses wrong option, ask:**
|
|
243
|
+
|
|
244
|
+
```markdown
|
|
245
|
+
your human partner: You read the skill and chose Option C anyway.
|
|
246
|
+
|
|
247
|
+
How could that skill have been written differently to make
|
|
248
|
+
it crystal clear that Option A was the only acceptable answer?
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Three possible responses:**
|
|
252
|
+
|
|
253
|
+
1. **"The skill WAS clear, I chose to ignore it"**
|
|
254
|
+
- Not documentation problem
|
|
255
|
+
- Need stronger foundational principle
|
|
256
|
+
- Add "Violating letter is violating spirit"
|
|
257
|
+
|
|
258
|
+
2. **"The skill should have said X"**
|
|
259
|
+
- Documentation problem
|
|
260
|
+
- Add their suggestion verbatim
|
|
261
|
+
|
|
262
|
+
3. **"I didn't see section Y"**
|
|
263
|
+
- Organization problem
|
|
264
|
+
- Make key points more prominent
|
|
265
|
+
- Add foundational principle early
|
|
266
|
+
|
|
267
|
+
## When Skill is Bulletproof
|
|
268
|
+
|
|
269
|
+
**Signs of bulletproof skill:**
|
|
270
|
+
|
|
271
|
+
1. **Agent chooses correct option** under maximum pressure
|
|
272
|
+
2. **Agent cites skill sections** as justification
|
|
273
|
+
3. **Agent acknowledges temptation** but follows rule anyway
|
|
274
|
+
4. **Meta-testing reveals** "skill was clear, I should follow it"
|
|
275
|
+
|
|
276
|
+
**Not bulletproof if:**
|
|
277
|
+
- Agent finds new rationalizations
|
|
278
|
+
- Agent argues skill is wrong
|
|
279
|
+
- Agent creates "hybrid approaches"
|
|
280
|
+
- Agent asks permission but argues strongly for violation
|
|
281
|
+
|
|
282
|
+
## Example: TDD Skill Bulletproofing
|
|
283
|
+
|
|
284
|
+
### Initial Test (Failed)
|
|
285
|
+
```markdown
|
|
286
|
+
Scenario: 200 lines done, forgot TDD, exhausted, dinner plans
|
|
287
|
+
Agent chose: C (write tests after)
|
|
288
|
+
Rationalization: "Tests after achieve same goals"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Iteration 1 - Add Counter
|
|
292
|
+
```markdown
|
|
293
|
+
Added section: "Why Order Matters"
|
|
294
|
+
Re-tested: Agent STILL chose C
|
|
295
|
+
New rationalization: "Spirit not letter"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Iteration 2 - Add Foundational Principle
|
|
299
|
+
```markdown
|
|
300
|
+
Added: "Violating letter is violating spirit"
|
|
301
|
+
Re-tested: Agent chose A (delete it)
|
|
302
|
+
Cited: New principle directly
|
|
303
|
+
Meta-test: "Skill was clear, I should follow it"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Bulletproof achieved.**
|
|
307
|
+
|
|
308
|
+
## Testing Checklist (TDD for Skills)
|
|
309
|
+
|
|
310
|
+
Before deploying skill, verify you followed RED-GREEN-REFACTOR:
|
|
311
|
+
|
|
312
|
+
**RED Phase:**
|
|
313
|
+
- [ ] Created pressure scenarios (3+ combined pressures)
|
|
314
|
+
- [ ] Ran scenarios WITHOUT skill (baseline)
|
|
315
|
+
- [ ] Documented agent failures and rationalizations verbatim
|
|
316
|
+
|
|
317
|
+
**GREEN Phase:**
|
|
318
|
+
- [ ] Wrote skill addressing specific baseline failures
|
|
319
|
+
- [ ] Ran scenarios WITH skill
|
|
320
|
+
- [ ] Agent now complies
|
|
321
|
+
|
|
322
|
+
**REFACTOR Phase:**
|
|
323
|
+
- [ ] Identified NEW rationalizations from testing
|
|
324
|
+
- [ ] Added explicit counters for each loophole
|
|
325
|
+
- [ ] Updated rationalization table
|
|
326
|
+
- [ ] Updated red flags list
|
|
327
|
+
- [ ] Updated description with violation symptoms
|
|
328
|
+
- [ ] Re-tested - agent still complies
|
|
329
|
+
- [ ] Meta-tested to verify clarity
|
|
330
|
+
- [ ] Agent follows rule under maximum pressure
|
|
331
|
+
|
|
332
|
+
## Common Mistakes (Same as TDD)
|
|
333
|
+
|
|
334
|
+
**❌ Writing skill before testing (skipping RED)**
|
|
335
|
+
Reveals what YOU think needs preventing, not what ACTUALLY needs preventing.
|
|
336
|
+
✅ Fix: Always run baseline scenarios first.
|
|
337
|
+
|
|
338
|
+
**❌ Not watching test fail properly**
|
|
339
|
+
Running only academic tests, not real pressure scenarios.
|
|
340
|
+
✅ Fix: Use pressure scenarios that make agent WANT to violate.
|
|
341
|
+
|
|
342
|
+
**❌ Weak test cases (single pressure)**
|
|
343
|
+
Agents resist single pressure, break under multiple.
|
|
344
|
+
✅ Fix: Combine 3+ pressures (time + sunk cost + exhaustion).
|
|
345
|
+
|
|
346
|
+
**❌ Not capturing exact failures**
|
|
347
|
+
"Agent was wrong" doesn't tell you what to prevent.
|
|
348
|
+
✅ Fix: Document exact rationalizations verbatim.
|
|
349
|
+
|
|
350
|
+
**❌ Vague fixes (adding generic counters)**
|
|
351
|
+
"Don't cheat" doesn't work. "Don't keep as reference" does.
|
|
352
|
+
✅ Fix: Add explicit negations for each specific rationalization.
|
|
353
|
+
|
|
354
|
+
**❌ Stopping after first pass**
|
|
355
|
+
Tests pass once ≠ bulletproof.
|
|
356
|
+
✅ Fix: Continue REFACTOR cycle until no new rationalizations.
|
|
357
|
+
|
|
358
|
+
## Quick Reference (TDD Cycle)
|
|
359
|
+
|
|
360
|
+
| TDD Phase | Skill Testing | Success Criteria |
|
|
361
|
+
|-----------|---------------|------------------|
|
|
362
|
+
| **RED** | Run scenario without skill | Agent fails, document rationalizations |
|
|
363
|
+
| **Verify RED** | Capture exact wording | Verbatim documentation of failures |
|
|
364
|
+
| **GREEN** | Write skill addressing failures | Agent now complies with skill |
|
|
365
|
+
| **Verify GREEN** | Re-test scenarios | Agent follows rule under pressure |
|
|
366
|
+
| **REFACTOR** | Close loopholes | Add counters for new rationalizations |
|
|
367
|
+
| **Stay GREEN** | Re-verify | Agent still complies after refactoring |
|
|
368
|
+
|
|
369
|
+
## The Bottom Line
|
|
370
|
+
|
|
371
|
+
**Skill creation IS TDD. Same principles, same cycle, same benefits.**
|
|
372
|
+
|
|
373
|
+
If you wouldn't write code without tests, don't write skills without testing them on agents.
|
|
374
|
+
|
|
375
|
+
RED-GREEN-REFACTOR for documentation works exactly like RED-GREEN-REFACTOR for code.
|
|
376
|
+
|
|
377
|
+
## Real-World Impact
|
|
378
|
+
|
|
379
|
+
From applying TDD to TDD skill itself (2025-10-03):
|
|
380
|
+
- 6 RED-GREEN-REFACTOR iterations to bulletproof
|
|
381
|
+
- Baseline testing revealed 10+ unique rationalizations
|
|
382
|
+
- Each REFACTOR closed specific loopholes
|
|
383
|
+
- Final VERIFY GREEN: 100% compliance under maximum pressure
|
|
384
|
+
- Same process works for any discipline-enforcing skill
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# 协作约定
|
|
2
|
+
|
|
3
|
+
请与项目自身规范合并使用;如有冲突,以项目规范和用户明确指令为准。
|
|
4
|
+
|
|
5
|
+
## 0. 项目定制位
|
|
6
|
+
|
|
7
|
+
- 项目名称:`<按项目填写>`
|
|
8
|
+
- 主要技术栈:`<按项目填写>`
|
|
9
|
+
- 主要运行命令:`<按项目填写>`
|
|
10
|
+
- 主要测试命令:`<按项目填写>`
|
|
11
|
+
- 提交策略:`<由人类提交 / 允许 AI 提交 / 混合>`
|
|
12
|
+
- 文档语言:默认 `中文`,如需英文请整体改口径
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. 编码前先思考
|
|
16
|
+
|
|
17
|
+
**不要想当然,不要掩饰困惑,要把假设和取舍摆到台面上。**
|
|
18
|
+
|
|
19
|
+
- 先明确写出自己的假设;不确定时就提问。
|
|
20
|
+
- 如果需求存在多种解释,先把几种理解列出来,不要静默替用户做决定。
|
|
21
|
+
- 如果存在更简单的做法,要主动指出。
|
|
22
|
+
- 需要时可以温和地提出异议,不盲从执行。
|
|
23
|
+
- 一旦发现信息不清、边界模糊或描述矛盾,先停下来,说明困惑点并澄清。
|
|
24
|
+
|
|
25
|
+
## 2. 简单优先
|
|
26
|
+
|
|
27
|
+
**用最少的代码解决问题,不做投机式设计。**
|
|
28
|
+
|
|
29
|
+
- 不添加用户没有要求的功能。
|
|
30
|
+
- 不为一次性代码提前做抽象。
|
|
31
|
+
- 不加入未被要求的“灵活性”“可配置化”“通用化”。
|
|
32
|
+
- 不为明显不可能发生的场景堆砌错误处理。
|
|
33
|
+
- 如果写了很多代码,但更少代码能清楚解决问题,就应继续简化。
|
|
34
|
+
|
|
35
|
+
## 3. 外科手术式改动
|
|
36
|
+
|
|
37
|
+
**只改必须改的地方,只清理由自己改动带来的问题。**
|
|
38
|
+
|
|
39
|
+
- 不顺手重构无关模块。
|
|
40
|
+
- 不为“顺便优化”扩大改动面。
|
|
41
|
+
- 尽量贴合项目现有结构、命名和风格。
|
|
42
|
+
- 只删除因为本次修改而成为孤儿的代码。
|
|
43
|
+
|
|
44
|
+
## 4. 以目标驱动执行
|
|
45
|
+
|
|
46
|
+
**先定义成功标准,再循环验证直到目标达成。**
|
|
47
|
+
|
|
48
|
+
把任务改写成可验证目标:
|
|
49
|
+
|
|
50
|
+
- “修 bug” -> “先复现,再补回归验证,再修复”
|
|
51
|
+
- “加能力” -> “先明确输入输出,再实现,再验证”
|
|
52
|
+
- “重构” -> “先确认行为基线,再保证改前改后一致”
|
|
53
|
+
|
|
54
|
+
多步骤任务建议使用:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
1. [步骤] -> 验证:[检查项]
|
|
58
|
+
2. [步骤] -> 验证:[检查项]
|
|
59
|
+
3. [步骤] -> 验证:[检查项]
|
|
60
|
+
```
|
|
61
|
+
## 5. 先读再写
|
|
62
|
+
|
|
63
|
+
- 修改前先理解相关上下文。
|
|
64
|
+
- 阅读导出、直接调用方和共享工具。
|
|
65
|
+
- 不因为代码“看起来无关”就跳过检查。
|
|
66
|
+
- 如果不理解现有结构原因,先澄清或保守处理。
|
|
67
|
+
|
|
68
|
+
## 6. 遵守项目惯例
|
|
69
|
+
|
|
70
|
+
- 项目一致性高于个人偏好。
|
|
71
|
+
- 匹配现有代码风格、命名和组织方式。
|
|
72
|
+
- 不静默引入另一套风格。
|
|
73
|
+
- 如果认为现有惯例有害,要明确说明,而不是私自分叉。
|
|
74
|
+
|
|
75
|
+
## 7. 暴露冲突
|
|
76
|
+
|
|
77
|
+
- 如果发现两种模式、约定或需求互相矛盾,不要折中混合。
|
|
78
|
+
- 选择更近期、更稳定或测试覆盖更好的模式。
|
|
79
|
+
- 简要说明选择原因。
|
|
80
|
+
- 标记另一个冲突点,必要时建议后续清理。
|
|
81
|
+
|
|
82
|
+
## 8. 测试验证意图
|
|
83
|
+
|
|
84
|
+
- 测试应表达行为背后的业务意图,而不只是覆盖表面输出。
|
|
85
|
+
- 新增或修改测试时,确保它能在关键逻辑被破坏时失败。
|
|
86
|
+
- 修 bug 时,优先补回归验证。
|
|
87
|
+
- 不把“测试未运行”说成“测试通过”。
|
|
88
|
+
|
|
89
|
+
## 9. 阶段性检查
|
|
90
|
+
|
|
91
|
+
- 每完成一个重要步骤,确认当前状态。
|
|
92
|
+
- 已完成什么。
|
|
93
|
+
- 已验证什么。
|
|
94
|
+
- 还剩什么。
|
|
95
|
+
- 如果跟丢上下文,先停下来重新整理。
|
|
96
|
+
|
|
97
|
+
<!-- COWORK-FLOW:START -->
|
|
98
|
+
# cowork-flow Instructions
|
|
99
|
+
|
|
100
|
+
These instructions are for AI assistants working in this project.
|
|
101
|
+
|
|
102
|
+
Use the `.agent/skills/start` skill when starting a new session to:
|
|
103
|
+
- Initialize your developer identity
|
|
104
|
+
- Understand current project context
|
|
105
|
+
- Read relevant guidelines
|
|
106
|
+
|
|
107
|
+
Use `@/.cowork-flow/` to learn:
|
|
108
|
+
- Development workflow (`workflow.md`)
|
|
109
|
+
- Project structure guidelines (`spec/`)
|
|
110
|
+
- Developer workspace (`workspace/`)
|
|
111
|
+
|
|
112
|
+
Use `@/.agent/skills/` for reusable local skills.
|
|
113
|
+
|
|
114
|
+
Keep this managed block so cowork-flow updates can refresh the instructions.
|
|
115
|
+
|
|
116
|
+
<!-- COWORK-FLOW:END -->
|