forge-workflow 1.0.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/bin/forge.js ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const COMMANDS = [
7
+ 'status.md', 'research.md', 'plan.md', 'dev.md', 'check.md',
8
+ 'ship.md', 'review.md', 'merge.md', 'verify.md'
9
+ ];
10
+
11
+ const SKILLS_PARALLEL_AI = [
12
+ 'SKILL.md', 'README.md', 'api-reference.md', 'quick-reference.md', 'research-workflows.md'
13
+ ];
14
+
15
+ const SKILLS_SONARCLOUD = ['SKILL.md', 'reference.md'];
16
+
17
+ console.log('');
18
+ console.log(' ___ ');
19
+ console.log(' | _|___ _ _ ___ ___ ');
20
+ console.log(' | _| . || \'_|| . || -_|');
21
+ console.log(' |_| |___||_| |_ ||___|');
22
+ console.log(' |___| ');
23
+ console.log('');
24
+ console.log('Installing Forge - 9-Stage TDD-First Workflow...');
25
+ console.log('');
26
+
27
+ // Get the project root (where npm install was run)
28
+ const projectRoot = process.env.INIT_CWD || process.cwd();
29
+
30
+ // Get the package directory (where forge is installed)
31
+ const packageDir = path.dirname(__dirname);
32
+
33
+ // Directories to create
34
+ const dirs = [
35
+ '.claude/commands',
36
+ '.claude/rules',
37
+ '.claude/skills/parallel-ai',
38
+ '.claude/skills/sonarcloud',
39
+ '.claude/scripts',
40
+ 'docs/research'
41
+ ];
42
+
43
+ // Create directories
44
+ console.log('Creating directories...');
45
+ dirs.forEach(dir => {
46
+ const fullPath = path.join(projectRoot, dir);
47
+ if (!fs.existsSync(fullPath)) {
48
+ fs.mkdirSync(fullPath, { recursive: true });
49
+ }
50
+ });
51
+
52
+ // Copy function
53
+ function copyFile(src, dest) {
54
+ try {
55
+ if (fs.existsSync(src)) {
56
+ fs.copyFileSync(src, dest);
57
+ return true;
58
+ }
59
+ } catch (err) {
60
+ // Silently continue if file doesn't exist
61
+ }
62
+ return false;
63
+ }
64
+
65
+ // Copy commands
66
+ console.log('Copying workflow commands...');
67
+ COMMANDS.forEach(cmd => {
68
+ const src = path.join(packageDir, '.claude/commands', cmd);
69
+ const dest = path.join(projectRoot, '.claude/commands', cmd);
70
+ if (copyFile(src, dest)) {
71
+ console.log(` ✓ ${cmd}`);
72
+ }
73
+ });
74
+
75
+ // Copy rules
76
+ console.log('Copying workflow rules...');
77
+ const rulesSrc = path.join(packageDir, '.claude/rules/workflow.md');
78
+ const rulesDest = path.join(projectRoot, '.claude/rules/workflow.md');
79
+ if (copyFile(rulesSrc, rulesDest)) {
80
+ console.log(' ✓ workflow.md');
81
+ }
82
+
83
+ // Copy skills
84
+ console.log('Copying skills...');
85
+ SKILLS_PARALLEL_AI.forEach(file => {
86
+ const src = path.join(packageDir, '.claude/skills/parallel-ai', file);
87
+ const dest = path.join(projectRoot, '.claude/skills/parallel-ai', file);
88
+ copyFile(src, dest);
89
+ });
90
+ console.log(' ✓ parallel-ai');
91
+
92
+ SKILLS_SONARCLOUD.forEach(file => {
93
+ const src = path.join(packageDir, '.claude/skills/sonarcloud', file);
94
+ const dest = path.join(projectRoot, '.claude/skills/sonarcloud', file);
95
+ copyFile(src, dest);
96
+ });
97
+ console.log(' ✓ sonarcloud');
98
+
99
+ // Copy scripts
100
+ console.log('Copying scripts...');
101
+ const scriptSrc = path.join(packageDir, '.claude/scripts/load-env.sh');
102
+ const scriptDest = path.join(projectRoot, '.claude/scripts/load-env.sh');
103
+ if (copyFile(scriptSrc, scriptDest)) {
104
+ console.log(' ✓ load-env.sh');
105
+ }
106
+
107
+ // Copy documentation
108
+ console.log('Copying documentation...');
109
+ const workflowSrc = path.join(packageDir, 'docs/WORKFLOW.md');
110
+ const workflowDest = path.join(projectRoot, 'docs/WORKFLOW.md');
111
+ if (copyFile(workflowSrc, workflowDest)) {
112
+ console.log(' ✓ WORKFLOW.md');
113
+ }
114
+
115
+ const templateSrc = path.join(packageDir, 'docs/research/TEMPLATE.md');
116
+ const templateDest = path.join(projectRoot, 'docs/research/TEMPLATE.md');
117
+ if (copyFile(templateSrc, templateDest)) {
118
+ console.log(' ✓ research/TEMPLATE.md');
119
+ }
120
+
121
+ console.log('');
122
+ console.log('✅ Forge installed successfully!');
123
+ console.log('');
124
+ console.log('┌─────────────────────────────────────────────────────────┐');
125
+ console.log('│ GET STARTED │');
126
+ console.log('├─────────────────────────────────────────────────────────┤');
127
+ console.log('│ /status - Check current context │');
128
+ console.log('│ /research - Start researching a feature │');
129
+ console.log('│ /plan - Create implementation plan │');
130
+ console.log('│ /dev - Start TDD development │');
131
+ console.log('│ /check - Run validation │');
132
+ console.log('│ /ship - Create pull request │');
133
+ console.log('│ /review - Address PR feedback │');
134
+ console.log('│ /merge - Merge and cleanup │');
135
+ console.log('│ /verify - Final documentation check │');
136
+ console.log('├─────────────────────────────────────────────────────────┤');
137
+ console.log('│ Full guide: docs/WORKFLOW.md │');
138
+ console.log('│ Research template: docs/research/TEMPLATE.md │');
139
+ console.log('└─────────────────────────────────────────────────────────┘');
140
+ console.log('');
@@ -0,0 +1,251 @@
1
+ # Forge Development Workflow
2
+
3
+ Complete 9-stage TDD-first workflow for feature development. Works with any tech stack.
4
+
5
+ ## Overview
6
+
7
+ This workflow integrates:
8
+ - **Test-Driven Development (TDD)**: Tests written UPFRONT
9
+ - **Research-First**: Evidence-based decisions with parallel-ai
10
+ - **Issue Tracking**: Beads for persistent tracking across agents
11
+ - **Strategic Planning**: OpenSpec for architectural changes
12
+ - **Security**: OWASP Top 10 analysis for every feature
13
+ - **Documentation**: Progressive updates, final verification
14
+
15
+ ## Workflow Stages
16
+
17
+ ```
18
+ ┌─────────┐
19
+ │ /status │ → Check current stage & context
20
+ └────┬────┘
21
+
22
+ ┌────▼──────┐
23
+ │ /research │ → Deep research (parallel-ai), save to docs/research/
24
+ └────┬──────┘
25
+
26
+ ┌────▼────┐
27
+ │ /plan │ → OpenSpec (if strategic) + Beads + branch
28
+ └────┬────┘
29
+
30
+ ┌────▼───┐
31
+ │ /dev │ → TDD implementation (RED-GREEN-REFACTOR)
32
+ └────┬───┘
33
+
34
+ ┌────▼────┐
35
+ │ /check │ → Validation (type/lint/tests/security)
36
+ └────┬────┘
37
+
38
+ ┌────▼────┐
39
+ │ /ship │ → Create PR with full documentation
40
+ └────┬────┘
41
+
42
+ ┌────▼─────┐
43
+ │ /review │ → Address ALL PR issues (GitHub Actions, Greptile, SonarCloud)
44
+ └────┬─────┘
45
+
46
+ ┌────▼─────┐
47
+ │ /merge │ → Update docs, merge PR, archive, cleanup
48
+ └────┬─────┘
49
+
50
+ ┌────▼──────┐
51
+ │ /verify │ → Cross-check all documentation, update if needed
52
+ └───────────┘
53
+
54
+ ✓ Complete
55
+ ```
56
+
57
+ ## Quick Reference
58
+
59
+ | Stage | Command | Key Actions |
60
+ |-------|---------|-------------|
61
+ | 1. Status | `/status` | Check PROGRESS.md, Beads, OpenSpec |
62
+ | 2. Research | `/research <name>` | parallel-ai + codebase, save to docs/research/ |
63
+ | 3. Plan | `/plan <slug>` | OpenSpec (if strategic) + Beads + branch |
64
+ | 4. Dev | `/dev` | TDD cycles (RED-GREEN-REFACTOR) |
65
+ | 5. Check | `/check` | Type/lint/security/tests |
66
+ | 6. Ship | `/ship` | Create PR with full docs |
67
+ | 7. Review | `/review <pr>` | Fix ALL PR issues |
68
+ | 8. Merge | `/merge <pr>` | Update docs, merge, archive |
69
+ | 9. Verify | `/verify` | Cross-check docs, update if needed |
70
+
71
+ For detailed information on each stage, see the individual command files in `.claude/commands/`.
72
+
73
+ ## TDD Principles
74
+
75
+ ### What is TDD?
76
+
77
+ **Test-Driven Development**: Write tests BEFORE writing implementation code.
78
+
79
+ **Benefits**:
80
+ - Catches bugs early
81
+ - Ensures code is testable
82
+ - Documents expected behavior
83
+ - Improves code design
84
+ - Provides confidence in refactoring
85
+
86
+ ### TDD Cycle
87
+
88
+ ```
89
+ ┌─────────────┐
90
+ │ RED (Test) │ → Write failing test
91
+ └──────┬──────┘
92
+
93
+ ┌──────▼───────┐
94
+ │ GREEN (Code) │ → Write minimal code to pass
95
+ └──────┬───────┘
96
+
97
+ ┌──────▼────────┐
98
+ │ REFACTOR │ → Clean up and optimize
99
+ └───────────────┘
100
+
101
+ └─→ Repeat for next feature
102
+ ```
103
+
104
+ ### Example TDD Flow
105
+
106
+ **Feature**: Add email validation
107
+
108
+ **RED** (Write test first):
109
+ ```typescript
110
+ // test/validation.test.ts
111
+ test('should validate email format', () => {
112
+ expect(validateEmail('test@example.com')).toBe(true)
113
+ expect(validateEmail('invalid')).toBe(false)
114
+ })
115
+ ```
116
+ **Run test**: ❌ Fails (function doesn't exist)
117
+
118
+ **GREEN** (Make it pass):
119
+ ```typescript
120
+ // src/validation.ts
121
+ export function validateEmail(email: string): boolean {
122
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
123
+ }
124
+ ```
125
+ **Run test**: ✅ Passes
126
+
127
+ **REFACTOR** (Optimize):
128
+ ```typescript
129
+ // Extract regex to constant
130
+ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
131
+
132
+ export function validateEmail(email: string): boolean {
133
+ return EMAIL_REGEX.test(email)
134
+ }
135
+ ```
136
+ **Run test**: ✅ Still passes
137
+
138
+ ---
139
+
140
+ ## Research-First Approach
141
+
142
+ ### Why Research First?
143
+
144
+ **Evidence-based decisions**:
145
+ - Understand existing patterns before reinventing
146
+ - Learn from others' mistakes (known issues)
147
+ - Apply industry best practices
148
+ - Make informed security decisions
149
+ - Document reasoning for future reference
150
+
151
+ ### parallel-ai Integration
152
+
153
+ **MANDATORY for all features**: Use parallel-ai skill for web research
154
+
155
+ **Research Queries**:
156
+ ```
157
+ "[your-framework] [feature] best practices 2026"
158
+ "[feature] implementation patterns"
159
+ "OWASP Top 10 risks for [feature] 2026"
160
+ "[Feature] security vulnerabilities common attacks"
161
+ "Secure [feature] implementation checklist"
162
+ ```
163
+
164
+ **Document Everything**:
165
+ - Source URLs
166
+ - Key insights
167
+ - Applicability to project
168
+ - Decision impact
169
+ - Evidence for choices
170
+
171
+ ---
172
+
173
+ ## Security-First Development
174
+
175
+ ### OWASP Top 10 Analysis
176
+
177
+ **MANDATORY for every feature**: Analyze against OWASP Top 10 2021
178
+
179
+ **The List**:
180
+ 1. A01: Broken Access Control
181
+ 2. A02: Cryptographic Failures
182
+ 3. A03: Injection
183
+ 4. A04: Insecure Design
184
+ 5. A05: Security Misconfiguration
185
+ 6. A06: Vulnerable Components
186
+ 7. A07: Identification and Authentication Failures
187
+ 8. A08: Software and Data Integrity Failures
188
+ 9. A09: Security Logging and Monitoring Failures
189
+ 10. A10: Server-Side Request Forgery (SSRF)
190
+
191
+ **For Each Risk**:
192
+ - Risk level: High/Medium/Low
193
+ - Applicability: Yes/No
194
+ - Mitigation strategy
195
+ - Test scenarios
196
+ - Evidence from research
197
+
198
+ **Security Tests** (TDD):
199
+ ```typescript
200
+ // test/security/access-control.test.ts
201
+ test('should prevent unauthorized access to other team data', async () => {
202
+ const user = await createTestUser({ teamId: 'team-1' })
203
+ const response = await api.get('/data?team_id=team-2')
204
+ .set('Authorization', `Bearer ${user.token}`)
205
+
206
+ expect(response.status).toBe(403)
207
+ expect(response.body.data).toBeUndefined()
208
+ })
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Cross-Agent Collaboration
214
+
215
+ ### Beads for Persistence
216
+
217
+ **Why Beads**:
218
+ - Git-backed (survives agent switches)
219
+ - Cross-agent visibility
220
+ - Status tracking
221
+ - Dependency management
222
+
223
+ **Workflow**:
224
+ ```bash
225
+ # Agent 1 (Claude Code)
226
+ bd create "Add notifications"
227
+ bd update bd-x7y2 --status in_progress --comment "API done, UI pending"
228
+ bd sync && git push
229
+
230
+ # Agent 2 (Cursor)
231
+ git pull && bd sync
232
+ bd show bd-x7y2 # See status: "API done, UI pending"
233
+ # Continue UI work
234
+ bd update bd-x7y2 --status done
235
+ bd sync && git push
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Tips & Best Practices
241
+
242
+ 1. **Always TDD**: Write tests BEFORE implementation
243
+ 2. **Research everything**: Use parallel-ai for every feature
244
+ 3. **Security first**: OWASP Top 10 analysis mandatory
245
+ 4. **Document decisions**: Evidence and reasoning in research docs
246
+ 5. **Update Beads regularly**: Keep status current for handoffs
247
+ 6. **Commit frequently**: After each TDD cycle
248
+ 7. **Address ALL PR feedback**: GitHub Actions, Greptile, SonarCloud
249
+ 8. **Update docs progressively**: Don't wait until the end
250
+ 9. **Verify at the end**: Final documentation check catches gaps
251
+ 10. **Sync often**: `bd sync` at end of every session
@@ -0,0 +1,292 @@
1
+ # Research: [Feature Name]
2
+
3
+ **Date**: YYYY-MM-DD
4
+ **Researcher**: Claude AI
5
+
6
+ ## Objective
7
+ [What we're trying to achieve - clear problem statement and goals]
8
+
9
+ ## Codebase Analysis
10
+
11
+ ### Existing Patterns
12
+ - **File**: `path/to/file.ts`
13
+ - **Pattern**: [Description of existing implementation]
14
+ - **Reusability**: [Yes/No + reasoning]
15
+ - **Lessons learned**: [What worked, what didn't]
16
+
17
+ ### Affected Modules
18
+ - **Module**: [name]
19
+ - **Changes needed**: [Description]
20
+ - **Impact**: [Low/Medium/High]
21
+ - **Dependencies**: [List any dependencies]
22
+
23
+ ### Test Infrastructure
24
+ - **Existing tests**: `path/to/tests/`
25
+ - **Test utilities**: [Available testing tools/helpers]
26
+ - **Coverage**: [Current state - percentage, gaps]
27
+ - **Test patterns**: [What patterns are used - unit, integration, E2E]
28
+
29
+ ## Web Research
30
+
31
+ ### Best Practices (parallel-ai)
32
+ 1. **Source**: [URL]
33
+ - **Key insight**: [Summary of best practice]
34
+ - **Applicability**: [How it applies to our project]
35
+ - **Decision impact**: [What decision this influences]
36
+ - **Implementation notes**: [How to apply]
37
+
38
+ 2. **Source**: [URL]
39
+ - [...]
40
+
41
+ ### Known Issues (parallel-ai)
42
+ 1. **Issue**: [Description]
43
+ - **Source**: [GitHub/SO/Blog URL]
44
+ - **Mitigation**: [How to avoid]
45
+ - **Decision impact**: [Changes to approach]
46
+ - **Frequency**: [How common is this issue]
47
+
48
+ 2. **Issue**: [...]
49
+
50
+ ### Library Documentation (Context7)
51
+ 1. **Library**: [name and version]
52
+ - **API**: [Relevant methods/patterns]
53
+ - **Compatibility**: [Version requirements, breaking changes]
54
+ - **Decision impact**: [Implementation details]
55
+ - **Example usage**: [Code snippet]
56
+
57
+ 2. **Library**: [...]
58
+
59
+ ### Case Studies
60
+ 1. **Source**: [URL]
61
+ - **Company/Project**: [Who implemented this]
62
+ - **Scale**: [Production scale, users, data volume]
63
+ - **Lessons**: [What they learned]
64
+ - **Applicability**: [How it relates to our use case]
65
+
66
+ 2. **Source**: [...]
67
+
68
+ ## Key Decisions & Reasoning
69
+
70
+ ### Decision 1: [Decision Title]
71
+ - **Decision**: [What we decided]
72
+ - **Reasoning**: [Why we chose this approach]
73
+ - **Evidence**: [Research that supports this - links to sources]
74
+ - **Alternatives considered**:
75
+ 1. [Alternative 1]: [Why rejected]
76
+ 2. [Alternative 2]: [Why rejected]
77
+ - **Trade-offs**: [What we're giving up, what we're gaining]
78
+ - **Risk**: [Low/Medium/High] - [Risk description]
79
+
80
+ ### Decision 2: [Decision Title]
81
+ - [...]
82
+
83
+ ## TDD Test Scenarios (Identified Upfront)
84
+
85
+ ### Unit Tests
86
+ 1. **Test**: [Scenario description]
87
+ - **File**: `test/path/test.ts`
88
+ - **Function under test**: `functionName()`
89
+ - **Assertions**: [What to verify]
90
+ - **Test data**: [Required test data/mocks]
91
+ - **Edge cases**: [List edge cases to cover]
92
+
93
+ 2. **Test**: [...]
94
+
95
+ ### Integration Tests
96
+ 1. **Test**: [Scenario description]
97
+ - **File**: `test/integration/test.ts`
98
+ - **Components**: [What components are being tested together]
99
+ - **Assertions**: [What to verify]
100
+ - **Test data**: [Database fixtures, API mocks]
101
+
102
+ 2. **Test**: [...]
103
+
104
+ ### E2E Tests
105
+ 1. **Test**: [User flow scenario]
106
+ - **File**: `test/e2e/test.ts`
107
+ - **User flow**: [Step-by-step user actions]
108
+ - **Assertions**: [What user should see/experience]
109
+ - **Test data**: [Complete test environment setup]
110
+
111
+ 2. **Test**: [...]
112
+
113
+ ## Security Analysis (OWASP Top 10 + Feature-Specific)
114
+
115
+ ### OWASP Top 10 Applicability
116
+
117
+ #### A01: Broken Access Control
118
+ - **Risk**: [High/Medium/Low]
119
+ - **Applicable**: [Yes/No]
120
+ - **Mitigation**: [How addressed - RLS policies, permission checks]
121
+ - **Tests**: [Security test scenarios]
122
+ - **Evidence**: [Links to security research]
123
+
124
+ #### A02: Cryptographic Failures
125
+ - **Risk**: [High/Medium/Low]
126
+ - **Applicable**: [Yes/No]
127
+ - **Mitigation**: [Encryption at rest/transit, key management]
128
+ - **Tests**: [Encryption tests]
129
+ - **Compliance**: [Data protection requirements]
130
+
131
+ #### A03: Injection
132
+ - **Risk**: [High/Medium/Low]
133
+ - **Applicable**: [Yes/No]
134
+ - **Mitigation**: [Parameterized queries, input validation, sanitization]
135
+ - **Tests**: [SQL injection tests, XSS tests, command injection tests]
136
+ - **Libraries**: [What libraries help prevent injection]
137
+
138
+ #### A04: Insecure Design
139
+ - **Risk**: [High/Medium/Low]
140
+ - **Threat model**: [Key threats identified]
141
+ - **Secure design patterns**: [Patterns used - zero trust, defense in depth]
142
+ - **Architecture review**: [Security considerations in design]
143
+ - **Tests**: [Security design validation]
144
+
145
+ #### A05: Security Misconfiguration
146
+ - **Risk**: [High/Medium/Low]
147
+ - **Configuration reviewed**: [Yes/No]
148
+ - **Security headers**: [CSP, HSTS, X-Frame-Options, etc.]
149
+ - **Error handling**: [No sensitive info in errors]
150
+ - **Default accounts**: [No default/test credentials]
151
+ - **Tests**: [Configuration security tests]
152
+
153
+ #### A06: Vulnerable Components
154
+ - **Risk**: [High/Medium/Low]
155
+ - **Dependencies scanned**: [Yes/No - tool used]
156
+ - **Known CVEs**: [Count and severity from scan]
157
+ - **Update plan**: [If vulnerabilities found]
158
+ - **Monitoring**: [Dependabot, Snyk, etc.]
159
+ - **Tests**: [Dependency security checks]
160
+
161
+ #### A07: Identification and Authentication Failures
162
+ - **Risk**: [High/Medium/Low]
163
+ - **Auth mechanism**: [OAuth2/JWT/Session/etc.]
164
+ - **Session management**: [Secure/reviewed - timeout, rotation]
165
+ - **Password policy**: [Requirements if applicable]
166
+ - **MFA**: [Required/Optional/Not applicable]
167
+ - **Brute force protection**: [Rate limiting, account lockout]
168
+ - **Tests**: [Authentication tests, session tests]
169
+
170
+ #### A08: Software and Data Integrity Failures
171
+ - **Risk**: [High/Medium/Low]
172
+ - **Integrity checks**: [Where implemented - signatures, checksums]
173
+ - **Code signing**: [Yes/No]
174
+ - **CI/CD security**: [Pipeline reviewed, secrets management]
175
+ - **Supply chain**: [Trusted sources, verification]
176
+ - **Tests**: [Integrity validation tests]
177
+
178
+ #### A09: Security Logging and Monitoring Failures
179
+ - **Risk**: [High/Medium/Low]
180
+ - **Security events logged**: [List what's tracked]
181
+ - **Audit trail**: [What's tracked for compliance]
182
+ - **No sensitive data**: [Verified - no passwords/tokens in logs]
183
+ - **Alerting**: [Security alerts configured]
184
+ - **Log retention**: [Duration and compliance]
185
+ - **Tests**: [Logging tests, no sensitive data tests]
186
+
187
+ #### A10: Server-Side Request Forgery (SSRF)
188
+ - **Risk**: [High/Medium/Low]
189
+ - **External requests**: [Where made in code]
190
+ - **URL validation**: [Whitelist/validation rules]
191
+ - **Network restrictions**: [Firewall rules, VPC]
192
+ - **Input sanitization**: [User-controlled URLs]
193
+ - **Tests**: [SSRF prevention tests]
194
+
195
+ ### Feature-Specific Security Risks
196
+
197
+ 1. **Risk**: [Specific risk for this feature]
198
+ - **Likelihood**: High/Medium/Low
199
+ - **Impact**: High/Medium/Low
200
+ - **Attack vector**: [How this could be exploited]
201
+ - **Mitigation**: [Specific solution]
202
+ - **Evidence**: [Research source showing this risk]
203
+ - **Tests**: [Security test scenarios]
204
+ - **Monitoring**: [How to detect attacks]
205
+
206
+ 2. **Risk**: [Next risk]
207
+ - [...]
208
+
209
+ ### Security Test Scenarios (TDD)
210
+
211
+ 1. **Test**: Unauthorized access attempt should fail
212
+ - **File**: `test/security/access-control.test.ts`
213
+ - **Scenario**: User tries to access another team's data
214
+ - **Expected**: 403 Forbidden, no data leak
215
+
216
+ 2. **Test**: SQL injection attempt should be blocked
217
+ - **File**: `test/security/injection.test.ts`
218
+ - **Scenario**: Malicious input in query parameter
219
+ - **Expected**: Input sanitized, no SQL execution, error logged
220
+
221
+ 3. **Test**: XSS attempt should be sanitized
222
+ - **File**: `test/security/xss.test.ts`
223
+ - **Scenario**: Script tag in user input
224
+ - **Expected**: HTML escaped, no script execution
225
+
226
+ 4. **Test**: [Additional security tests]
227
+ - [...]
228
+
229
+ ## Scope Assessment
230
+
231
+ - **Type**: Tactical / Strategic
232
+ - **Rationale**: [Why this classification]
233
+ - **OpenSpec needed**: Yes / No
234
+
235
+ - **Complexity**: Low / Medium / High
236
+ - **Rationale**: [Number of files, systems involved, dependencies]
237
+ - **Estimated effort**: [Without time, describe scope]
238
+
239
+ - **Parallel opportunity**: Yes / No
240
+ - **Rationale**: [Independent tracks available?]
241
+ - **Tracks**: [If yes, list potential parallel tracks]
242
+
243
+ - **Estimated files**: [Count]
244
+ - **New files**: [List]
245
+ - **Modified files**: [List]
246
+
247
+ - **Dependencies**:
248
+ - **Internal**: [Other features/modules]
249
+ - **External**: [Third-party libraries]
250
+ - **Blockers**: [Any blocking dependencies]
251
+
252
+ - **Security risk level**: Low / Medium / High / Critical
253
+ - **Rationale**: [Based on OWASP analysis]
254
+ - **Mitigation priority**: [When to address]
255
+
256
+ ## Next Steps
257
+
258
+ 1. **If Strategic**: Create OpenSpec proposal
259
+ - `openspec proposal create <feature-slug>`
260
+ - Write proposal.md, tasks.md, design.md
261
+ - Reference this research doc for evidence
262
+
263
+ 2. **Create Beads issue**:
264
+ - `bd create "<feature-name>"`
265
+ - Link to this research doc
266
+ - Link to OpenSpec if strategic
267
+
268
+ 3. **Create branch**:
269
+ - `git checkout -b feat/<feature-slug>`
270
+
271
+ 4. **Proceed to /plan**:
272
+ - Read this research doc
273
+ - Create formal implementation plan
274
+ - Wait for OpenSpec approval if strategic
275
+
276
+ ## Research Checklist
277
+
278
+ - [ ] Codebase exploration complete
279
+ - [ ] parallel-ai web research complete (multiple sources)
280
+ - [ ] Context7 library documentation reviewed
281
+ - [ ] Case studies analyzed
282
+ - [ ] All key decisions documented with evidence
283
+ - [ ] TDD test scenarios identified upfront
284
+ - [ ] OWASP Top 10 analysis complete
285
+ - [ ] Feature-specific security risks identified
286
+ - [ ] Security test scenarios defined
287
+ - [ ] Scope assessment complete
288
+ - [ ] Next steps clear
289
+
290
+ ---
291
+
292
+ **Note**: This research document serves as the single source of truth for all architectural and implementation decisions. Reference it throughout the development lifecycle (in OpenSpec proposals, PR descriptions, code reviews, and documentation).