super-opencode 1.1.0 → 1.1.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/.opencode/agents/architect.md +84 -84
- package/.opencode/agents/backend.md +124 -124
- package/.opencode/agents/frontend.md +137 -137
- package/.opencode/agents/optimizer.md +51 -51
- package/.opencode/agents/pm-agent.md +105 -105
- package/.opencode/agents/quality.md +107 -107
- package/.opencode/agents/researcher.md +105 -105
- package/.opencode/agents/reviewer.md +80 -80
- package/.opencode/agents/security.md +107 -107
- package/.opencode/agents/writer.md +136 -136
- package/.opencode/commands/soc-analyze.md +136 -137
- package/.opencode/commands/soc-brainstorm.md +109 -110
- package/.opencode/commands/soc-cleanup.md +107 -107
- package/.opencode/commands/soc-design.md +0 -1
- package/.opencode/commands/soc-explain.md +113 -113
- package/.opencode/commands/soc-git.md +104 -104
- package/.opencode/commands/soc-help.md +94 -94
- package/.opencode/commands/soc-implement.md +112 -112
- package/.opencode/commands/soc-improve.md +105 -105
- package/.opencode/commands/soc-pm.md +99 -99
- package/.opencode/commands/soc-research.md +105 -105
- package/.opencode/commands/soc-review.md +102 -102
- package/.opencode/commands/soc-test.md +109 -109
- package/.opencode/commands/soc-workflow.md +97 -97
- package/.opencode/settings.json +3 -3
- package/.opencode/skills/confidence-check/SKILL.md +97 -97
- package/.opencode/skills/debug-protocol/SKILL.md +83 -83
- package/.opencode/skills/reflexion/SKILL.md +108 -108
- package/.opencode/skills/security-audit/SKILL.md +90 -90
- package/.opencode/skills/self-check/SKILL.md +95 -95
- package/.opencode/skills/simplification/SKILL.md +92 -92
- package/AGENTS.md +175 -175
- package/LICENSE +21 -21
- package/dist/cli.js +2 -2
- package/package.json +45 -45
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: debug-protocol
|
|
3
|
-
description: Scientific debugging workflow using Root Cause Analysis and Minimal Reproducible Examples (MRE).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Debug Protocol Skill
|
|
7
|
-
|
|
8
|
-
## Purpose
|
|
9
|
-
To replace "Shotgun Debugging" (randomly changing code) with a deterministic, scientific process.
|
|
10
|
-
**Goal:** Fix the *root cause*, not just the symptom.
|
|
11
|
-
|
|
12
|
-
## When to Use
|
|
13
|
-
- **Trigger**: When a test fails, an exception is thrown, or output is unexpected.
|
|
14
|
-
- **Agent**: Primarily used by `execution` mode.
|
|
15
|
-
- **Support**:
|
|
16
|
-
- Call `quality` to write the reproduction test.
|
|
17
|
-
- Call `researcher` if the error message is obscure/undocumented.
|
|
18
|
-
|
|
19
|
-
## The Scientific Method (4-Step Protocol)
|
|
20
|
-
|
|
21
|
-
### Phase 1: Observation (The MRE)
|
|
22
|
-
**Rule**: *If you cannot reproduce it, you cannot fix it.*
|
|
23
|
-
1. **Isolate**: Create a standalone script or test case that fails 100% of the time.
|
|
24
|
-
2. **Minimize**: Remove all code not strictly necessary to produce the error.
|
|
25
|
-
3. **Log**: Do not guess variables. Log them.
|
|
26
|
-
|
|
27
|
-
### Phase 2: Localization (The "Wolf Fence")
|
|
28
|
-
**Rule**: *Divide and Conquer.*
|
|
29
|
-
1. **Binary Search**: Is the data wrong at the Database? No? At the API? No? At the UI?
|
|
30
|
-
2. **Trace**: Follow the data flow. Find the *exact line* where the reality diverges from expectation.
|
|
31
|
-
|
|
32
|
-
### Phase 3: Hypothesis (The "5 Whys")
|
|
33
|
-
**Rule**: *Do not fix the symptom.*
|
|
34
|
-
1. **Identify**: "Variable X is null."
|
|
35
|
-
2. **Ask Why**: "Why is X null?" -> "Because the API returned 404."
|
|
36
|
-
3. **Ask Why**: "Why 404?" -> "Because the ID was undefined."
|
|
37
|
-
4. **Ask Why**: "Why undefined?" -> "Because of a typo in the frontend."
|
|
38
|
-
5. **Root Cause**: Typo in the frontend payload.
|
|
39
|
-
|
|
40
|
-
### Phase 4: Resolution & Verification
|
|
41
|
-
**Rule**: *Prove it.*
|
|
42
|
-
1. **Apply Fix**: Correct the root cause.
|
|
43
|
-
2. **Verify**: Run the MRE from Phase 1. It must pass.
|
|
44
|
-
3. **Regression**: Run the full test suite. Ensure nothing else broke.
|
|
45
|
-
|
|
46
|
-
## Debugging Scratchpad Template
|
|
47
|
-
|
|
48
|
-
*Copy this into context during a debug session.*
|
|
49
|
-
|
|
50
|
-
```markdown
|
|
51
|
-
## 🐞 Debug Session: [Error Name]
|
|
52
|
-
|
|
53
|
-
### 1. The Reproduction (MRE)
|
|
54
|
-
- [ ] Created `reproduce_issue.ts`
|
|
55
|
-
- [ ] Failure is deterministic (Happens every time)
|
|
56
|
-
- **Error Message**: `[Paste exact error]`
|
|
57
|
-
|
|
58
|
-
### 2. Localization (Wolf Fence)
|
|
59
|
-
- [ ] Inputs are correct? (Yes/No)
|
|
60
|
-
- [ ] Intermediate state correct? (Yes/No)
|
|
61
|
-
- **Found at**: File `X`, Line `Y`.
|
|
62
|
-
|
|
63
|
-
### 3. Root Cause Analysis (5 Whys)
|
|
64
|
-
1. Why? [Answer]
|
|
65
|
-
2. Why? [Answer]
|
|
66
|
-
3. **Root Cause**: [The fundamental flaw]
|
|
67
|
-
|
|
68
|
-
### 4. Resolution
|
|
69
|
-
- **Action**: [What did you change?]
|
|
70
|
-
- **Verification**: `npm test -- reproduce_issue.ts` -> ✅ PASS
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Anti-Patterns (Must Avoid)
|
|
74
|
-
|
|
75
|
-
- ❌ **"It should work":** Code does not care what it "should" do. It does what it is told. Look at what it is doing.
|
|
76
|
-
- ❌ **Console Log Spray:** Don't leave `console.log('here')` all over the code. Use structured logging or remove them after finding the bug.
|
|
77
|
-
- ❌ **The "Blind Fix":** Applying a StackOverflow solution without understanding *why* it applies to your specific context. (Call `researcher` first).
|
|
78
|
-
- ❌ **Ignoring Warning Logs:** Often the error is preceded by a warning 10 lines up. Read the *whole* log.
|
|
79
|
-
|
|
80
|
-
## Integration with Agents
|
|
81
|
-
|
|
82
|
-
- **`quality` agent**: If you are stuck on **Phase 1 (Reproduction)**, delegate to `quality`. *"I see the error, but I can't write a test for it. Quality Agent, please create a Cypress test for this UI bug."*
|
|
83
|
-
- **`researcher` agent**: If you are stuck on **Phase 3 (Hypothesis)**. *"I have the error 'Heap Out of Memory'. Researcher, what are the common causes for this in Node.js 18?"*
|
|
1
|
+
---
|
|
2
|
+
name: debug-protocol
|
|
3
|
+
description: Scientific debugging workflow using Root Cause Analysis and Minimal Reproducible Examples (MRE).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debug Protocol Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
To replace "Shotgun Debugging" (randomly changing code) with a deterministic, scientific process.
|
|
10
|
+
**Goal:** Fix the *root cause*, not just the symptom.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
- **Trigger**: When a test fails, an exception is thrown, or output is unexpected.
|
|
14
|
+
- **Agent**: Primarily used by `execution` mode.
|
|
15
|
+
- **Support**:
|
|
16
|
+
- Call `quality` to write the reproduction test.
|
|
17
|
+
- Call `researcher` if the error message is obscure/undocumented.
|
|
18
|
+
|
|
19
|
+
## The Scientific Method (4-Step Protocol)
|
|
20
|
+
|
|
21
|
+
### Phase 1: Observation (The MRE)
|
|
22
|
+
**Rule**: *If you cannot reproduce it, you cannot fix it.*
|
|
23
|
+
1. **Isolate**: Create a standalone script or test case that fails 100% of the time.
|
|
24
|
+
2. **Minimize**: Remove all code not strictly necessary to produce the error.
|
|
25
|
+
3. **Log**: Do not guess variables. Log them.
|
|
26
|
+
|
|
27
|
+
### Phase 2: Localization (The "Wolf Fence")
|
|
28
|
+
**Rule**: *Divide and Conquer.*
|
|
29
|
+
1. **Binary Search**: Is the data wrong at the Database? No? At the API? No? At the UI?
|
|
30
|
+
2. **Trace**: Follow the data flow. Find the *exact line* where the reality diverges from expectation.
|
|
31
|
+
|
|
32
|
+
### Phase 3: Hypothesis (The "5 Whys")
|
|
33
|
+
**Rule**: *Do not fix the symptom.*
|
|
34
|
+
1. **Identify**: "Variable X is null."
|
|
35
|
+
2. **Ask Why**: "Why is X null?" -> "Because the API returned 404."
|
|
36
|
+
3. **Ask Why**: "Why 404?" -> "Because the ID was undefined."
|
|
37
|
+
4. **Ask Why**: "Why undefined?" -> "Because of a typo in the frontend."
|
|
38
|
+
5. **Root Cause**: Typo in the frontend payload.
|
|
39
|
+
|
|
40
|
+
### Phase 4: Resolution & Verification
|
|
41
|
+
**Rule**: *Prove it.*
|
|
42
|
+
1. **Apply Fix**: Correct the root cause.
|
|
43
|
+
2. **Verify**: Run the MRE from Phase 1. It must pass.
|
|
44
|
+
3. **Regression**: Run the full test suite. Ensure nothing else broke.
|
|
45
|
+
|
|
46
|
+
## Debugging Scratchpad Template
|
|
47
|
+
|
|
48
|
+
*Copy this into context during a debug session.*
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
## 🐞 Debug Session: [Error Name]
|
|
52
|
+
|
|
53
|
+
### 1. The Reproduction (MRE)
|
|
54
|
+
- [ ] Created `reproduce_issue.ts`
|
|
55
|
+
- [ ] Failure is deterministic (Happens every time)
|
|
56
|
+
- **Error Message**: `[Paste exact error]`
|
|
57
|
+
|
|
58
|
+
### 2. Localization (Wolf Fence)
|
|
59
|
+
- [ ] Inputs are correct? (Yes/No)
|
|
60
|
+
- [ ] Intermediate state correct? (Yes/No)
|
|
61
|
+
- **Found at**: File `X`, Line `Y`.
|
|
62
|
+
|
|
63
|
+
### 3. Root Cause Analysis (5 Whys)
|
|
64
|
+
1. Why? [Answer]
|
|
65
|
+
2. Why? [Answer]
|
|
66
|
+
3. **Root Cause**: [The fundamental flaw]
|
|
67
|
+
|
|
68
|
+
### 4. Resolution
|
|
69
|
+
- **Action**: [What did you change?]
|
|
70
|
+
- **Verification**: `npm test -- reproduce_issue.ts` -> ✅ PASS
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Anti-Patterns (Must Avoid)
|
|
74
|
+
|
|
75
|
+
- ❌ **"It should work":** Code does not care what it "should" do. It does what it is told. Look at what it is doing.
|
|
76
|
+
- ❌ **Console Log Spray:** Don't leave `console.log('here')` all over the code. Use structured logging or remove them after finding the bug.
|
|
77
|
+
- ❌ **The "Blind Fix":** Applying a StackOverflow solution without understanding *why* it applies to your specific context. (Call `researcher` first).
|
|
78
|
+
- ❌ **Ignoring Warning Logs:** Often the error is preceded by a warning 10 lines up. Read the *whole* log.
|
|
79
|
+
|
|
80
|
+
## Integration with Agents
|
|
81
|
+
|
|
82
|
+
- **`quality` agent**: If you are stuck on **Phase 1 (Reproduction)**, delegate to `quality`. *"I see the error, but I can't write a test for it. Quality Agent, please create a Cypress test for this UI bug."*
|
|
83
|
+
- **`researcher` agent**: If you are stuck on **Phase 3 (Hypothesis)**. *"I have the error 'Heap Out of Memory'. Researcher, what are the common causes for this in Node.js 18?"*
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reflexion
|
|
3
|
-
description: Post-action analysis to generate heuristics, update project memory, and prevent regression loops.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Reflexion Skill
|
|
7
|
-
|
|
8
|
-
## Purpose
|
|
9
|
-
To transform **Failures** into **Heuristics**.
|
|
10
|
-
Reflexion is the cognitive step that occurs **after** a failed attempt and **before** the next attempt. It breaks the "Insanity Loop" (doing the same thing twice expecting different results).
|
|
11
|
-
|
|
12
|
-
**ROI Metric**: Prevents 5-10 wasted attempts in a loop by forcing a strategy shift after the first failure.
|
|
13
|
-
|
|
14
|
-
## When to Use
|
|
15
|
-
- **Automatic Trigger**: After a tool error (e.g., `bash` exit code != 0).
|
|
16
|
-
- **Automatic Trigger**: After a test failure during `execution` mode.
|
|
17
|
-
- **Manual Trigger**: When the user rejects an artifact ("This isn't what I asked for").
|
|
18
|
-
- **Periodic**: At the end of a major feature (Project Retro).
|
|
19
|
-
|
|
20
|
-
## The Reflexion Protocol (The Loop)
|
|
21
|
-
|
|
22
|
-
### 1. The Halt (Stop)
|
|
23
|
-
**Rule**: *Never retry immediately.*
|
|
24
|
-
If an error occurs, you must pause. Do not simply re-run the command hoping for a different outcome.
|
|
25
|
-
|
|
26
|
-
### 2. The Trace (Diagnosis)
|
|
27
|
-
**Action**: Analyze the mismatch between *Expected Output* and *Actual Output*.
|
|
28
|
-
* *Was it a Syntax Error?* (Context failure).
|
|
29
|
-
* *Was it a Logic Error?* (Reasoning failure).
|
|
30
|
-
* *Was it a Hallucination?* (Knowledge failure).
|
|
31
|
-
|
|
32
|
-
### 3. The Heuristic (Correction)
|
|
33
|
-
**Action**: Create a new rule for yourself.
|
|
34
|
-
* *Old Thought:* "I will use `rm -rf` to clean up."
|
|
35
|
-
* *New Heuristic:* "I must check if the directory exists before attempting delete."
|
|
36
|
-
|
|
37
|
-
### 4. The Store (Memory)
|
|
38
|
-
**Action**: Save this lesson.
|
|
39
|
-
* *Short-term:* Apply to current context window.
|
|
40
|
-
* *Long-term:* Write to `.opencode/memory/patterns.md`.
|
|
41
|
-
|
|
42
|
-
## Execution Template
|
|
43
|
-
|
|
44
|
-
*Use this scratchpad when entering a Reflexion State.*
|
|
45
|
-
|
|
46
|
-
```markdown
|
|
47
|
-
## 🧠 Reflexion: [Failure Context]
|
|
48
|
-
|
|
49
|
-
### 1. Analysis
|
|
50
|
-
- **Expectation**: Test passed.
|
|
51
|
-
- **Reality**: `ReferenceError: User is not defined`
|
|
52
|
-
- **Gap**: I assumed `User` was exported from `types.ts`, but it was a default export.
|
|
53
|
-
|
|
54
|
-
### 2. Critique
|
|
55
|
-
"I failed to check the import style of the existing module before writing the import statement."
|
|
56
|
-
|
|
57
|
-
### 3. New Strategy (The Pivot)
|
|
58
|
-
- ❌ **Stop**: Guessing import paths.
|
|
59
|
-
- ✅ **Start**: Using `grep` to see how other files import `User`.
|
|
60
|
-
- **Action**: Run `grep -r "import.*User" .` before fixing.
|
|
61
|
-
|
|
62
|
-
### 4. Memory Update
|
|
63
|
-
- [ ] Add to Local Context? (Yes)
|
|
64
|
-
- [ ] Add to Project Patterns? (No - simple syntax error)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Memory Schema & Storage
|
|
68
|
-
|
|
69
|
-
Maintain a dedicated memory structure to allow the `researcher` and `pm-agent` to learn over time.
|
|
70
|
-
|
|
71
|
-
```text
|
|
72
|
-
.opencode/
|
|
73
|
-
└── memory/
|
|
74
|
-
├── active_context.md # Scratchpad for current session
|
|
75
|
-
├── patterns.md # Success patterns (What works here)
|
|
76
|
-
└── anti_patterns.md # Failure log (What breaks here)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Example: `.opencode/memory/anti_patterns.md`
|
|
80
|
-
```markdown
|
|
81
|
-
## ⛔ Anti-Patterns
|
|
82
|
-
|
|
83
|
-
### 1. Database Connections
|
|
84
|
-
- **Context**: Next.js Server Components.
|
|
85
|
-
- **Failure**: "Too many connections" error.
|
|
86
|
-
- **Lesson**: Do not instantiate Prisma Client inside the component. Use the singleton pattern defined in `src/lib/db.ts`.
|
|
87
|
-
|
|
88
|
-
### 2. Styling
|
|
89
|
-
- **Context**: Button Components.
|
|
90
|
-
- **Failure**: Tailwinds classes not applying.
|
|
91
|
-
- **Lesson**: We are using `tailwind-merge`. Standard string concatenation will fail. Always use `cn()` utility.
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Integration with Agents
|
|
95
|
-
|
|
96
|
-
- **`execution` agent**: Must trigger `reflexion` after 2 failed build attempts.
|
|
97
|
-
- *Logic:* "Attempt 1 Failed -> Retry -> Attempt 2 Failed -> **STOP & REFLECT** -> Attempt 3".
|
|
98
|
-
- **`pm-agent`**: Reads `.opencode/memory/patterns.md` at the start of a new task to load context.
|
|
99
|
-
- **`writer`**: Uses successful reflexions to update the project's `README.md` or `CONTRIBUTING.md`.
|
|
100
|
-
|
|
101
|
-
## Reflexion vs. Debugging
|
|
102
|
-
|
|
103
|
-
| Feature | `debug-protocol` | `reflexion` |
|
|
104
|
-
| :--- | :--- | :--- |
|
|
105
|
-
| **Focus** | The Code | The Agent's Process |
|
|
106
|
-
| **Goal** | Fix the Bug | Improve the Strategy |
|
|
107
|
-
| **Output** | Working Software | Better Internal Rules |
|
|
108
|
-
| **Question** | "Why is variable X null?" | "Why did I write code that made X null?" |
|
|
1
|
+
---
|
|
2
|
+
name: reflexion
|
|
3
|
+
description: Post-action analysis to generate heuristics, update project memory, and prevent regression loops.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Reflexion Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
To transform **Failures** into **Heuristics**.
|
|
10
|
+
Reflexion is the cognitive step that occurs **after** a failed attempt and **before** the next attempt. It breaks the "Insanity Loop" (doing the same thing twice expecting different results).
|
|
11
|
+
|
|
12
|
+
**ROI Metric**: Prevents 5-10 wasted attempts in a loop by forcing a strategy shift after the first failure.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
- **Automatic Trigger**: After a tool error (e.g., `bash` exit code != 0).
|
|
16
|
+
- **Automatic Trigger**: After a test failure during `execution` mode.
|
|
17
|
+
- **Manual Trigger**: When the user rejects an artifact ("This isn't what I asked for").
|
|
18
|
+
- **Periodic**: At the end of a major feature (Project Retro).
|
|
19
|
+
|
|
20
|
+
## The Reflexion Protocol (The Loop)
|
|
21
|
+
|
|
22
|
+
### 1. The Halt (Stop)
|
|
23
|
+
**Rule**: *Never retry immediately.*
|
|
24
|
+
If an error occurs, you must pause. Do not simply re-run the command hoping for a different outcome.
|
|
25
|
+
|
|
26
|
+
### 2. The Trace (Diagnosis)
|
|
27
|
+
**Action**: Analyze the mismatch between *Expected Output* and *Actual Output*.
|
|
28
|
+
* *Was it a Syntax Error?* (Context failure).
|
|
29
|
+
* *Was it a Logic Error?* (Reasoning failure).
|
|
30
|
+
* *Was it a Hallucination?* (Knowledge failure).
|
|
31
|
+
|
|
32
|
+
### 3. The Heuristic (Correction)
|
|
33
|
+
**Action**: Create a new rule for yourself.
|
|
34
|
+
* *Old Thought:* "I will use `rm -rf` to clean up."
|
|
35
|
+
* *New Heuristic:* "I must check if the directory exists before attempting delete."
|
|
36
|
+
|
|
37
|
+
### 4. The Store (Memory)
|
|
38
|
+
**Action**: Save this lesson.
|
|
39
|
+
* *Short-term:* Apply to current context window.
|
|
40
|
+
* *Long-term:* Write to `.opencode/memory/patterns.md`.
|
|
41
|
+
|
|
42
|
+
## Execution Template
|
|
43
|
+
|
|
44
|
+
*Use this scratchpad when entering a Reflexion State.*
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
## 🧠 Reflexion: [Failure Context]
|
|
48
|
+
|
|
49
|
+
### 1. Analysis
|
|
50
|
+
- **Expectation**: Test passed.
|
|
51
|
+
- **Reality**: `ReferenceError: User is not defined`
|
|
52
|
+
- **Gap**: I assumed `User` was exported from `types.ts`, but it was a default export.
|
|
53
|
+
|
|
54
|
+
### 2. Critique
|
|
55
|
+
"I failed to check the import style of the existing module before writing the import statement."
|
|
56
|
+
|
|
57
|
+
### 3. New Strategy (The Pivot)
|
|
58
|
+
- ❌ **Stop**: Guessing import paths.
|
|
59
|
+
- ✅ **Start**: Using `grep` to see how other files import `User`.
|
|
60
|
+
- **Action**: Run `grep -r "import.*User" .` before fixing.
|
|
61
|
+
|
|
62
|
+
### 4. Memory Update
|
|
63
|
+
- [ ] Add to Local Context? (Yes)
|
|
64
|
+
- [ ] Add to Project Patterns? (No - simple syntax error)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Memory Schema & Storage
|
|
68
|
+
|
|
69
|
+
Maintain a dedicated memory structure to allow the `researcher` and `pm-agent` to learn over time.
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
.opencode/
|
|
73
|
+
└── memory/
|
|
74
|
+
├── active_context.md # Scratchpad for current session
|
|
75
|
+
├── patterns.md # Success patterns (What works here)
|
|
76
|
+
└── anti_patterns.md # Failure log (What breaks here)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Example: `.opencode/memory/anti_patterns.md`
|
|
80
|
+
```markdown
|
|
81
|
+
## ⛔ Anti-Patterns
|
|
82
|
+
|
|
83
|
+
### 1. Database Connections
|
|
84
|
+
- **Context**: Next.js Server Components.
|
|
85
|
+
- **Failure**: "Too many connections" error.
|
|
86
|
+
- **Lesson**: Do not instantiate Prisma Client inside the component. Use the singleton pattern defined in `src/lib/db.ts`.
|
|
87
|
+
|
|
88
|
+
### 2. Styling
|
|
89
|
+
- **Context**: Button Components.
|
|
90
|
+
- **Failure**: Tailwinds classes not applying.
|
|
91
|
+
- **Lesson**: We are using `tailwind-merge`. Standard string concatenation will fail. Always use `cn()` utility.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Integration with Agents
|
|
95
|
+
|
|
96
|
+
- **`execution` agent**: Must trigger `reflexion` after 2 failed build attempts.
|
|
97
|
+
- *Logic:* "Attempt 1 Failed -> Retry -> Attempt 2 Failed -> **STOP & REFLECT** -> Attempt 3".
|
|
98
|
+
- **`pm-agent`**: Reads `.opencode/memory/patterns.md` at the start of a new task to load context.
|
|
99
|
+
- **`writer`**: Uses successful reflexions to update the project's `README.md` or `CONTRIBUTING.md`.
|
|
100
|
+
|
|
101
|
+
## Reflexion vs. Debugging
|
|
102
|
+
|
|
103
|
+
| Feature | `debug-protocol` | `reflexion` |
|
|
104
|
+
| :--- | :--- | :--- |
|
|
105
|
+
| **Focus** | The Code | The Agent's Process |
|
|
106
|
+
| **Goal** | Fix the Bug | Improve the Strategy |
|
|
107
|
+
| **Output** | Working Software | Better Internal Rules |
|
|
108
|
+
| **Question** | "Why is variable X null?" | "Why did I write code that made X null?" |
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: security-audit
|
|
3
|
-
description: Static Analysis and Threat Modeling skill to detect OWASP Top 10 vulnerabilities.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Security Audit Skill
|
|
7
|
-
|
|
8
|
-
## Purpose
|
|
9
|
-
To act as an automated **SAST (Static Application Security Testing)** scanner.
|
|
10
|
-
**Goal**: Identify vulnerabilities in the *implementation* phase, before the code reaches the `review` phase.
|
|
11
|
-
|
|
12
|
-
**ROI Metric**: Detecting a hardcoded secret here takes 5 seconds. Rotating a compromised key in production takes 5 hours.
|
|
13
|
-
|
|
14
|
-
## When to Use
|
|
15
|
-
- **Trigger**: When `backend` implements an endpoint involving `users`, `auth`, or `payments`.
|
|
16
|
-
- **Trigger**: When `frontend` uses `dangerouslySetInnerHTML` or similar raw HTML rendering.
|
|
17
|
-
- **Trigger**: When `pm-agent` flags a task as "High Risk."
|
|
18
|
-
- **Agent**: Primary skill for the `security` agent; secondary skill for `backend`/`review` modes.
|
|
19
|
-
|
|
20
|
-
## The Audit Protocol (The Scanner)
|
|
21
|
-
|
|
22
|
-
### 1. Pattern Scanning (The Grep Check)
|
|
23
|
-
*Scan the code for these specific "smells":*
|
|
24
|
-
|
|
25
|
-
| Risk Category | Keywords/Patterns to Flag |
|
|
26
|
-
| :--- | :--- |
|
|
27
|
-
| **Injection (RCE/XSS)** | `eval()`, `exec()`, `system()`, `dangerouslySetInnerHTML`, `innerHTML` |
|
|
28
|
-
| **SQL Injection** | String concatenation inside queries (`"SELECT... " + input`), `${var}` inside SQL strings |
|
|
29
|
-
| **Weak Crypto** | `md5`, `sha1`, `Math.random()` (for secrets), `http://` (non-TLS) |
|
|
30
|
-
| **Secrets** | `API_KEY`, `SECRET`, `PASSWORD` (assigned to hard strings) |
|
|
31
|
-
| **Debug Leftovers** | `console.log(userObj)`, `debugger`, `0.0.0.0` (binding to all interfaces) |
|
|
32
|
-
|
|
33
|
-
### 2. Logic Analysis (STRIDE)
|
|
34
|
-
*Ask these questions about the flow:*
|
|
35
|
-
* **Spoofing**: Does this verify *who* the user is? (Check: Auth Middleware presence).
|
|
36
|
-
* **Tampering**: Can I modify the payload? (Check: Zod/Joi validation `strip()` on unknown keys).
|
|
37
|
-
* **Information Disclosure**: Does the error return the stack trace? (Check: `try/catch` blocks).
|
|
38
|
-
* **Elevation of Privilege**: Does it check `user.id === resource.ownerId`? (Check: Authorization logic).
|
|
39
|
-
|
|
40
|
-
### 3. Dependency Check (Supply Chain)
|
|
41
|
-
* If `package.json` was modified:
|
|
42
|
-
* Are versions pinned? (Good: `1.2.3`, Bad: `^1.2.3`).
|
|
43
|
-
* Are there known CVEs? (Trigger `tavily` search).
|
|
44
|
-
|
|
45
|
-
## Execution Template
|
|
46
|
-
|
|
47
|
-
*Use this scratchpad to document the audit findings.*
|
|
48
|
-
|
|
49
|
-
```markdown
|
|
50
|
-
## 🔐 Security Audit Report: [File/Component]
|
|
51
|
-
|
|
52
|
-
### 1. Static Scan
|
|
53
|
-
- [ ] Checked for hardcoded secrets.
|
|
54
|
-
- [ ] Checked for raw SQL/HTML injection.
|
|
55
|
-
- [ ] Checked for dangerous functions (`eval`, `exec`).
|
|
56
|
-
|
|
57
|
-
### 2. Logic Check (OWASP)
|
|
58
|
-
- **AuthZ**: [ Verify BOLA/IDOR protection ]
|
|
59
|
-
- **Input**: [ Verify Schema Validation ]
|
|
60
|
-
- **Output**: [ Verify Data Sanitization ]
|
|
61
|
-
|
|
62
|
-
### 3. Vulnerability Findings
|
|
63
|
-
| Severity | Line | Issue | CWE ID | Remediation |
|
|
64
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
65
|
-
| 🔴 **Critical** | 42 | SQL Injection (`${id}`) | CWE-89 | Use Param: `WHERE id = $1` |
|
|
66
|
-
| 🟡 **Medium** | 15 | Missing Rate Limit | CWE-799 | Add `RateLimitMiddleware` |
|
|
67
|
-
|
|
68
|
-
### 🏁 Verdict
|
|
69
|
-
[ PASS / FAIL ] - *If Fail, do not commit.*
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Remediation Patterns (The "Fix It" Guide)
|
|
73
|
-
|
|
74
|
-
**Problem:** SQL Injection
|
|
75
|
-
❌ `db.query("SELECT * FROM users WHERE name = '" + name + "'")`
|
|
76
|
-
✅ `db.query("SELECT * FROM users WHERE name = $1", [name])`
|
|
77
|
-
|
|
78
|
-
**Problem:** XSS (React)
|
|
79
|
-
❌ `<div dangerouslySetInnerHTML={{ __html: userInput }} />`
|
|
80
|
-
✅ `<div>{userInput}</div>` or use `DOMPurify.sanitize(userInput)`
|
|
81
|
-
|
|
82
|
-
**Problem:** Broken Auth (IDOR)
|
|
83
|
-
❌ `return await db.orders.find(req.params.id)`
|
|
84
|
-
✅ `return await db.orders.find({ id: req.params.id, ownerId: req.user.id })`
|
|
85
|
-
|
|
86
|
-
## Integration with Agents
|
|
87
|
-
|
|
88
|
-
- **`security` agent**: Uses this skill as its primary method of interaction.
|
|
89
|
-
- **`backend` agent**: Must invoke `security-audit` before marking an API task as "Complete."
|
|
90
|
-
- **`review` mode**: Uses the *Findings Table* as the basis for "Critical" comments.
|
|
1
|
+
---
|
|
2
|
+
name: security-audit
|
|
3
|
+
description: Static Analysis and Threat Modeling skill to detect OWASP Top 10 vulnerabilities.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Audit Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
To act as an automated **SAST (Static Application Security Testing)** scanner.
|
|
10
|
+
**Goal**: Identify vulnerabilities in the *implementation* phase, before the code reaches the `review` phase.
|
|
11
|
+
|
|
12
|
+
**ROI Metric**: Detecting a hardcoded secret here takes 5 seconds. Rotating a compromised key in production takes 5 hours.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
- **Trigger**: When `backend` implements an endpoint involving `users`, `auth`, or `payments`.
|
|
16
|
+
- **Trigger**: When `frontend` uses `dangerouslySetInnerHTML` or similar raw HTML rendering.
|
|
17
|
+
- **Trigger**: When `pm-agent` flags a task as "High Risk."
|
|
18
|
+
- **Agent**: Primary skill for the `security` agent; secondary skill for `backend`/`review` modes.
|
|
19
|
+
|
|
20
|
+
## The Audit Protocol (The Scanner)
|
|
21
|
+
|
|
22
|
+
### 1. Pattern Scanning (The Grep Check)
|
|
23
|
+
*Scan the code for these specific "smells":*
|
|
24
|
+
|
|
25
|
+
| Risk Category | Keywords/Patterns to Flag |
|
|
26
|
+
| :--- | :--- |
|
|
27
|
+
| **Injection (RCE/XSS)** | `eval()`, `exec()`, `system()`, `dangerouslySetInnerHTML`, `innerHTML` |
|
|
28
|
+
| **SQL Injection** | String concatenation inside queries (`"SELECT... " + input`), `${var}` inside SQL strings |
|
|
29
|
+
| **Weak Crypto** | `md5`, `sha1`, `Math.random()` (for secrets), `http://` (non-TLS) |
|
|
30
|
+
| **Secrets** | `API_KEY`, `SECRET`, `PASSWORD` (assigned to hard strings) |
|
|
31
|
+
| **Debug Leftovers** | `console.log(userObj)`, `debugger`, `0.0.0.0` (binding to all interfaces) |
|
|
32
|
+
|
|
33
|
+
### 2. Logic Analysis (STRIDE)
|
|
34
|
+
*Ask these questions about the flow:*
|
|
35
|
+
* **Spoofing**: Does this verify *who* the user is? (Check: Auth Middleware presence).
|
|
36
|
+
* **Tampering**: Can I modify the payload? (Check: Zod/Joi validation `strip()` on unknown keys).
|
|
37
|
+
* **Information Disclosure**: Does the error return the stack trace? (Check: `try/catch` blocks).
|
|
38
|
+
* **Elevation of Privilege**: Does it check `user.id === resource.ownerId`? (Check: Authorization logic).
|
|
39
|
+
|
|
40
|
+
### 3. Dependency Check (Supply Chain)
|
|
41
|
+
* If `package.json` was modified:
|
|
42
|
+
* Are versions pinned? (Good: `1.2.3`, Bad: `^1.2.3`).
|
|
43
|
+
* Are there known CVEs? (Trigger `tavily` search).
|
|
44
|
+
|
|
45
|
+
## Execution Template
|
|
46
|
+
|
|
47
|
+
*Use this scratchpad to document the audit findings.*
|
|
48
|
+
|
|
49
|
+
```markdown
|
|
50
|
+
## 🔐 Security Audit Report: [File/Component]
|
|
51
|
+
|
|
52
|
+
### 1. Static Scan
|
|
53
|
+
- [ ] Checked for hardcoded secrets.
|
|
54
|
+
- [ ] Checked for raw SQL/HTML injection.
|
|
55
|
+
- [ ] Checked for dangerous functions (`eval`, `exec`).
|
|
56
|
+
|
|
57
|
+
### 2. Logic Check (OWASP)
|
|
58
|
+
- **AuthZ**: [ Verify BOLA/IDOR protection ]
|
|
59
|
+
- **Input**: [ Verify Schema Validation ]
|
|
60
|
+
- **Output**: [ Verify Data Sanitization ]
|
|
61
|
+
|
|
62
|
+
### 3. Vulnerability Findings
|
|
63
|
+
| Severity | Line | Issue | CWE ID | Remediation |
|
|
64
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
65
|
+
| 🔴 **Critical** | 42 | SQL Injection (`${id}`) | CWE-89 | Use Param: `WHERE id = $1` |
|
|
66
|
+
| 🟡 **Medium** | 15 | Missing Rate Limit | CWE-799 | Add `RateLimitMiddleware` |
|
|
67
|
+
|
|
68
|
+
### 🏁 Verdict
|
|
69
|
+
[ PASS / FAIL ] - *If Fail, do not commit.*
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Remediation Patterns (The "Fix It" Guide)
|
|
73
|
+
|
|
74
|
+
**Problem:** SQL Injection
|
|
75
|
+
❌ `db.query("SELECT * FROM users WHERE name = '" + name + "'")`
|
|
76
|
+
✅ `db.query("SELECT * FROM users WHERE name = $1", [name])`
|
|
77
|
+
|
|
78
|
+
**Problem:** XSS (React)
|
|
79
|
+
❌ `<div dangerouslySetInnerHTML={{ __html: userInput }} />`
|
|
80
|
+
✅ `<div>{userInput}</div>` or use `DOMPurify.sanitize(userInput)`
|
|
81
|
+
|
|
82
|
+
**Problem:** Broken Auth (IDOR)
|
|
83
|
+
❌ `return await db.orders.find(req.params.id)`
|
|
84
|
+
✅ `return await db.orders.find({ id: req.params.id, ownerId: req.user.id })`
|
|
85
|
+
|
|
86
|
+
## Integration with Agents
|
|
87
|
+
|
|
88
|
+
- **`security` agent**: Uses this skill as its primary method of interaction.
|
|
89
|
+
- **`backend` agent**: Must invoke `security-audit` before marking an API task as "Complete."
|
|
90
|
+
- **`review` mode**: Uses the *Findings Table* as the basis for "Critical" comments.
|