opencodekit 0.21.10 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +4 -25
- package/dist/template/.opencode/.template-manifest.json +115 -188
- package/dist/template/.opencode/AGENTS.md +127 -484
- package/dist/template/.opencode/README.md +2 -2
- package/dist/template/.opencode/agent/build.md +158 -356
- package/dist/template/.opencode/agent/explore.md +0 -1
- package/dist/template/.opencode/agent/plan.md +7 -16
- package/dist/template/.opencode/agent/review.md +0 -1
- package/dist/template/.opencode/agent/scout.md +2 -3
- package/dist/template/.opencode/agent/vision.md +0 -1
- package/dist/template/.opencode/artifacts/.active +1 -0
- package/dist/template/.opencode/artifacts/example/plan.md +12 -0
- package/dist/template/.opencode/artifacts/example/progress.md +4 -0
- package/dist/template/.opencode/artifacts/example/research.md +4 -0
- package/dist/template/.opencode/artifacts/example/spec.md +16 -0
- package/dist/template/.opencode/artifacts/todo.md +5 -0
- package/dist/template/.opencode/artifacts/verify.log +4 -0
- package/dist/template/.opencode/command/clarify.md +46 -0
- package/dist/template/.opencode/command/commit.md +53 -0
- package/dist/template/.opencode/command/create.md +29 -71
- package/dist/template/.opencode/command/design.md +1 -2
- package/dist/template/.opencode/command/explore.md +3 -4
- package/dist/template/.opencode/command/fix.md +55 -0
- package/dist/template/.opencode/command/improve-architecture.md +55 -0
- package/dist/template/.opencode/command/init.md +86 -69
- package/dist/template/.opencode/command/plan.md +30 -60
- package/dist/template/.opencode/command/pr.md +10 -28
- package/dist/template/.opencode/command/refactor.md +65 -0
- package/dist/template/.opencode/command/research.md +7 -29
- package/dist/template/.opencode/command/review-codebase.md +6 -13
- package/dist/template/.opencode/command/ship.md +136 -78
- package/dist/template/.opencode/command/test.md +66 -0
- package/dist/template/.opencode/command/ui-review.md +2 -4
- package/dist/template/.opencode/command/verify.md +15 -23
- package/dist/template/.opencode/dcp.jsonc +96 -85
- package/dist/template/.opencode/memory/README.md +4 -6
- package/dist/template/.opencode/memory/_templates/adr.md +45 -0
- package/dist/template/.opencode/memory/_templates/prd.md +1 -1
- package/dist/template/.opencode/memory/_templates/roadmap.md +1 -1
- package/dist/template/.opencode/memory/_templates/state.md +1 -1
- package/dist/template/.opencode/memory/project/gotchas.md +4 -4
- package/dist/template/.opencode/memory/project/project.md +2 -2
- package/dist/template/.opencode/memory/project/roadmap.md +1 -1
- package/dist/template/.opencode/memory/project/state.md +2 -2
- package/dist/template/.opencode/memory/project/tech-stack.md +2 -2
- package/dist/template/.opencode/memory/session-context.md +1 -1
- package/dist/template/.opencode/opencode.json +14 -152
- package/dist/template/.opencode/plugin/README.md +2 -2
- package/dist/template/.opencode/plugin/guard.ts +62 -0
- package/dist/template/.opencode/plugin/{lib/memory-admin-tools.ts → memory/admin.ts} +4 -4
- package/dist/template/.opencode/plugin/{lib → memory}/capture.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/compile.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/context.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/curator.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/observations.ts +102 -3
- package/dist/template/.opencode/plugin/{lib → memory}/db/schema.ts +43 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/types.ts +22 -0
- package/dist/template/.opencode/plugin/{lib/memory-db.ts → memory/db.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/distill.ts +1 -1
- package/dist/template/.opencode/plugin/{lib/memory-helpers.ts → memory/helpers.ts} +5 -1
- package/dist/template/.opencode/plugin/{lib/memory-hooks.ts → memory/hooks.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/index-generator.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/inject.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/lint.ts +2 -2
- package/dist/template/.opencode/plugin/memory/tools.ts +322 -0
- package/dist/template/.opencode/plugin/{lib → memory}/validate.ts +2 -2
- package/dist/template/.opencode/plugin/memory.ts +7 -17
- package/dist/template/.opencode/plugin/srcwalk.ts +721 -0
- package/dist/template/.opencode/skill/agent-code-quality-gate/SKILL.md +98 -0
- package/dist/template/.opencode/skill/behavioral-kernel/SKILL.md +52 -0
- package/dist/template/.opencode/skill/brainstorming/SKILL.md +1 -1
- package/dist/template/.opencode/skill/browser-testing-with-devtools/SKILL.md +85 -0
- package/dist/template/.opencode/skill/code-cleanup/SKILL.md +114 -0
- package/dist/template/.opencode/skill/code-navigation/SKILL.md +142 -0
- package/dist/template/.opencode/skill/code-review-and-quality/SKILL.md +131 -0
- package/dist/template/.opencode/skill/context-engineering/SKILL.md +1 -1
- package/dist/template/.opencode/skill/debugging-and-error-recovery/SKILL.md +109 -0
- package/dist/template/.opencode/skill/deep-module-design/SKILL.md +207 -0
- package/dist/template/.opencode/skill/development-lifecycle/SKILL.md +26 -45
- package/dist/template/.opencode/skill/gemini-large-context/SKILL.md +4 -4
- package/dist/template/.opencode/skill/git-workflow-and-versioning/SKILL.md +77 -0
- package/dist/template/.opencode/skill/grill-me/SKILL.md +140 -0
- package/dist/template/.opencode/skill/memory-system/SKILL.md +9 -10
- package/dist/template/.opencode/skill/opensrc/references/example-workflow.md +1 -1
- package/dist/template/.opencode/skill/planning-and-task-breakdown/SKILL.md +116 -0
- package/dist/template/.opencode/skill/shipping-and-launch/SKILL.md +95 -0
- package/dist/template/.opencode/skill/source-driven-development/SKILL.md +103 -0
- package/dist/template/.opencode/skill/spec-driven-development/SKILL.md +121 -0
- package/dist/template/.opencode/skill/srcwalk/SKILL.md +161 -0
- package/dist/template/.opencode/skill/subagent-driven-development/SKILL.md +1 -1
- package/dist/template/.opencode/skill/ubiquitous-language/SKILL.md +184 -0
- package/dist/template/.opencode/skill/using-git-worktrees/SKILL.md +6 -6
- package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +6 -6
- package/dist/template/.opencode/skill/verification-before-completion/references/VERIFICATION_PROTOCOL.md +5 -5
- package/package.json +76 -76
- package/dist/template/.opencode/AGENT_ALIGNMENT.md +0 -564
- package/dist/template/.opencode/agent/painter.md +0 -83
- package/dist/template/.opencode/command/compound.md +0 -240
- package/dist/template/.opencode/command/curate.md +0 -299
- package/dist/template/.opencode/command/handoff.md +0 -149
- package/dist/template/.opencode/command/health.md +0 -356
- package/dist/template/.opencode/command/init-context.md +0 -297
- package/dist/template/.opencode/command/init-user.md +0 -125
- package/dist/template/.opencode/command/iterate.md +0 -200
- package/dist/template/.opencode/command/lfg.md +0 -173
- package/dist/template/.opencode/command/resume.md +0 -78
- package/dist/template/.opencode/command/status.md +0 -126
- package/dist/template/.opencode/command/ui-slop-check.md +0 -169
- package/dist/template/.opencode/plans/1768385996691-silent-wizard.md +0 -247
- package/dist/template/.opencode/plans/1770006237537-mighty-otter.md +0 -418
- package/dist/template/.opencode/plans/1770006913647-glowing-forest.md +0 -170
- package/dist/template/.opencode/plans/1770013678126-witty-planet.md +0 -278
- package/dist/template/.opencode/plans/1770112267595-shiny-rocket.md +0 -258
- package/dist/template/.opencode/plans/swarm-protocol.md +0 -123
- package/dist/template/.opencode/plugin/lib/memory-tools.ts +0 -535
- package/dist/template/.opencode/skill/agent-evals/SKILL.md +0 -208
- package/dist/template/.opencode/skill/anti-ai-slop/SKILL.md +0 -76
- package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +0 -122
- package/dist/template/.opencode/skill/augment-context-engine/mcp.json +0 -6
- package/dist/template/.opencode/skill/beads/SKILL.md +0 -182
- package/dist/template/.opencode/skill/beads/references/BEST_PRACTICES.md +0 -27
- package/dist/template/.opencode/skill/beads/references/BOUNDARIES.md +0 -219
- package/dist/template/.opencode/skill/beads/references/DEPENDENCIES.md +0 -124
- package/dist/template/.opencode/skill/beads/references/EXAMPLES.md +0 -45
- package/dist/template/.opencode/skill/beads/references/FILE_CLAIMING.md +0 -101
- package/dist/template/.opencode/skill/beads/references/GIT_SYNC.md +0 -25
- package/dist/template/.opencode/skill/beads/references/HIERARCHY.md +0 -71
- package/dist/template/.opencode/skill/beads/references/MULTI_AGENT.md +0 -40
- package/dist/template/.opencode/skill/beads/references/RESUMABILITY.md +0 -177
- package/dist/template/.opencode/skill/beads/references/SESSION_PROTOCOL.md +0 -61
- package/dist/template/.opencode/skill/beads/references/TASK_CREATION.md +0 -38
- package/dist/template/.opencode/skill/beads/references/TROUBLESHOOTING.md +0 -38
- package/dist/template/.opencode/skill/beads/references/WORKFLOWS.md +0 -226
- package/dist/template/.opencode/skill/brand-asset-protocol/SKILL.md +0 -222
- package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +0 -224
- package/dist/template/.opencode/skill/code-simplification/SKILL.md +0 -211
- package/dist/template/.opencode/skill/context-condensation/SKILL.md +0 -149
- package/dist/template/.opencode/skill/context-initialization/SKILL.md +0 -69
- package/dist/template/.opencode/skill/context-management/SKILL.md +0 -390
- package/dist/template/.opencode/skill/deep-research/SKILL.md +0 -384
- package/dist/template/.opencode/skill/design-direction-advisor/SKILL.md +0 -139
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +0 -191
- package/dist/template/.opencode/skill/executing-plans/SKILL.md +0 -247
- package/dist/template/.opencode/skill/figma-go/SKILL.md +0 -65
- package/dist/template/.opencode/skill/finishing-a-development-branch/SKILL.md +0 -357
- package/dist/template/.opencode/skill/full-output-enforcement/SKILL.md +0 -62
- package/dist/template/.opencode/skill/gh-address-comments/SKILL.md +0 -29
- package/dist/template/.opencode/skill/gh-address-comments/scripts/fetch_comments.py +0 -237
- package/dist/template/.opencode/skill/gh-fix-ci/SKILL.md +0 -38
- package/dist/template/.opencode/skill/gh-fix-ci/scripts/inspect_pr_checks.py +0 -509
- package/dist/template/.opencode/skill/hi-fi-prototype-html/SKILL.md +0 -253
- package/dist/template/.opencode/skill/html-deck-export/SKILL.md +0 -189
- package/dist/template/.opencode/skill/index-knowledge/SKILL.md +0 -413
- package/dist/template/.opencode/skill/memory-grounding/SKILL.md +0 -68
- package/dist/template/.opencode/skill/playwriter/SKILL.md +0 -158
- package/dist/template/.opencode/skill/portless/SKILL.md +0 -109
- package/dist/template/.opencode/skill/prd/SKILL.md +0 -146
- package/dist/template/.opencode/skill/prd-task/SKILL.md +0 -182
- package/dist/template/.opencode/skill/prd-task/references/prd-schema.json +0 -124
- package/dist/template/.opencode/skill/prompt-leverage/SKILL.md +0 -90
- package/dist/template/.opencode/skill/prompt-leverage/references/framework.md +0 -91
- package/dist/template/.opencode/skill/prompt-leverage/scripts/augment_prompt.py +0 -157
- package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +0 -263
- package/dist/template/.opencode/skill/reconcile/SKILL.md +0 -183
- package/dist/template/.opencode/skill/reflection-checkpoints/SKILL.md +0 -183
- package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +0 -443
- package/dist/template/.opencode/skill/requesting-code-review/references/specialist-profiles.md +0 -108
- package/dist/template/.opencode/skill/requesting-code-review/review.md +0 -160
- package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +0 -134
- package/dist/template/.opencode/skill/screenshot/SKILL.md +0 -48
- package/dist/template/.opencode/skill/screenshot/scripts/ensure_macos_permissions.sh +0 -54
- package/dist/template/.opencode/skill/screenshot/scripts/macos_display_info.swift +0 -22
- package/dist/template/.opencode/skill/screenshot/scripts/macos_permissions.swift +0 -40
- package/dist/template/.opencode/skill/screenshot/scripts/macos_window_info.swift +0 -126
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.ps1 +0 -163
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.py +0 -585
- package/dist/template/.opencode/skill/security-threat-model/SKILL.md +0 -36
- package/dist/template/.opencode/skill/security-threat-model/references/prompt-template.md +0 -255
- package/dist/template/.opencode/skill/security-threat-model/references/security-controls-and-assets.md +0 -32
- package/dist/template/.opencode/skill/sharing-skills/SKILL.md +0 -214
- package/dist/template/.opencode/skill/skill-creator/SKILL.md +0 -181
- package/dist/template/.opencode/skill/skill-installer/SKILL.md +0 -58
- package/dist/template/.opencode/skill/skill-installer/scripts/github_utils.py +0 -21
- package/dist/template/.opencode/skill/skill-installer/scripts/install-skill-from-github.py +0 -313
- package/dist/template/.opencode/skill/skill-installer/scripts/list-skills.py +0 -106
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +0 -244
- package/dist/template/.opencode/skill/swarm-coordination/references/architecture.md +0 -39
- package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md +0 -145
- package/dist/template/.opencode/skill/swarm-coordination/references/dependency-graph.md +0 -50
- package/dist/template/.opencode/skill/swarm-coordination/references/drift-check.md +0 -90
- package/dist/template/.opencode/skill/swarm-coordination/references/integration-beads.md +0 -20
- package/dist/template/.opencode/skill/swarm-coordination/references/launch-flow.md +0 -186
- package/dist/template/.opencode/skill/swarm-coordination/references/reconciler.md +0 -172
- package/dist/template/.opencode/skill/swarm-coordination/references/tier-enforcement.md +0 -78
- package/dist/template/.opencode/skill/swarm-coordination/references/tmux-integration.md +0 -134
- package/dist/template/.opencode/skill/systematic-debugging/SKILL.md +0 -402
- package/dist/template/.opencode/skill/terse-output-mode/SKILL.md +0 -95
- package/dist/template/.opencode/skill/think-in-code/SKILL.md +0 -136
- package/dist/template/.opencode/skill/ux-quality-gates/SKILL.md +0 -137
- package/dist/template/.opencode/skill/v1-run/SKILL.md +0 -175
- package/dist/template/.opencode/skill/v1-run/mcp.json +0 -6
- package/dist/template/.opencode/skill/verification-gates/SKILL.md +0 -63
- package/dist/template/.opencode/skill/visual-analysis/SKILL.md +0 -154
- package/dist/template/.opencode/skill/web-design-guidelines/SKILL.md +0 -46
- package/dist/template/.opencode/skill/workspace-setup/SKILL.md +0 -76
- package/dist/template/.opencode/skill/writing-plans/SKILL.md +0 -320
- /package/dist/template/.opencode/plugin/{lib → memory}/compact.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/graph.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/maintenance.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/pipeline.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/notify.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/operation-log.ts +0 -0
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: brand-asset-protocol
|
|
3
|
-
description: Use when designing anything for a specific brand (logo, marketing site, product launch animation, branded slide deck, redesign). MUST load before producing branded visuals. Forces real logo + product image + UI screenshot fetch BEFORE any design work — color values alone are not enough for brand recognition. Includes 5-10-2-8 quality bar (5 search rounds, 10 candidates, pick 2 best, each ≥8/10).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Brand Asset Protocol
|
|
7
|
-
|
|
8
|
-
> Adapted from `huashu-design`. Brand recognition lives in **assets first, color second**. Generic CSS shapes can never substitute a real logo or product image.
|
|
9
|
-
|
|
10
|
-
## When to Use
|
|
11
|
-
|
|
12
|
-
Trigger this protocol whenever the task names a real brand or product:
|
|
13
|
-
|
|
14
|
-
- "Design a launch animation for **DJI Pocket 4**"
|
|
15
|
-
- "Redesign the **Stripe** dashboard"
|
|
16
|
-
- "Build a landing page for **Linear**"
|
|
17
|
-
- "Make a slide deck about **Anthropic Claude**"
|
|
18
|
-
- Internal client work: "Design something for **our company**"
|
|
19
|
-
|
|
20
|
-
If the task is generic ("design a SaaS landing page"), skip this skill — use `design-direction-advisor` instead.
|
|
21
|
-
|
|
22
|
-
## Prerequisite: Verify the Brand Exists First
|
|
23
|
-
|
|
24
|
-
Before fetching assets, confirm the brand/product **exists and you know its current state**. Never assert from training data — search.
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
Trigger: any specific product/version (Pocket 4, Gemini 3 Pro, new SDK, etc.)
|
|
28
|
-
Action: WebSearch "<product> launch date specs 2026" → read 1-3 authoritative results
|
|
29
|
-
Cost: 10 seconds. Skipping this can cost 1-2 hours of rework.
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Forbidden phrases that signal you should search instead of guess:
|
|
33
|
-
|
|
34
|
-
- ❌ "I think X hasn't launched yet"
|
|
35
|
-
- ❌ "X is currently version N" (without checking)
|
|
36
|
-
- ❌ "X probably doesn't exist"
|
|
37
|
-
- ✅ "Let me search for the latest state of X"
|
|
38
|
-
|
|
39
|
-
## Asset Hierarchy: Why Color Alone Fails
|
|
40
|
-
|
|
41
|
-
| Asset | Recognition contribution | Required for |
|
|
42
|
-
| ---------------------------- | ---------------------------- | ----------------------------------------- |
|
|
43
|
-
| **Logo** | Highest — instant ID | **Every** branded project |
|
|
44
|
-
| **Product photos / renders** | Very high — the "main actor" | Physical products (hardware, packaging) |
|
|
45
|
-
| **UI screenshots** | Very high — the "main actor" | Digital products (apps, SaaS, dashboards) |
|
|
46
|
-
| Color palette | Medium — easily collides | Supporting role |
|
|
47
|
-
| Typography | Low — needs the above | Supporting role |
|
|
48
|
-
| Vibe keywords | Low — internal QA only | Supporting role |
|
|
49
|
-
|
|
50
|
-
**Rule**: Pulling colors + fonts but skipping logo/product/UI → protocol violation. Generic placeholders, CSS silhouettes, or hand-drawn SVG cannot substitute real assets.
|
|
51
|
-
|
|
52
|
-
## The 5-Step Protocol (Strict Sequence)
|
|
53
|
-
|
|
54
|
-
### Step 1 — Ask (one full asset checklist, not vague "got brand guidelines?")
|
|
55
|
-
|
|
56
|
-
Send this exact list:
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
For <brand/product>, which of these do you have? (priority order)
|
|
60
|
-
1. Logo (SVG / high-res PNG) — required for any brand
|
|
61
|
-
2. Product photos / official renders — required for physical products
|
|
62
|
-
3. UI screenshots / interface assets — required for digital products
|
|
63
|
-
4. Color values (HEX / RGB / palette doc)
|
|
64
|
-
5. Font list (display / body)
|
|
65
|
-
6. Brand guidelines PDF / Figma design system / brand site URL
|
|
66
|
-
|
|
67
|
-
Send what you have; I'll fetch / generate the rest.
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Step 2 — Search Official Sources
|
|
71
|
-
|
|
72
|
-
| Asset | Where to look |
|
|
73
|
-
| --------------- | ------------------------------------------------------------------------------------------- |
|
|
74
|
-
| **Logo** | `<brand>.com/brand`, `/press`, `/press-kit`, `brand.<brand>.com`, header inline SVG |
|
|
75
|
-
| **Product img** | Product detail page hero + gallery, official YouTube launch film frames, press releases |
|
|
76
|
-
| **UI** | App Store / Play Store screenshots, official site screenshots section, demo video frames |
|
|
77
|
-
| **Colors** | Site inline CSS / Tailwind config / brand guidelines PDF |
|
|
78
|
-
| **Fonts** | `<link rel="stylesheet">` references on official site, Google Fonts trace, brand guidelines |
|
|
79
|
-
|
|
80
|
-
Fallback queries: `<brand> logo download SVG`, `<brand> press kit`, `<brand> <product> official renders`, `<brand> app screenshots`.
|
|
81
|
-
|
|
82
|
-
### Step 3 — Download (three fallback paths per asset type)
|
|
83
|
-
|
|
84
|
-
**Logo (mandatory for every brand):**
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# 1. Direct file (best)
|
|
88
|
-
curl -o assets/<brand>/logo.svg https://<brand>.com/logo.svg
|
|
89
|
-
|
|
90
|
-
# 2. Extract inline SVG from homepage HTML (~80% of cases)
|
|
91
|
-
curl -A "Mozilla/5.0" -L https://<brand>.com -o assets/<brand>/homepage.html
|
|
92
|
-
# then grep <svg>...</svg> for the logo node
|
|
93
|
-
|
|
94
|
-
# 3. Official social avatar (last resort): GitHub/Twitter/LinkedIn org image
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Product photos (mandatory for physical products):**
|
|
98
|
-
|
|
99
|
-
1. Official product page hero (right-click image URL, curl it)
|
|
100
|
-
2. Official press kit / press releases
|
|
101
|
-
3. Launch video frames (`yt-dlp` + `ffmpeg`)
|
|
102
|
-
4. Wikimedia Commons (public domain)
|
|
103
|
-
5. AI generation **using the official product photo as reference** — never replace with CSS silhouettes
|
|
104
|
-
|
|
105
|
-
**UI screenshots (mandatory for digital products):**
|
|
106
|
-
|
|
107
|
-
- App Store / Play Store product page (note: may be marketing mockups, not real UI — verify)
|
|
108
|
-
- Official site screenshots section
|
|
109
|
-
- Product demo video frames
|
|
110
|
-
- Official Twitter/X launch posts (often the latest version)
|
|
111
|
-
- Real screenshots from your own account when possible
|
|
112
|
-
|
|
113
|
-
### Step 4 — Quality Bar: The 5-10-2-8 Rule (non-Logo assets)
|
|
114
|
-
|
|
115
|
-
> Logo rules differ: any logo must be used (no logo → stop and ask user). Other assets (product photos, UI, hero imagery) follow 5-10-2-8.
|
|
116
|
-
|
|
117
|
-
| Dimension | Standard | Anti-pattern |
|
|
118
|
-
| ---------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------- |
|
|
119
|
-
| **5 search rounds** | Cross-search official site / press kit / social / YouTube / Wikimedia / user account | First page of results, stop |
|
|
120
|
-
| **10 candidates** | Gather at least 10 before filtering | Grab 2, no choice |
|
|
121
|
-
| **Pick 2 best** | Curate 2 finals from the 10 | Use everything = visual overload |
|
|
122
|
-
| **Each ≥8/10 quality** | Below 8 → use honest placeholder or AI-generate from official reference. **Better none than mediocre.** | Pad brand-spec.md with 7/10 fillers |
|
|
123
|
-
|
|
124
|
-
**8/10 scoring dimensions** (record per asset in `brand-spec.md`):
|
|
125
|
-
|
|
126
|
-
1. **Resolution** — ≥2000px (≥3000px for print/large screen)
|
|
127
|
-
2. **Copyright clarity** — official > public domain > free stock > unclear (unclear = 0)
|
|
128
|
-
3. **Brand vibe match** — consistent with the vibe keywords in `brand-spec.md`
|
|
129
|
-
4. **Lighting/composition consistency** — the 2 finals should not clash
|
|
130
|
-
5. **Standalone narrative** — each asset must independently express a narrative role, not just decorate
|
|
131
|
-
|
|
132
|
-
### Step 5 — Codify in `brand-spec.md` (single source of truth)
|
|
133
|
-
|
|
134
|
-
```markdown
|
|
135
|
-
# <Brand> · Brand Spec
|
|
136
|
-
|
|
137
|
-
> Captured: YYYY-MM-DD
|
|
138
|
-
> Sources: <list>
|
|
139
|
-
> Completeness: complete / partial / inferred
|
|
140
|
-
|
|
141
|
-
## 🎯 Core Assets (first-class)
|
|
142
|
-
|
|
143
|
-
### Logo
|
|
144
|
-
|
|
145
|
-
- Primary: `assets/<brand>/logo.svg`
|
|
146
|
-
- Inverse: `assets/<brand>/logo-white.svg`
|
|
147
|
-
- Use cases: <intro / outro / corner watermark / global>
|
|
148
|
-
- Forbidden: <no stretch / no recolor / no outline>
|
|
149
|
-
|
|
150
|
-
### Product Photos (required for physical products)
|
|
151
|
-
|
|
152
|
-
- Hero: `assets/<brand>/product-hero.png` (2000×1500)
|
|
153
|
-
- Detail: `assets/<brand>/product-detail-1.png`
|
|
154
|
-
- Scene: `assets/<brand>/product-scene.png`
|
|
155
|
-
|
|
156
|
-
### UI Screenshots (required for digital products)
|
|
157
|
-
|
|
158
|
-
- Home: `assets/<brand>/ui-home.png`
|
|
159
|
-
- Feature: `assets/<brand>/ui-feature-<name>.png`
|
|
160
|
-
|
|
161
|
-
## 🎨 Supporting Assets
|
|
162
|
-
|
|
163
|
-
### Palette
|
|
164
|
-
|
|
165
|
-
- Primary: #XXXXXX <source>
|
|
166
|
-
- Background: #XXXXXX
|
|
167
|
-
- Ink: #XXXXXX
|
|
168
|
-
- Accent: #XXXXXX
|
|
169
|
-
- Forbidden: <colors the brand explicitly avoids>
|
|
170
|
-
|
|
171
|
-
### Typography
|
|
172
|
-
|
|
173
|
-
- Display: <font stack>
|
|
174
|
-
- Body: <font stack>
|
|
175
|
-
- Mono: <font stack>
|
|
176
|
-
|
|
177
|
-
### Signature Details
|
|
178
|
-
|
|
179
|
-
- <which details are taken to 120%>
|
|
180
|
-
|
|
181
|
-
### Forbidden Zone
|
|
182
|
-
|
|
183
|
-
- <explicit "do not" rules>
|
|
184
|
-
|
|
185
|
-
### Vibe Keywords
|
|
186
|
-
|
|
187
|
-
- <3-5 adjectives>
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Execution Discipline (after spec exists)
|
|
191
|
-
|
|
192
|
-
- **All HTML must reference asset file paths from `brand-spec.md`** — no CSS silhouettes, no hand-drawn SVG substitutes.
|
|
193
|
-
- **Logo as `<img>`** referencing the real file. Never redraw.
|
|
194
|
-
- **Product photos as `<img>`** referencing real files. No CSS silhouettes.
|
|
195
|
-
- **CSS variables injected from spec**: `:root { --brand-primary: ...; }` — HTML only uses `var(--brand-*)`.
|
|
196
|
-
- This converts brand consistency from "by intent" to "by structure" — adding a new color requires editing the spec first.
|
|
197
|
-
|
|
198
|
-
## Failure Fallbacks
|
|
199
|
-
|
|
200
|
-
| Missing | Action |
|
|
201
|
-
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
202
|
-
| **Logo not findable** | **Stop and ask the user.** Logo is the foundation of brand recognition. Don't fake it. |
|
|
203
|
-
| **Product photo (physical)** | Prefer AI generation **using official reference image** → ask user → honest placeholder ("product photo TBD") as last resort |
|
|
204
|
-
| **UI screenshot (digital)** | Ask user for screenshots from their account → official demo video frames. Don't use generic mockup generators. |
|
|
205
|
-
| **Color values** | Run `design-direction-advisor` skill, recommend 3 directions with explicit assumption labels |
|
|
206
|
-
|
|
207
|
-
**Forbidden**: silently using CSS silhouettes / generic gradients when assets can't be found. **Better to stop and ask than to fake.**
|
|
208
|
-
|
|
209
|
-
## Real Failures (why this protocol exists)
|
|
210
|
-
|
|
211
|
-
- **Kimi animation**: Guessed "should be orange" from memory. Actual brand color: `#1783FF` blue. Full rework.
|
|
212
|
-
- **Lovart design**: Mistook a demo brand color in a product screenshot for Lovart's own. Almost destroyed the entire design.
|
|
213
|
-
- **DJI Pocket 4 launch animation**: Pulled colors but skipped logo + product image, used CSS silhouettes. Output was "generic black-bg + orange-accent tech animation" with zero DJI recognition. Designer's note: _"Otherwise, what are we even expressing?"_
|
|
214
|
-
|
|
215
|
-
## Cost Comparison
|
|
216
|
-
|
|
217
|
-
| Path | Time |
|
|
218
|
-
| -------------------------- | ----------------------------------------------------------------------------------- |
|
|
219
|
-
| **Run protocol correctly** | Logo 5 min + product/UI 10 min + color grep 5 min + spec write 10 min = **~30 min** |
|
|
220
|
-
| **Skip protocol** | Generic output → user rework 1-2 hours, sometimes full redo |
|
|
221
|
-
|
|
222
|
-
**The cheapest stability investment in branded design work.** For client deliverables, launch events, or important customer projects, the 30-minute protocol is insurance.
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-search-patterns
|
|
3
|
-
description: Use when navigating unfamiliar code with search-first patterns, combining built-in/LSP navigation with srcwalk CLI
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
tags: [workflow, code-quality, context, subagent]
|
|
6
|
-
dependencies: []
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Code Search Patterns
|
|
10
|
-
|
|
11
|
-
Unified navigation skill for fast, low-waste code understanding:
|
|
12
|
-
|
|
13
|
-
- **Main agent**: built-in tools + LSP + srcwalk CLI
|
|
14
|
-
- **Subagents**: Bash + `srcwalk` CLI
|
|
15
|
-
|
|
16
|
-
This skill merges practical navigation heuristics with concrete tool usage so you can locate behavior, trace impact, and edit safely with fewer calls.
|
|
17
|
-
|
|
18
|
-
## When to Use
|
|
19
|
-
|
|
20
|
-
- Exploring unfamiliar modules before editing
|
|
21
|
-
- Tracing call chains across files and directories
|
|
22
|
-
- Checking blast radius before signature/export changes
|
|
23
|
-
- Dispatching subagents that need structural code navigation
|
|
24
|
-
- Reducing token/tool-call waste during implementation
|
|
25
|
-
|
|
26
|
-
## When NOT to Use
|
|
27
|
-
|
|
28
|
-
- Trivial single-file edits where symbol location is already known
|
|
29
|
-
- Pure docs/config reads with no dependency tracing
|
|
30
|
-
- Tasks focused on external web research (use web research tools instead)
|
|
31
|
-
|
|
32
|
-
## Core Principle
|
|
33
|
-
|
|
34
|
-
> Collapse multiple tool calls into fewer, smarter ones. Every unnecessary read or search wastes tokens and turns.
|
|
35
|
-
|
|
36
|
-
## Navigation Patterns
|
|
37
|
-
|
|
38
|
-
### 1) Search First, Read Second
|
|
39
|
-
|
|
40
|
-
Start with symbol/content search to find exact locations, then read only the needed slice.
|
|
41
|
-
|
|
42
|
-
- **Good**: `search -> targeted read`
|
|
43
|
-
- **Avoid**: `read many files -> search later`
|
|
44
|
-
|
|
45
|
-
Use LSP (`findReferences`, `outgoingCalls`) or srcwalk search first; read deep only after narrowing scope.
|
|
46
|
-
|
|
47
|
-
### 2) Multi-Symbol Search
|
|
48
|
-
|
|
49
|
-
When flow spans multiple functions, query them together (`A,B,C`) instead of serial one-by-one lookups.
|
|
50
|
-
|
|
51
|
-
- Faster call-chain reconstruction
|
|
52
|
-
- Fewer repeated scans of the same files
|
|
53
|
-
|
|
54
|
-
### 3) Don’t Re-Read What Search Already Returned
|
|
55
|
-
|
|
56
|
-
If search output already includes definition body/context, proceed from it.
|
|
57
|
-
Re-read only when you need:
|
|
58
|
-
|
|
59
|
-
- exact edit anchors,
|
|
60
|
-
- additional surrounding lines,
|
|
61
|
-
- or untruncated content.
|
|
62
|
-
|
|
63
|
-
### 4) Blast Radius Check (Before Breaking Changes)
|
|
64
|
-
|
|
65
|
-
Before renaming/removing/changing signatures, inspect downstream impact first.
|
|
66
|
-
|
|
67
|
-
- LSP: `findReferences`, `incomingCalls`
|
|
68
|
-
- srcwalk: `srcwalk impact <symbol>` or `srcwalk callers <symbol>`
|
|
69
|
-
|
|
70
|
-
Then apply edits from dependents inward.
|
|
71
|
-
|
|
72
|
-
### 5) Context Locality
|
|
73
|
-
|
|
74
|
-
Prefer nearby package/module scope first.
|
|
75
|
-
|
|
76
|
-
- built-in search: constrain `path`
|
|
77
|
-
- srcwalk: pass `--scope <dir>` to restrict the scan area
|
|
78
|
-
|
|
79
|
-
Locality reduces irrelevant matches and token churn.
|
|
80
|
-
|
|
81
|
-
### 6) Outline Before Deep Read
|
|
82
|
-
|
|
83
|
-
For large files, inspect structure first (symbols/outline), then read only target sections.
|
|
84
|
-
|
|
85
|
-
- LSP: `documentSymbol`
|
|
86
|
-
- srcwalk read: smart outline by default, then section drill-in
|
|
87
|
-
|
|
88
|
-
### 7) Follow Call Chain, Not File Tree
|
|
89
|
-
|
|
90
|
-
Start at entry behavior and walk calls (`definition -> outgoing -> next definition`) instead of reading folders linearly.
|
|
91
|
-
|
|
92
|
-
This exposes real execution flow with fewer reads.
|
|
93
|
-
|
|
94
|
-
## srcwalk CLI
|
|
95
|
-
|
|
96
|
-
`srcwalk` is available to all agents (main agent and subagents) via Bash. It combines grep + tree-sitter AST into one CLI tool.
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
srcwalk guide # Print agent routing policy (run once per session)
|
|
100
|
-
srcwalk find <symbol> # Symbol search (definitions + usages)
|
|
101
|
-
srcwalk <file> # Smart file read (outline for large files)
|
|
102
|
-
srcwalk map # Codebase structural overview
|
|
103
|
-
srcwalk files '<glob>' # Find files by pattern
|
|
104
|
-
srcwalk callers <sym> # Reverse call graph
|
|
105
|
-
srcwalk impact <sym> # Blast-radius heuristic
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Auto-detection
|
|
109
|
-
|
|
110
|
-
| Query shape | Auto-detected action |
|
|
111
|
-
| --------------------------------- | ------------------------------------ |
|
|
112
|
-
| Existing file path (`src/foo.ts`) | Read file (smart outline/full) |
|
|
113
|
-
| Identifier (`initCommand`) | Symbol search (definitions + usages) |
|
|
114
|
-
| `find <symbol>` | Explicit symbol search |
|
|
115
|
-
| `files <glob>` | File discovery |
|
|
116
|
-
|
|
117
|
-
### Core operations
|
|
118
|
-
|
|
119
|
-
#### 1) Read file
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
srcwalk src/index.ts
|
|
123
|
-
srcwalk src/index.ts --full
|
|
124
|
-
srcwalk src/index.ts --section 45-89
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### 2) Search symbols
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
srcwalk find initCommand --scope src/
|
|
131
|
-
srcwalk find "initCommand,detectMode" --scope src/
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### 3) Search text/regex
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
srcwalk find "TODO" --scope src/
|
|
138
|
-
srcwalk find "/TODO.*fix/" --scope src/
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### 4) Find callers
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
srcwalk callers initCommand --scope src/
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### 5) List files
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
srcwalk files "*.test.ts" --scope src/
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### 6) Blast radius
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
srcwalk impact initCommand --scope src/
|
|
157
|
-
srcwalk callers initCommand --scope src/
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
#### 7) Codebase map
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
srcwalk map --scope src/
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Useful flags
|
|
167
|
-
|
|
168
|
-
| Flag | Purpose | Example |
|
|
169
|
-
| ----------------------- | --------------------------------------------- | ----------------------------------- |
|
|
170
|
-
| `--scope <dir>` | Restrict scan area | `--scope src/commands/` |
|
|
171
|
-
| `--section <range\|sym>` | Targeted file slice (line range or symbol) | `--section 120-180`, `--section fn` |
|
|
172
|
-
| `--full` | Force full file output (no outline) | `--full` |
|
|
173
|
-
| `--budget <n>` | Limit output token size | `--budget 2000` |
|
|
174
|
-
| `--json` | Machine-readable output | `--json` |
|
|
175
|
-
| `--filter <qualifiers>` | Filter find results by field:value | `--filter kind:fn` |
|
|
176
|
-
| `--glob <pattern>` | File pattern filter within find | `--glob "*.ts"` |
|
|
177
|
-
| `--expand[=<n>]` | Inline source for top N matches | `--expand 3` |
|
|
178
|
-
| `--depth <n>` | Depth for callers/callees traversal | `--depth 2` |
|
|
179
|
-
|
|
180
|
-
### Example subagent dispatch
|
|
181
|
-
|
|
182
|
-
```ts
|
|
183
|
-
task({
|
|
184
|
-
subagent_type: "general",
|
|
185
|
-
prompt: `Use srcwalk via Bash for navigation.
|
|
186
|
-
|
|
187
|
-
1) Locate symbol and usages:
|
|
188
|
-
srcwalk find initCommand --scope src/
|
|
189
|
-
|
|
190
|
-
2) Find callers:
|
|
191
|
-
srcwalk callers initCommand --scope src/
|
|
192
|
-
|
|
193
|
-
3) Check blast radius before edits:
|
|
194
|
-
srcwalk impact initCommand --scope src/
|
|
195
|
-
|
|
196
|
-
4) Read only the relevant section:
|
|
197
|
-
srcwalk src/commands/init.ts --section 500-620
|
|
198
|
-
|
|
199
|
-
Then implement the requested change with minimal file edits.`,
|
|
200
|
-
});
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Cost Awareness
|
|
204
|
-
|
|
205
|
-
Navigation cost compounds quickly. Optimize for fewer, richer calls.
|
|
206
|
-
|
|
207
|
-
- Prefer one structural search over multiple blind reads
|
|
208
|
-
- Reuse search output; avoid duplicate reads of the same symbol body
|
|
209
|
-
- Scope aggressively (`path`, `scope`) to cut noise
|
|
210
|
-
- Use section reads for large files instead of full-file pulls
|
|
211
|
-
|
|
212
|
-
Target heuristic: understand a symbol and its direct impact in **≤3 calls** whenever possible.
|
|
213
|
-
|
|
214
|
-
## Common Mistakes
|
|
215
|
-
|
|
216
|
-
| Mistake | Better pattern |
|
|
217
|
-
| ------------------------------------------------ | ------------------------------------------------------------------- |
|
|
218
|
-
| Reading big files before locating symbol | Search first, then section read |
|
|
219
|
-
| Re-reading code already shown in search output | Work from returned snippet; re-read only if needed for edit anchors |
|
|
220
|
-
| Serially tracing one function at a time | Multi-symbol search + callers/deps |
|
|
221
|
-
| Ignoring blast radius before API/signature edits | Run references/incoming/deps first |
|
|
222
|
-
| Unscoped repository-wide search | Use `path`/`--scope` to localize |
|
|
223
|
-
| Using CLI defaults when mode is ambiguous | Use explicit subcommand (`find`, `files`, `callers`) or `--filter kind:<label>` |
|
|
224
|
-
| Overusing `--full` on large files | Outline first, then `--section` |
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-simplification
|
|
3
|
-
description: Use when reducing code complexity, eliminating dead code, or refactoring for clarity — enforces measure-before-cutting discipline to prevent breaking changes disguised as cleanup
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
tags: [code-quality, refactoring]
|
|
6
|
-
dependencies: [verification-before-completion]
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Code Simplification
|
|
10
|
-
|
|
11
|
-
> **Replaces** ad-hoc "cleanup" refactors that introduce bugs — enforces systematic simplification with verification at every step
|
|
12
|
-
|
|
13
|
-
## When to Use
|
|
14
|
-
|
|
15
|
-
- Code is harder to understand than it needs to be
|
|
16
|
-
- Functions are too long (>50 lines), files are too large (>500 lines)
|
|
17
|
-
- Dead code, unused imports, or unnecessary abstractions exist
|
|
18
|
-
- You're asked to "clean up" or "simplify" a module
|
|
19
|
-
- Complexity is making bugs harder to fix
|
|
20
|
-
|
|
21
|
-
## When NOT to Use
|
|
22
|
-
|
|
23
|
-
- The code works, is readable, and isn't blocking anything — leave it alone
|
|
24
|
-
- You're implementing a new feature (use incremental-implementation instead)
|
|
25
|
-
- The "simplification" is actually a rewrite with different behavior
|
|
26
|
-
|
|
27
|
-
## Common Rationalizations
|
|
28
|
-
|
|
29
|
-
| Rationalization | Rebuttal |
|
|
30
|
-
| -------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
31
|
-
| "This code is ugly, let me rewrite it" | Ugly but working > beautiful but broken. Simplify incrementally, not wholesale |
|
|
32
|
-
| "Nobody uses this, I'll delete it" | Verify with grep/find-references FIRST. "Nobody uses this" is the #1 cause of breakage |
|
|
33
|
-
| "I'll simplify it while I'm in here" | Mixing feature work with refactoring makes both harder to review and revert |
|
|
34
|
-
| "This abstraction isn't needed" | Check if it serves a testing, extension, or boundary purpose before removing |
|
|
35
|
-
| "I can make this more elegant" | Elegant for whom? Optimize for the next reader, not for cleverness |
|
|
36
|
-
| "The tests will catch any issues" | Tests cover known behavior. Simplification can change behavior in ways tests don't cover |
|
|
37
|
-
|
|
38
|
-
## Overview
|
|
39
|
-
|
|
40
|
-
Code simplification is the discipline of making code easier to understand and maintain WITHOUT changing its behavior. The key word is discipline — undisciplined simplification introduces bugs.
|
|
41
|
-
|
|
42
|
-
**Core principle:** Measure complexity, simplify the worst offender, verify nothing broke, repeat.
|
|
43
|
-
|
|
44
|
-
## The Process
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
1. MEASURE — Identify what's actually complex (not just what feels complex)
|
|
48
|
-
2. ISOLATE — Pick ONE simplification target
|
|
49
|
-
3. VERIFY — Ensure tests exist for current behavior
|
|
50
|
-
4. SIMPLIFY — Apply the smallest change that reduces complexity
|
|
51
|
-
5. CONFIRM — Run full verification to prove behavior is unchanged
|
|
52
|
-
6. REPEAT — Pick the next target
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Complexity Signals
|
|
56
|
-
|
|
57
|
-
| Signal | Threshold | Action |
|
|
58
|
-
| --------------------- | ---------------- | ------------------------------------------- |
|
|
59
|
-
| Function length | >50 lines | Extract helper functions |
|
|
60
|
-
| File length | >500 lines | Split into modules |
|
|
61
|
-
| Nesting depth | >3 levels | Flatten with early returns or extract |
|
|
62
|
-
| Parameter count | >4 params | Use an options object |
|
|
63
|
-
| Cyclomatic complexity | >10 per function | Break into smaller functions |
|
|
64
|
-
| Dead code | Any | Remove after verifying with find-references |
|
|
65
|
-
| Unused imports | Any | Remove (linter usually catches these) |
|
|
66
|
-
| Duplicate code | 3+ copies | Extract shared function |
|
|
67
|
-
|
|
68
|
-
## Simplification Patterns
|
|
69
|
-
|
|
70
|
-
### Extract Function
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
// BEFORE: Long function with embedded logic
|
|
74
|
-
function processOrder(order: Order) {
|
|
75
|
-
// 20 lines of validation
|
|
76
|
-
// 15 lines of pricing
|
|
77
|
-
// 10 lines of notification
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// AFTER: Named steps
|
|
81
|
-
function processOrder(order: Order) {
|
|
82
|
-
validateOrder(order);
|
|
83
|
-
const total = calculateTotal(order);
|
|
84
|
-
notifyCustomer(order, total);
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Early Return (Flatten Nesting)
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
// BEFORE: Deep nesting
|
|
92
|
-
function getUser(id: string) {
|
|
93
|
-
if (id) {
|
|
94
|
-
const user = db.find(id);
|
|
95
|
-
if (user) {
|
|
96
|
-
if (user.active) {
|
|
97
|
-
return user;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// AFTER: Guard clauses
|
|
105
|
-
function getUser(id: string) {
|
|
106
|
-
if (!id) return null;
|
|
107
|
-
const user = db.find(id);
|
|
108
|
-
if (!user) return null;
|
|
109
|
-
if (!user.active) return null;
|
|
110
|
-
return user;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Remove Dead Code
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
1. Search: grep/find-references for the symbol
|
|
118
|
-
2. Verify: No callers exist (check tests too)
|
|
119
|
-
3. Remove: Delete the code
|
|
120
|
-
4. Confirm: All tests still pass
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**NEVER assume code is dead without searching.** Check:
|
|
124
|
-
|
|
125
|
-
- Direct calls
|
|
126
|
-
- Dynamic references (string-based lookups, reflection)
|
|
127
|
-
- Test-only usage
|
|
128
|
-
- Configuration references
|
|
129
|
-
|
|
130
|
-
### Inline Unnecessary Abstraction
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
// BEFORE: Wrapper that adds nothing
|
|
134
|
-
function getUserName(user: User): string {
|
|
135
|
-
return user.name;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// AFTER: Just use the property directly
|
|
139
|
-
user.name;
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Only inline if the abstraction doesn't serve a testing, boundary, or extension purpose.
|
|
143
|
-
|
|
144
|
-
### Replace Conditional with Early Exit
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
// BEFORE
|
|
148
|
-
function handle(input: string) {
|
|
149
|
-
let result = "";
|
|
150
|
-
if (isValid(input)) {
|
|
151
|
-
result = transform(input);
|
|
152
|
-
} else {
|
|
153
|
-
throw new Error("Invalid");
|
|
154
|
-
}
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// AFTER
|
|
159
|
-
function handle(input: string) {
|
|
160
|
-
if (!isValid(input)) throw new Error("Invalid");
|
|
161
|
-
return transform(input);
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## What NOT to Simplify
|
|
166
|
-
|
|
167
|
-
- **Working error handling** — even if verbose, it's there for a reason
|
|
168
|
-
- **Compatibility shims** — they exist because something needs them
|
|
169
|
-
- **Performance-critical paths** — "simpler" may mean "slower"
|
|
170
|
-
- **Code with extensive test coverage pointing at specific behavior** — the tests document WHY it's complex
|
|
171
|
-
- **Other people's current work** — don't simplify files with active PRs
|
|
172
|
-
|
|
173
|
-
## Red Flags — STOP
|
|
174
|
-
|
|
175
|
-
If you catch yourself:
|
|
176
|
-
|
|
177
|
-
- Changing behavior while "simplifying"
|
|
178
|
-
- Removing code without checking references first
|
|
179
|
-
- Simplifying more than one thing per commit
|
|
180
|
-
- "Cleaning up" files you weren't asked to touch
|
|
181
|
-
- Making the code "more elegant" without a clear readability improvement
|
|
182
|
-
|
|
183
|
-
**STOP.** Revert the current change and pick a smaller target.
|
|
184
|
-
|
|
185
|
-
## Verification
|
|
186
|
-
|
|
187
|
-
Before each simplification:
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
# Ensure tests exist for current behavior
|
|
191
|
-
npm test -- --related [file]
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
After each simplification:
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
npm run typecheck
|
|
198
|
-
npm run lint
|
|
199
|
-
npm test
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**If ANY test fails, the simplification changed behavior.** Either:
|
|
203
|
-
|
|
204
|
-
1. The simplification is wrong — revert it
|
|
205
|
-
2. The test is testing implementation details — fix the test, but document WHY
|
|
206
|
-
|
|
207
|
-
## See Also
|
|
208
|
-
|
|
209
|
-
- **incremental-implementation** — Build new features in slices; simplify afterward
|
|
210
|
-
- **systematic-debugging** — When simplification reveals hidden bugs
|
|
211
|
-
- **defense-in-depth** — When simplifying validation, ensure all layers still hold
|