super-opencode 1.1.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.
Files changed (36) hide show
  1. package/.opencode/agents/architect.md +84 -0
  2. package/.opencode/agents/backend.md +124 -0
  3. package/.opencode/agents/frontend.md +137 -0
  4. package/.opencode/agents/optimizer.md +51 -0
  5. package/.opencode/agents/pm-agent.md +105 -0
  6. package/.opencode/agents/quality.md +107 -0
  7. package/.opencode/agents/researcher.md +105 -0
  8. package/.opencode/agents/reviewer.md +80 -0
  9. package/.opencode/agents/security.md +107 -0
  10. package/.opencode/agents/writer.md +136 -0
  11. package/.opencode/commands/soc-analyze.md +137 -0
  12. package/.opencode/commands/soc-brainstorm.md +110 -0
  13. package/.opencode/commands/soc-cleanup.md +107 -0
  14. package/.opencode/commands/soc-design.md +122 -0
  15. package/.opencode/commands/soc-explain.md +113 -0
  16. package/.opencode/commands/soc-git.md +104 -0
  17. package/.opencode/commands/soc-help.md +94 -0
  18. package/.opencode/commands/soc-implement.md +112 -0
  19. package/.opencode/commands/soc-improve.md +105 -0
  20. package/.opencode/commands/soc-pm.md +99 -0
  21. package/.opencode/commands/soc-research.md +105 -0
  22. package/.opencode/commands/soc-review.md +102 -0
  23. package/.opencode/commands/soc-test.md +109 -0
  24. package/.opencode/commands/soc-workflow.md +97 -0
  25. package/.opencode/settings.json +3 -0
  26. package/.opencode/skills/confidence-check/SKILL.md +97 -0
  27. package/.opencode/skills/debug-protocol/SKILL.md +83 -0
  28. package/.opencode/skills/reflexion/SKILL.md +108 -0
  29. package/.opencode/skills/security-audit/SKILL.md +90 -0
  30. package/.opencode/skills/self-check/SKILL.md +95 -0
  31. package/.opencode/skills/simplification/SKILL.md +92 -0
  32. package/AGENTS.md +175 -0
  33. package/LICENSE +21 -0
  34. package/README.md +288 -0
  35. package/dist/cli.js +403 -0
  36. package/package.json +45 -0
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: confidence-check
3
+ description: Pre-execution risk assessment to prevent hallucinations and architectural drift.
4
+ ---
5
+
6
+ # Confidence Check Skill
7
+
8
+ ## Purpose
9
+ To calculate a probabilistic "Success Score" (0.0 - 1.0) **before** generating code. This acts as a circuit breaker for the `execution` mode.
10
+
11
+ **ROI Metric**: A 200-token analysis prevents 2,000+ tokens of incorrect code generation and subsequent debugging time.
12
+
13
+ ## When to Use
14
+ - **Automatic Trigger**: Before any `write_file` operation affecting > 50 lines of code.
15
+ - **Manual Trigger**: When requirements are vague (e.g., "Fix the bug").
16
+ - **Agent Handoff**: When `pm-agent` assigns a task to `backend` or `frontend`.
17
+
18
+ ## The 5 Pillars of Confidence
19
+
20
+ | Pillar | Weight | Verification Action | Related Agent |
21
+ | :--- | :--- | :--- | :--- |
22
+ | **1. Context Awareness** | 25% | Have I read *all* related files? (grep/read_file) | `pm-agent` |
23
+ | **2. Specification** | 25% | Do I have a clear Interface/Schema? (Zod/Types) | `architect` |
24
+ | **3. Ground Truth** | 20% | Do I have *current* docs? (No hallucinations) | `researcher` |
25
+ | **4. Pattern Matching** | 15% | Does this match existing project style? | `review` |
26
+ | **5. Impact Analysis** | 15% | Do I know what this might break? | `quality` |
27
+
28
+ ## Scoring & Protocols
29
+
30
+ ### 🟢 High Confidence (≄ 0.90)
31
+ **Action**: **PROCEED** to `execution` mode.
32
+ * *Definition:* You have the file paths, the schema is defined, you have verified the library version, and you have a rollback plan.
33
+
34
+ ### 🟔 Medium Confidence (0.70 - 0.89)
35
+ **Action**: **REFINE** before coding.
36
+ * *Protocol:* Identify the weak pillar and fix it.
37
+ * *Weak Docs?* -> Trigger `researcher` to fetch API refs.
38
+ * *Weak Specs?* -> Trigger `architect` to define the interface.
39
+ * *Weak Context?* -> Run `grep` to find usages.
40
+
41
+ ### šŸ”“ Low Confidence (< 0.70)
42
+ **Action**: **HALT**.
43
+ * *Protocol:* Do not write code. Return control to `pm-agent` or ask the user clarifying questions.
44
+ * *Example:* "I cannot proceed. I do not know the expected return type of the API, and I cannot find a design pattern for this module."
45
+
46
+ ## Execution Template
47
+
48
+ *Copy this mental scratchpad into your context window before coding.*
49
+
50
+ ```markdown
51
+ ## šŸ›”ļø Pre-Flight Confidence Check
52
+
53
+ ### 1. Context Audit (25%)
54
+ - [ ] Mapped dependency tree? (Yes/No)
55
+ - [ ] Checked for duplicate logic via `grep`? (Yes/No)
56
+ - **Score: __ / 0.25**
57
+
58
+ ### 2. Spec Validation (25%)
59
+ - [ ] Is the Input/Output clearly typed (TypeScript/Zod)?
60
+ - [ ] Does an ADR or RFC exist for this?
61
+ - **Score: __ / 0.25** -> *If 0, consult `architect`*
62
+
63
+ ### 3. Documentation Reality (20%)
64
+ - [ ] Did I look up the library docs *today*?
65
+ - [ ] Am I guessing the API syntax?
66
+ - **Score: __ / 0.20** -> *If 0, consult `researcher`*
67
+
68
+ ### 4. Local Patterns (15%)
69
+ - [ ] Am I using the project's established styling/naming?
70
+ - **Score: __ / 0.15**
71
+
72
+ ### 5. Risk Assessment (15%)
73
+ - [ ] If this fails, does the app crash or just error out?
74
+ - [ ] Do I have a test case ready to verify this?
75
+ - **Score: __ / 0.15** -> *If 0, consult `quality`*
76
+
77
+ ### šŸ Final Score: [ 0.00 - 1.00 ]
78
+ **Verdict:** [ PROCEED / REFINE / HALT ]
79
+ ```
80
+
81
+ ## Scenario Examples
82
+
83
+ ### Scenario A: Adding a new API Endpoint
84
+ * **Context**: Read `server.ts`? Yes.
85
+ * **Spec**: No request schema defined. (**0**)
86
+ * **Docs**: Know Express well. (0.2)
87
+ * **Pattern**: Copied existing controller style. (0.15)
88
+ * **Risk**: Low. (0.15)
89
+ * **Total**: **0.75 (Medium)**
90
+ * **Action**: *STOP. Call `backend` agent to define Zod schema first. Then Proceed.*
91
+
92
+ ### Scenario B: "Fix the white screen"
93
+ * **Context**: No error logs provided. (**0**)
94
+ * **Spec**: Unknown. (**0**)
95
+ * **Docs**: N/A.
96
+ * **Total**: **0.15 (Low)**
97
+ * **Action**: *HALT. Ask user for logs or reproduction steps. Trigger `brainstorming` mode.*
@@ -0,0 +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?"*
@@ -0,0 +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?" |
@@ -0,0 +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.
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: self-check
3
+ description: Post-implementation validation to enforce the Definition of Done (DoD) and prevent hallucinations.
4
+ ---
5
+
6
+ # Self-Check Skill
7
+
8
+ ## Purpose
9
+ To validate work **after** implementation but **before** handoff.
10
+ This is the "Check" in PDCA. It prevents the "It works on my machine" (or "It works in my context window") syndrome.
11
+
12
+ **ROI Metric**: Catching a syntax error here costs 50 tokens. Catching it in a PR review costs 5,000 tokens + human time.
13
+
14
+ ## When to Use
15
+ - **Trigger**: Immediately after `execution` mode finishes writing code.
16
+ - **Trigger**: Before the `backend` agent hands off to `frontend`.
17
+ - **Trigger**: Before any `git commit`.
18
+
19
+ ## The "Proof of Work" Protocol
20
+
21
+ ### 1. The Build Check (Syntax)
22
+ **Rule**: *Code that doesn't build doesn't exist.*
23
+ - Did you run the build/transpile command? (`npm run build`, `go build`, etc.)
24
+ - **Evidence**: Paste the exit code and the last 3 lines of output.
25
+
26
+ ### 2. The Logic Check (Behavior)
27
+ **Rule**: *Claims require proof.*
28
+ - **Forbidden Phrase**: "I ran the tests and they passed." (This is often a hallucination).
29
+ - **Required Action**: Run the test command via `run_command` and capture the actual output.
30
+ - **Evidence**: Paste the `Total: X Passed, 0 Failed` line.
31
+
32
+ ### 3. The Contract Check (Requirements)
33
+ **Rule**: *Did you solve the user's problem?*
34
+ - Map every constraint from the original prompt to a specific line of code or test case.
35
+
36
+ ### 4. The Hygiene Check (Cleanup)
37
+ **Rule**: *Leave no trace.*
38
+ - Scan for: `console.log("here")`, `debugger`, commented out code blocks, or `TODO` comments added by you.
39
+ - **Action**: Remove them.
40
+
41
+ ## Execution Template
42
+
43
+ *Copy this into the context window to validate your work.*
44
+
45
+ ```markdown
46
+ ## āœ… Self-Check Validation
47
+
48
+ ### 1. Build Verification
49
+ - **Command**: `npm run build`
50
+ - **Output**:
51
+ ```text
52
+ > build
53
+ > tsc
54
+ ✨ Done in 2.45s.
55
+ ```
56
+ - **Status**: [ PASS / FAIL ]
57
+
58
+ ### 2. Test Verification
59
+ - **Command**: `npm test -- user.service.test.ts`
60
+ - **Output**:
61
+ ```text
62
+ PASS src/services/user.service.test.ts
63
+ Tests: 3 passed, 3 total
64
+ ```
65
+ - **Status**: [ PASS / FAIL ] -> *If FAIL, trigger `reflexion` skill.*
66
+
67
+ ### 3. Requirements Mapping
68
+ | Requirement | Implemented? | Evidence (File/Line) |
69
+ | :--- | :--- | :--- |
70
+ | "Users must have a role" | āœ… | `UserSchema.ts:12` (Zod enum) |
71
+ | "Passwords must be hashed" | āœ… | `AuthService.ts:45` (bcrypt call) |
72
+
73
+ ### 4. Code Hygiene
74
+ - [ ] Removed debug `console.log`s?
75
+ - [ ] Removed temporary comments?
76
+ - [ ] Ran Linter? (`npm run lint`)
77
+
78
+ ### šŸ Final Verdict: [ READY TO SHIP / NEEDS FIXING ]
79
+
80
+ ## Red Flags (Hallucination Detection)
81
+
82
+ If you see these patterns in your own reasoning, **STOP**:
83
+
84
+ | Red Flag | Why It's Bad | Correction |
85
+ | :--- | :--- | :--- |
86
+ | *"The code looks correct."* | Visual inspection is insufficient. | Run the code. |
87
+ | *"I updated the tests."* | Did you *run* them? | Run the tests. |
88
+ | *"This should fix the error."* | Hope is not a strategy. | Verify the fix. |
89
+ | *"I'll assume the DB is running."* | Assumption is the mother of all failures. | Check connection. |
90
+
91
+ ## Integration with Agents
92
+
93
+ - **`execution` mode**: Must run `self-check` before declaring `Status: COMPLETE`.
94
+ - **`pm-agent`**: Rejects any task update that does not include a `self-check` artifact.
95
+ - **`reflexion` skill**: If `self-check` results in **FAIL**, the agent must immediately enter `reflexion` mode to analyze the root cause before retrying.
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: simplification
3
+ description: Complexity reduction and architectural streamlining for Frontend, Backend, and Quality agents.
4
+ ---
5
+
6
+ # Simplification Skill (Occam's Razor)
7
+
8
+ ## Purpose
9
+ "Simplicity is the ultimate sophistication." This skill provides a rigorous protocol for identifying and eliminating over-engineering, code bloat, and technical debt across the entire stack.
10
+
11
+ ## Overview
12
+ The Simplification Skill is a cross-functional protocol used to flatten logic, reduce state, and ensure every line of code justifies its existence. It leverages specialized agents and MCP tools to validate architectural simplicity and performance.
13
+
14
+ ## Prerequisites
15
+ - **Agents**: [Backend](file:///.opencode/agents/backend.md), [Frontend](file:///.opencode/agents/frontend.md), [Quality](file:///.opencode/agents/quality.md).
16
+ - **MCP Tools**:
17
+ - `context7`: To research lightweight alternatives and library standards.
18
+ - `sequential-thinking`: To audit complex logic flows for potential flattening.
19
+ - `sqlite`: To verify if database schemas or queries can be compressed.
20
+ - `playwright`/`chrome-devtools`: To identify UI "jank" or DOM complexity.
21
+
22
+ ## Agent-Specific Simplification Protocols
23
+
24
+ ### [Senior Backend Engineer](file:///.opencode/agents/backend.md)
25
+ - **State Reduction**: Derive values instead of storing them. If `is_active` can be derived from `status === 'active'`, delete the redundant field.
26
+ - **Query Optimization**: Use `sqlite` to check for N+1 issues. Replace nested loops with single optimized queries or batching.
27
+ - **Error Flattening**: Centralize error handling middleware. Remove repetitive `try/catch` blocks from business logic to expose the "Happy Path".
28
+
29
+ ### [Senior Frontend Engineer](file:///.opencode/agents/frontend.md)
30
+ - **DOM Streamlining**: Replace "Div Soup" with semantic HTML elements.
31
+ - **Hook Optimization**: Audit `useEffect` usage. If it's used to sync state, replace it with derived constants or `useMemo`.
32
+ - **Styling Discipline**: Replace custom inline styles with standard Tailwind utility classes or `cva` variants.
33
+
34
+ ### [QA Automation Engineer](file:///.opencode/agents/quality.md)
35
+ - **Test Pruning**: Remove redundant unit tests if the logic is covered by a high-confidence integration test.
36
+ - **Selector Simplification**: Replace fragile XPaths or class-based selectors with accessible `getByRole` or `getByLabel` locators.
37
+
38
+ ## The Procedural Workflow
39
+
40
+ ### 1. The Deletion Test
41
+ - **Action**: Use `grep_search` to find references to the target code. If references < 1, **DELETE**.
42
+ - **Rule**: Dead code is the best code.
43
+
44
+ ### 2. The Library Leverage (via `context7`)
45
+ - **Action**: Use `context7` to check if a complex custom utility (e.g., date formatting, deep cloning) can be replaced by a native function or a lightweight standard library (Lodash/Zustand).
46
+
47
+ ### 3. Flat Logic Audit (via `sequential-thinking`)
48
+ - **Action**: Step through the logic. If nesting > 3 levels or cyclomatic complexity is high, apply guard clauses.
49
+ - **Target Pattern**:
50
+ ```diff
51
+ - if (user) {
52
+ - if (user.active) {
53
+ - return doThing();
54
+ - }
55
+ - }
56
+ + if (!user?.active) return;
57
+ + return doThing();
58
+ ```
59
+
60
+ ## Complexity Metrics to Watch
61
+ - **Nesting Level**: Maximum 3 levels of indentation.
62
+ - **Function Size**: Maximum 30 lines.
63
+ - **Cognitive Weight**: If a function requires `sequential-thinking` just to "read" it, it's too complex.
64
+
65
+ ## Output Format
66
+
67
+ ```markdown
68
+ ## Simplification Review: [Target File/Function]
69
+
70
+ ### 1. Opportunities Identified
71
+ | Area | Description | Tool Used | Impact |
72
+ |------|-------------|-----------|--------|
73
+ | Logic | Flatten nested `if` statements | `sequential-thinking` | High |
74
+ | State | Remove redundant `isLoading` boolean | - | Medium |
75
+ | Lib | Replace custom deep clone with `structuredClone` | `context7` | Low |
76
+
77
+ ### 2. Implementation: Before vs After
78
+ **Before**:
79
+ ```javascript
80
+ // Complex, nested, or redundant code
81
+ ```
82
+
83
+ **After**:
84
+ ```javascript
85
+ // Streamlined, readable, and efficient code
86
+ ```
87
+
88
+ ### 3. Impact Assessment
89
+ - Lines Removed: [Count]
90
+ - Performance Gain: [e.g., Reduced O(N²) to O(N)]
91
+ - Maintenance Status: Optimized
92
+ ```