@simplysm/sd-claude 13.0.74 → 13.0.76
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/claude/refs/sd-code-conventions.md +92 -2
- package/claude/refs/sd-solid.md +2 -0
- package/claude/refs/sd-workflow.md +2 -1
- package/claude/rules/sd-claude-rules.md +21 -0
- package/claude/rules/sd-refs-linker.md +1 -1
- package/claude/sd-statusline.js +53 -11
- package/claude/skills/sd-api-name-review/SKILL.md +22 -3
- package/claude/skills/sd-brainstorm/SKILL.md +90 -1
- package/claude/skills/sd-check/SKILL.md +30 -14
- package/claude/skills/sd-commit/SKILL.md +0 -1
- package/claude/skills/sd-debug/SKILL.md +14 -13
- package/claude/skills/sd-explore/SKILL.md +76 -0
- package/claude/skills/sd-plan/SKILL.md +32 -0
- package/claude/skills/sd-plan-dev/SKILL.md +53 -2
- package/claude/skills/sd-plan-dev/code-quality-reviewer-prompt.md +1 -3
- package/claude/skills/sd-plan-dev/implementer-prompt.md +10 -1
- package/claude/skills/sd-readme/SKILL.md +1 -1
- package/claude/skills/sd-review/SKILL.md +73 -27
- package/claude/skills/sd-review/api-reviewer-prompt.md +6 -1
- package/claude/skills/sd-review/code-reviewer-prompt.md +9 -3
- package/claude/skills/sd-review/code-simplifier-prompt.md +43 -36
- package/claude/skills/sd-review/convention-checker-prompt.md +64 -0
- package/claude/skills/sd-review/structure-analyzer-prompt.md +97 -0
- package/claude/skills/sd-skill/SKILL.md +23 -0
- package/claude/skills/sd-skill/anthropic-best-practices.md +71 -1091
- package/claude/skills/sd-skill/testing-skills-with-subagents.md +9 -5
- package/claude/skills/sd-use/SKILL.md +19 -27
- package/package.json +1 -1
- package/claude/skills/sd-check/baseline-analysis.md +0 -150
- package/claude/skills/sd-check/test-scenarios.md +0 -205
- package/claude/skills/sd-debug/test-baseline-pressure.md +0 -61
|
@@ -37,7 +37,7 @@ async function readFileAsync() { ... } // Async suffix prohibited
|
|
|
37
37
|
## JSDoc Convention
|
|
38
38
|
|
|
39
39
|
- Not enforced — omit when code is self-explanatory
|
|
40
|
-
- When written, use
|
|
40
|
+
- When written, use English
|
|
41
41
|
|
|
42
42
|
## Re-export Restriction
|
|
43
43
|
|
|
@@ -50,8 +50,98 @@ async function readFileAsync() { ... } // Async suffix prohibited
|
|
|
50
50
|
- Small packages (≤10 exports): `//` comments only
|
|
51
51
|
- Always `export *` (wildcard), never explicit `export type { ... } from "..."`
|
|
52
52
|
|
|
53
|
+
## `any` vs `unknown` vs Generics
|
|
54
|
+
|
|
55
|
+
Choose based on **what you do with the value**:
|
|
56
|
+
|
|
57
|
+
| Type | When | Key rule |
|
|
58
|
+
|------|------|----------|
|
|
59
|
+
| `any` | Value is **passed through** without property access | No `.prop`, no method calls, no narrowing |
|
|
60
|
+
| `unknown` | Value's properties **will be accessed** but type is unknown | Must narrow with type guard before any access |
|
|
61
|
+
| Generic `<T>` | **Input/output type relationship** must be preserved | Caller's type flows through to return type |
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// any — pure pass-through, no property access
|
|
65
|
+
function logAndStore(value: any): void {
|
|
66
|
+
console.log(value); // OK: no property access
|
|
67
|
+
storage.push(value); // OK: just forwarding
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// unknown — will access properties, must narrow first
|
|
71
|
+
function getName(data: unknown): string {
|
|
72
|
+
if (typeof data === "object" && data !== null && "name" in data) {
|
|
73
|
+
return String((data as { name: unknown }).name);
|
|
74
|
+
}
|
|
75
|
+
throw new Error("No name property");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Generic — input type preserved in output
|
|
79
|
+
function wrapValue<T>(value: T): { value: T } {
|
|
80
|
+
return { value };
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**any vs Generic for pass-through:** If the function only forwards a value without accessing it AND the caller does not need type preservation in the return, use `any`. If the caller needs the same type back (input→output relationship), use a generic.
|
|
85
|
+
|
|
53
86
|
## Type Safety for Public APIs
|
|
54
87
|
|
|
55
88
|
- API changes must be detectable via **typecheck alone** — all affected usage sites must show compile errors
|
|
56
89
|
- Public component props must support **IDE intellisense** (autocomplete, type hints)
|
|
57
|
-
-
|
|
90
|
+
- **No `any` in public-facing types** — use generics or specific union types instead
|
|
91
|
+
- **No `Record<string, any>` for structured props** — define explicit interfaces so consumers get autocomplete
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Bad — consumers get no autocomplete, changes are invisible
|
|
95
|
+
interface TableProps {
|
|
96
|
+
columns: Record<string, any>;
|
|
97
|
+
onRowClick: Function;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Good — changes to ColumnDef break consumers at compile time
|
|
101
|
+
interface TableProps<TRow> {
|
|
102
|
+
columns: ColumnDef<TRow>[];
|
|
103
|
+
onRowClick?: (row: TRow) => void;
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Forced Type Casting Prohibition
|
|
108
|
+
|
|
109
|
+
- **`as unknown as X` is prohibited** — dangerous escape hatch that silences real type errors
|
|
110
|
+
- **`as X` must be avoided** unless there is no alternative — when tempted, try these fixes first:
|
|
111
|
+
|
|
112
|
+
| Type error situation | Fix (instead of `as`) |
|
|
113
|
+
|---------------------|-----------------------|
|
|
114
|
+
| Missing properties | Add them to the interface |
|
|
115
|
+
| Type too wide | Use generics to propagate correctly |
|
|
116
|
+
| Unknown shape | Type guard: `if ("prop" in obj)`, `instanceof` |
|
|
117
|
+
| Multiple shapes | Discriminated union or overload |
|
|
118
|
+
| Wrong at source | Fix the root cause, not the usage site |
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Bad — casting hides the real problem
|
|
122
|
+
const admin = user as unknown as AdminUser;
|
|
123
|
+
|
|
124
|
+
// Bad — lazy cast instead of proper narrowing
|
|
125
|
+
const name = (event as any).target.name;
|
|
126
|
+
|
|
127
|
+
// Good — fix parameter type at the source
|
|
128
|
+
function getAdminDashboard(admin: AdminUser): string { ... }
|
|
129
|
+
|
|
130
|
+
// Good — narrow unknown with type guard
|
|
131
|
+
function getNameFromEvent(event: unknown): string {
|
|
132
|
+
if (typeof event === "object" && event !== null && "target" in event) {
|
|
133
|
+
const target = event.target;
|
|
134
|
+
if (typeof target === "object" && target !== null && "name" in target) {
|
|
135
|
+
return String(target.name);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
throw new Error("Invalid event structure");
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Boolean Prop Defaults
|
|
143
|
+
|
|
144
|
+
- Name boolean props so their default value is `false`
|
|
145
|
+
- Prefer `hide*`, `disable*` patterns where the feature is ON by default
|
|
146
|
+
- This avoids double-negation in JSX: `hideX={false}` is clearer than `showX={true}` when both mean "show X"
|
|
147
|
+
- Exception: inherent HTML attributes like `draggable` may default to `true`
|
package/claude/refs/sd-solid.md
CHANGED
|
@@ -48,6 +48,8 @@ All sub-components via dot notation only (`Parent.Child`).
|
|
|
48
48
|
- Default `rem`, use `em` for text-relative sizing (e.g., Icon)
|
|
49
49
|
- Use `clsx()` with semantic grouping + `twMerge()` for conflict resolution
|
|
50
50
|
- Before modifying styles: Read existing class patterns of the same component
|
|
51
|
+
- **Class strings inline**: Do not extract class strings into separate variables — write them directly in the JSX return
|
|
52
|
+
- **`*.styles.ts` files**: Tailwind class strings must be wrapped with `clsx()` for IntelliSense support
|
|
51
53
|
|
|
52
54
|
## Application View Naming (`client-*`)
|
|
53
55
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
## Problem-Solving Principles
|
|
7
7
|
|
|
8
8
|
- **Root cause first**: When encountering errors or unexpected behavior, always investigate the root cause before attempting a fix. Do not apply workarounds, hacks, or surface-level patches.
|
|
9
|
-
- **No band-aid fixes**: Avoid techniques like suppressing errors, adding defensive checks to hide symptoms, or
|
|
9
|
+
- **No band-aid fixes**: Avoid techniques like suppressing errors, adding defensive checks to hide symptoms, bypassing validation, or inflating timeout values. These mask the real problem and create technical debt.
|
|
10
10
|
- **Consider refactoring**: If the root cause reveals a design flaw or structural issue, propose a refactoring approach rather than working around it. A proper fix — even if larger in scope — is better than a fragile workaround.
|
|
11
11
|
- **Trace the full chain**: Follow the error or issue through the entire call chain (caller -> callee -> dependencies) to understand why it happens, not just where it happens.
|
|
12
12
|
- **When uncertain, ask**: If the root cause is unclear or the fix requires significant changes, discuss with the user before proceeding. Present findings and options rather than silently applying a quick fix.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- Before creating new files: Glob/Read similar existing files to check structure and patterns
|
|
17
17
|
- Before modifying functions/classes: Read the file to understand existing code style
|
|
18
18
|
- When unsure about API/method usage: Check signatures in source code
|
|
19
|
+
- **Always search the local codebase first.** Do not search the web or external docs until you have confirmed the answer is not in local code.
|
|
19
20
|
- **If confidence is low, ask the user instead of writing code**
|
|
20
21
|
|
|
21
22
|
## Memory Policy
|
|
@@ -39,6 +39,27 @@ If a referenced file or document cannot be found, **stop immediately and ask the
|
|
|
39
39
|
- Any unsolicited observations about surrounding code quality
|
|
40
40
|
- Only describe **what you changed** — nothing else
|
|
41
41
|
|
|
42
|
+
### Analysis & Comparison
|
|
43
|
+
|
|
44
|
+
- When analyzing, comparing, diffing, or auditing: **enumerate all items exhaustively**. Never provide a shallow summary — list every difference, even minor ones.
|
|
45
|
+
- Example: v12 vs v13 migration gap → list ALL API, type, pattern differences item by item
|
|
46
|
+
|
|
47
|
+
### Direct Action Requests
|
|
48
|
+
|
|
49
|
+
- When the user provides a specific action (e.g., "rename X to Y", "delete this file"), **execute it directly**. Do not route through skill agents or sub-agent workflows for trivial operations.
|
|
50
|
+
|
|
51
|
+
## Worktree Prohibition
|
|
52
|
+
|
|
53
|
+
**NEVER use `isolation: "worktree"` when calling the Agent tool.** This is an absolute rule with no exceptions.
|
|
54
|
+
|
|
55
|
+
- Do NOT create git worktrees unless the user explicitly says "worktree" (e.g., "create a worktree", "use a worktree").
|
|
56
|
+
- Using `isolation: "worktree"` on Agent tool calls without explicit user instruction is **strictly prohibited**.
|
|
57
|
+
- Worktrees leave behind directories and branches that clutter the repository and cause frustration.
|
|
58
|
+
- If you need to run agents, run them **without** the `isolation` parameter.
|
|
59
|
+
- If the user explicitly requests a worktree:
|
|
60
|
+
- Create it under the **`.worktree/`** directory (project root), NOT `.claude/worktrees/`.
|
|
61
|
+
- **After work is complete, you MUST delete the worktree and its branch** before finishing. No worktree may be left behind.
|
|
62
|
+
|
|
42
63
|
## Asking Clarifying Questions
|
|
43
64
|
|
|
44
65
|
When you need to ask the user a question, you MUST use the `AskUserQuestion` tool. Do NOT ask questions in plain text.
|
|
@@ -13,7 +13,7 @@ Determine the major version by the `version` field in `package.json`.
|
|
|
13
13
|
|
|
14
14
|
| When | Read this file |
|
|
15
15
|
| ------------------------------------------------ | ------------------------------------- |
|
|
16
|
-
| Writing or
|
|
16
|
+
| Writing, modifying, or reviewing code | `.claude/refs/sd-code-conventions.md` |
|
|
17
17
|
| Working with `.cache/` or Playwright screenshots | `.claude/refs/sd-directories.md` |
|
|
18
18
|
| Using `@simplysm/*` package APIs | `.claude/refs/sd-simplysm-docs.md` |
|
|
19
19
|
| Debugging, problem-solving, or planning approach | `.claude/refs/sd-workflow.md` |
|
package/claude/sd-statusline.js
CHANGED
|
@@ -8,6 +8,8 @@ import { stdin } from "process";
|
|
|
8
8
|
|
|
9
9
|
const STDIN_TIMEOUT_MS = 5000;
|
|
10
10
|
const FETCH_TIMEOUT_MS = 3000;
|
|
11
|
+
const CACHE_TTL_MS = 60_000; // 1 minute
|
|
12
|
+
const CACHE_PATH = path.join(os.homedir(), ".claude", "usage-api-cache.json");
|
|
11
13
|
|
|
12
14
|
//#endregion
|
|
13
15
|
|
|
@@ -75,16 +77,49 @@ function getOAuthToken() {
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
/**
|
|
78
|
-
*
|
|
80
|
+
* Read cached usage data from local file.
|
|
81
|
+
* @returns {{ data: object, timestamp: number } | undefined}
|
|
82
|
+
*/
|
|
83
|
+
function readCache() {
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.existsSync(CACHE_PATH)) return undefined;
|
|
86
|
+
const content = fs.readFileSync(CACHE_PATH, "utf-8");
|
|
87
|
+
return JSON.parse(content);
|
|
88
|
+
} catch {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Write usage data to local cache file.
|
|
95
|
+
* @param {object} data
|
|
96
|
+
*/
|
|
97
|
+
function writeCache(data) {
|
|
98
|
+
try {
|
|
99
|
+
fs.writeFileSync(CACHE_PATH, JSON.stringify({ data, timestamp: Date.now() }), "utf-8");
|
|
100
|
+
} catch {
|
|
101
|
+
// ignore write errors
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Fetch Anthropic API usage information using OAuth token, with 1-minute cache.
|
|
79
107
|
* @param {string} token - OAuth access token
|
|
108
|
+
* @param {string} version - Claude Code version
|
|
80
109
|
* @returns {Promise<{
|
|
81
|
-
* seven_day?: {utilization?: number, resets_at?: string},
|
|
82
|
-
* daily?: {utilization?: number, resets_at?: string},
|
|
83
|
-
* five_hour?: {utilization?: number, resets_at?: string},
|
|
84
|
-
* extra_usage?: {is_enabled?: boolean, monthly_limit?: number | null, used_credits?: number}
|
|
110
|
+
* seven_day?: {utilization?: number, resets_at?: string},
|
|
111
|
+
* daily?: {utilization?: number, resets_at?: string},
|
|
112
|
+
* five_hour?: {utilization?: number, resets_at?: string},
|
|
113
|
+
* extra_usage?: {is_enabled?: boolean, monthly_limit?: number | null, used_credits?: number}
|
|
85
114
|
* } | undefined>}
|
|
86
115
|
*/
|
|
87
|
-
async function fetchUsage(token) {
|
|
116
|
+
async function fetchUsage(token, version) {
|
|
117
|
+
// Return cached data if still valid
|
|
118
|
+
const cache = readCache();
|
|
119
|
+
if (cache != null && (Date.now() - cache.timestamp) < CACHE_TTL_MS) {
|
|
120
|
+
return cache.data;
|
|
121
|
+
}
|
|
122
|
+
|
|
88
123
|
try {
|
|
89
124
|
const controller = new AbortController();
|
|
90
125
|
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
@@ -93,6 +128,7 @@ async function fetchUsage(token) {
|
|
|
93
128
|
headers: {
|
|
94
129
|
"Authorization": `Bearer ${token}`,
|
|
95
130
|
"anthropic-beta": "oauth-2025-04-20",
|
|
131
|
+
"User-Agent": `claude-code/${version}`,
|
|
96
132
|
},
|
|
97
133
|
signal: controller.signal,
|
|
98
134
|
});
|
|
@@ -100,19 +136,24 @@ async function fetchUsage(token) {
|
|
|
100
136
|
clearTimeout(timeout);
|
|
101
137
|
|
|
102
138
|
if (!response.ok) {
|
|
103
|
-
|
|
139
|
+
// API failed — update timestamp to prevent retry for TTL duration
|
|
140
|
+
writeCache(cache?.data ?? {});
|
|
141
|
+
return cache?.data;
|
|
104
142
|
}
|
|
105
143
|
|
|
106
144
|
const data = await response.json();
|
|
107
145
|
|
|
108
|
-
// Validate response structure
|
|
109
146
|
if (data == null || typeof data !== "object") {
|
|
110
|
-
|
|
147
|
+
writeCache(cache?.data ?? {});
|
|
148
|
+
return cache?.data;
|
|
111
149
|
}
|
|
112
150
|
|
|
151
|
+
writeCache(data);
|
|
113
152
|
return data;
|
|
114
153
|
} catch {
|
|
115
|
-
|
|
154
|
+
// Network error — update timestamp to prevent retry for TTL duration
|
|
155
|
+
writeCache(cache?.data ?? {});
|
|
156
|
+
return cache?.data;
|
|
116
157
|
}
|
|
117
158
|
}
|
|
118
159
|
|
|
@@ -172,6 +213,7 @@ function formatTimeRemaining(isoDate) {
|
|
|
172
213
|
* @property {{display_name?: string}} [model] - Model information
|
|
173
214
|
* @property {{context_window_size?: number, remaining_context_tokens?: number, current_usage?: {input_tokens?: number, output_tokens?: number, cache_creation_input_tokens?: number, cache_read_input_tokens?: number}}} [context_window] - Context window information
|
|
174
215
|
* @property {{tokens_used?: number, tokens_limit?: number}} [weekly_token_usage] - Weekly token usage (fallback)
|
|
216
|
+
* @property {string} [version] - Claude Code version
|
|
175
217
|
*/
|
|
176
218
|
|
|
177
219
|
/**
|
|
@@ -212,7 +254,7 @@ async function main() {
|
|
|
212
254
|
let extraUsage = "";
|
|
213
255
|
|
|
214
256
|
if (token != null) {
|
|
215
|
-
const usageResponse = await fetchUsage(token);
|
|
257
|
+
const usageResponse = await fetchUsage(token, input.version ?? "unknown");
|
|
216
258
|
if (usageResponse != null) {
|
|
217
259
|
// Use daily or five_hour
|
|
218
260
|
const dailyData = usageResponse.daily ?? usageResponse.five_hour;
|
|
@@ -31,9 +31,9 @@ Based on Phase 1 results, determine comparison targets and perspectives:
|
|
|
31
31
|
2. Determine the target's domain and tech stack to **select comparable libraries**
|
|
32
32
|
3. Use **parallel agents** to web-search/fetch official docs for each library, investigating naming conventions for the same pattern categories
|
|
33
33
|
|
|
34
|
-
## Phase 3: Comparative Analysis
|
|
34
|
+
## Phase 3: Comparative Analysis
|
|
35
35
|
|
|
36
|
-
Cross-compare Phase 1 and Phase 2 results
|
|
36
|
+
Cross-compare Phase 1 and Phase 2 results and classify each item:
|
|
37
37
|
|
|
38
38
|
| Priority | Criteria |
|
|
39
39
|
| -------- | ------------------------------------------------------ |
|
|
@@ -44,6 +44,25 @@ Cross-compare Phase 1 and Phase 2 results to produce the report.
|
|
|
44
44
|
|
|
45
45
|
Each item includes: current name, recommended change, rationale (usage patterns per library).
|
|
46
46
|
|
|
47
|
+
## Phase 4: Report & User Confirmation
|
|
48
|
+
|
|
49
|
+
Present **Keep** items to the user as a summary.
|
|
50
|
+
|
|
51
|
+
Then present each **P0/P1/P2** finding to the user **one at a time**, ordered by priority (P0 → P1 → P2).
|
|
52
|
+
|
|
53
|
+
For each finding, explain:
|
|
54
|
+
1. **What the problem is** — the current name and why it's misaligned or inconsistent
|
|
55
|
+
2. **How it could be fixed** — recommended name(s) with rationale from surveyed libraries
|
|
56
|
+
3. **Ask**: address this or skip?
|
|
57
|
+
|
|
58
|
+
Collect only findings the user confirms. If the user skips all findings, report that and end.
|
|
59
|
+
|
|
60
|
+
## Phase 5: Brainstorm Handoff
|
|
61
|
+
|
|
62
|
+
Pass only the **user-confirmed findings** to **sd-brainstorm**.
|
|
63
|
+
|
|
64
|
+
sd-brainstorm will handle prioritization, grouping, approach exploration, and design.
|
|
65
|
+
|
|
47
66
|
## Completion Criteria
|
|
48
67
|
|
|
49
|
-
|
|
68
|
+
Report Keep items, confirm P0/P1/P2 findings with user one by one, then hand off confirmed findings to sd-brainstorm. No code modifications during review.
|
|
@@ -14,12 +14,44 @@ Start by understanding the current project context, then ask questions one at a
|
|
|
14
14
|
## The Process
|
|
15
15
|
|
|
16
16
|
**Understanding the idea:**
|
|
17
|
-
- Check out the current project state first (files, docs, recent commits)
|
|
17
|
+
- Check out the current project state first (files, docs, recent commits). For deeper codebase exploration, consider using `sd-explore`.
|
|
18
18
|
- Ask questions one at a time to refine the idea
|
|
19
19
|
- Prefer multiple choice questions when possible, but open-ended is fine too
|
|
20
20
|
- Only one question per message - if a topic needs more exploration, break it into multiple questions
|
|
21
21
|
- Focus on understanding: purpose, constraints, success criteria
|
|
22
22
|
|
|
23
|
+
**When a main design document is provided as context:**
|
|
24
|
+
|
|
25
|
+
```dot
|
|
26
|
+
digraph sub_design {
|
|
27
|
+
has_main [label="Main design with\nsection plan in context?" shape=diamond];
|
|
28
|
+
section_specified [label="Section specified?" shape=diamond];
|
|
29
|
+
prereqs_ok [label="Prerequisites\ncomplete?" shape=diamond];
|
|
30
|
+
normal [label="Normal brainstorm" shape=box];
|
|
31
|
+
show_progress [label="Show section progress\nAsk which section\n(suggest next incomplete)" shape=box];
|
|
32
|
+
warn [label="Warn prerequisites incomplete\nAsk: proceed anyway\nor complete first?" shape=box];
|
|
33
|
+
proceed [label="Proceed with section" shape=box];
|
|
34
|
+
|
|
35
|
+
has_main -> normal [label="no"];
|
|
36
|
+
has_main -> section_specified [label="yes"];
|
|
37
|
+
section_specified -> show_progress [label="no"];
|
|
38
|
+
section_specified -> prereqs_ok [label="yes"];
|
|
39
|
+
prereqs_ok -> proceed [label="yes"];
|
|
40
|
+
prereqs_ok -> warn [label="no"];
|
|
41
|
+
warn -> proceed [label="user: proceed"];
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
When proceeding with a section:
|
|
46
|
+
|
|
47
|
+
1. **Read the main design** — understand goals, overall structure, and the target section's scope
|
|
48
|
+
2. **Read actual code** — check the current codebase state for what previous sections have built. Reference the **actual code**, NOT previous section design documents. Code may have diverged from earlier designs during implementation.
|
|
49
|
+
3. **Scope the brainstorm** — limit questions, gap review, approaches, and design presentation to the target section only. Do not re-question decisions already established in the main design.
|
|
50
|
+
4. **Conflict detection** — if the main design's direction conflicts with the actual code state, alert the user and ask for direction before proceeding.
|
|
51
|
+
5. After the design is complete, save as `docs/plans/YYYY-MM-DD-<topic>-section-N-design.md`
|
|
52
|
+
6. Update the main design document: mark the section `[ ]` → `[x]` in the section plan
|
|
53
|
+
7. Commit both files, then proceed to the normal **Next Steps Guide** (Path A/B)
|
|
54
|
+
|
|
23
55
|
**Gap review loop:**
|
|
24
56
|
|
|
25
57
|
When you think you've asked enough, **STOP and run a gap review before moving on.**
|
|
@@ -76,6 +108,63 @@ If your first gap review shows all ✅:
|
|
|
76
108
|
- Cover: architecture, components, data flow, error handling, testing
|
|
77
109
|
- Be ready to go back and clarify if something doesn't make sense
|
|
78
110
|
|
|
111
|
+
**Scale assessment:**
|
|
112
|
+
|
|
113
|
+
After the design presentation is complete, assess scale (file count, logic complexity, number of distinct subsystems, scope of impact):
|
|
114
|
+
|
|
115
|
+
```dot
|
|
116
|
+
digraph scale {
|
|
117
|
+
assess [label="Assess design scale" shape=diamond];
|
|
118
|
+
manageable [label="Proceed to\nAfter the Design\n(Path A/B)" shape=box];
|
|
119
|
+
propose [label="Propose to user:\nproceed as-is OR\nsplit into sections" shape=box];
|
|
120
|
+
user_choice [label="User choice?" shape=diamond];
|
|
121
|
+
division [label="Propose 2-3 section\ndivision approaches\n(by feature/layer/dependency)" shape=box];
|
|
122
|
+
save [label="Append section plan\nto design doc\nSave + commit" shape=box];
|
|
123
|
+
guide [label="Show section guide\nBrainstorm ENDS" shape=box];
|
|
124
|
+
|
|
125
|
+
assess -> manageable [label="manageable"];
|
|
126
|
+
assess -> propose [label="large"];
|
|
127
|
+
propose -> user_choice;
|
|
128
|
+
user_choice -> manageable [label="proceed as-is"];
|
|
129
|
+
user_choice -> division [label="split"];
|
|
130
|
+
division -> save [label="user selects"];
|
|
131
|
+
save -> guide;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Section plan format** (append to existing design content as-is):
|
|
136
|
+
|
|
137
|
+
```markdown
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Section Plan
|
|
141
|
+
|
|
142
|
+
- [ ] Section 1: <name> — <scope summary>
|
|
143
|
+
- [ ] Section 2: <name> — <scope summary> (after section 1)
|
|
144
|
+
- [ ] Section 3: <name> — <scope summary> (after section 1, 2)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Section guide** (shown instead of Path A/B, in user's configured language):
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
Design has been split into sections.
|
|
151
|
+
|
|
152
|
+
Main design: docs/plans/YYYY-MM-DD-<topic>-design.md
|
|
153
|
+
|
|
154
|
+
Section progress:
|
|
155
|
+
- [ ] Section 1: <name>
|
|
156
|
+
- [ ] Section 2: <name> (after section 1)
|
|
157
|
+
- [ ] Section 3: <name> (after section 1, 2)
|
|
158
|
+
|
|
159
|
+
Run each section in order:
|
|
160
|
+
sd-brainstorm docs/plans/YYYY-MM-DD-<topic>-design.md section 1
|
|
161
|
+
|
|
162
|
+
After each section's brainstorm completes, you can choose Path A/B
|
|
163
|
+
to run plan → plan-dev → check → commit.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Do NOT auto-proceed to any section.
|
|
167
|
+
|
|
79
168
|
## After the Design
|
|
80
169
|
|
|
81
170
|
**Documentation:**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sd-check
|
|
3
3
|
description: "Typecheck, lint, test verification (explicit invocation only)"
|
|
4
|
-
allowed-tools: Bash(npm run check:*), Bash(pnpm run check:*), Bash(yarn run check:*), Bash(npm run typecheck:*), Bash(pnpm run typecheck:*), Bash(yarn run typecheck:*), Bash(npm run lint:*), Bash(pnpm run lint:*), Bash(yarn run lint:*), Bash(npm run vitest:*), Bash(pnpm run vitest:*), Bash(yarn run vitest:*)
|
|
5
4
|
---
|
|
6
5
|
|
|
7
6
|
# sd-check
|
|
@@ -34,19 +33,36 @@ Multiple types: `--type typecheck,lint`. No path = full project. No type = all c
|
|
|
34
33
|
|
|
35
34
|
## Workflow
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
```dot
|
|
37
|
+
digraph check_workflow {
|
|
38
|
+
"Run check" [shape=box];
|
|
39
|
+
"All passed?" [shape=diamond];
|
|
40
|
+
"Report results → done" [shape=box];
|
|
41
|
+
"Fix errors\n(typecheck → lint → test)" [shape=box];
|
|
42
|
+
"Stuck after 2-3 tries?" [shape=diamond];
|
|
43
|
+
"Recommend /sd-debug" [shape=box];
|
|
44
|
+
|
|
45
|
+
"Run check" -> "All passed?";
|
|
46
|
+
"All passed?" -> "Report results → done" [label="yes"];
|
|
47
|
+
"All passed?" -> "Fix errors\n(typecheck → lint → test)" [label="no"];
|
|
48
|
+
"Fix errors\n(typecheck → lint → test)" -> "Stuck after 2-3 tries?";
|
|
49
|
+
"Stuck after 2-3 tries?" -> "Run check" [label="no"];
|
|
50
|
+
"Stuck after 2-3 tries?" -> "Recommend /sd-debug" [label="yes"];
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Run command:** `$PM run check [path] [--type type]` (timeout: 600000)
|
|
55
|
+
|
|
56
|
+
**Fixing errors:**
|
|
57
|
+
- **Before fixing any code**: Read `.claude/refs/sd-code-conventions.md` and check `.claude/rules/sd-refs-linker.md` for additional refs relevant to the affected code area (e.g., `sd-solid.md` for SolidJS, `sd-orm.md` for ORM). Fixing errors does NOT exempt you from following project conventions.
|
|
58
|
+
- Test failures: **MUST** run `git log` to decide — update test or fix source
|
|
59
|
+
- **E2E test failures**: use Playwright MCP to investigate before fixing
|
|
60
|
+
1. `browser_navigate` to the target URL
|
|
61
|
+
2. `browser_snapshot` / `browser_take_screenshot` (save to `.tmp/playwright/`) to see page state
|
|
62
|
+
3. `browser_console_messages` for JS errors
|
|
63
|
+
4. `browser_network_requests` for failed API calls
|
|
64
|
+
5. Interact with the page following the test steps to reproduce the failure
|
|
65
|
+
6. Fix based on observed evidence, not guesswork
|
|
50
66
|
|
|
51
67
|
## Rules
|
|
52
68
|
|
|
@@ -196,25 +196,26 @@ You MUST complete each phase before proceeding to the next.
|
|
|
196
196
|
- Issue actually resolved?
|
|
197
197
|
|
|
198
198
|
4. **If Fix Doesn't Work**
|
|
199
|
-
- STOP
|
|
200
|
-
- Count: How many fixes have you tried?
|
|
201
|
-
- If < 3: Return to Phase 1, re-analyze with new information
|
|
202
|
-
- **If ≥ 3: STOP and question the architecture (step 5 below)**
|
|
203
|
-
- DON'T attempt Fix #4 without architectural discussion
|
|
204
199
|
|
|
205
|
-
|
|
200
|
+
```dot
|
|
201
|
+
digraph fix_failure_loop {
|
|
202
|
+
"Fix failed?" [shape=diamond];
|
|
203
|
+
"Attempts < 3?" [shape=diamond];
|
|
204
|
+
"Phase 1: Re-analyze\nwith new information" [shape=box];
|
|
205
|
+
"STOP: Question Architecture\n→ Discuss with user first" [shape=box];
|
|
206
|
+
|
|
207
|
+
"Fix failed?" -> "Attempts < 3?";
|
|
208
|
+
"Attempts < 3?" -> "Phase 1: Re-analyze\nwith new information" [label="yes"];
|
|
209
|
+
"Attempts < 3?" -> "STOP: Question Architecture\n→ Discuss with user first" [label="no (≥3)"];
|
|
210
|
+
}
|
|
211
|
+
```
|
|
206
212
|
|
|
207
|
-
**
|
|
213
|
+
**Signs of architectural problem (≥3 failures):**
|
|
208
214
|
- Each fix reveals new shared state/coupling/problem in different place
|
|
209
215
|
- Fixes require "massive refactoring" to implement
|
|
210
216
|
- Each fix creates new symptoms elsewhere
|
|
211
217
|
|
|
212
|
-
**
|
|
213
|
-
- Is this pattern fundamentally sound?
|
|
214
|
-
- Are we "sticking with it through sheer inertia"?
|
|
215
|
-
- Should we refactor architecture vs. continue fixing symptoms?
|
|
216
|
-
|
|
217
|
-
**Discuss with the user before attempting more fixes**
|
|
218
|
+
**Question fundamentals:** Is this pattern sound? Are we sticking with it through inertia? Should we refactor architecture vs. continue fixing symptoms?
|
|
218
219
|
|
|
219
220
|
This is NOT a failed hypothesis - this is a wrong architecture.
|
|
220
221
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-explore
|
|
3
|
+
description: "Use when the user asks to explore, analyze, trace, or understand code structure, architecture, or implementation flow. Triggers: 'explore this', 'how does this work', 'analyze this code', 'trace the flow', 'what does this package do', codebase understanding requests."
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# sd-explore
|
|
8
|
+
|
|
9
|
+
You are an expert code analyst. Trace implementations across codebases and save structured analysis to file.
|
|
10
|
+
|
|
11
|
+
## Target Selection
|
|
12
|
+
|
|
13
|
+
**When invoked with `$ARGUMENTS`:**
|
|
14
|
+
|
|
15
|
+
- If path is provided → **Immediately start analysis** (don't ask clarifying questions)
|
|
16
|
+
- If path is a package directory → Trace all major features, architecture, and patterns
|
|
17
|
+
- If path is a single file → Trace its role, dependencies, and usage
|
|
18
|
+
- If no arguments provided → Ask the user what to explore
|
|
19
|
+
|
|
20
|
+
**Analysis only — no code modifications.**
|
|
21
|
+
|
|
22
|
+
## Output — Save to File
|
|
23
|
+
|
|
24
|
+
**All analysis results MUST be saved to `.tmp/explore/`.** Do NOT dump the full analysis into the conversation.
|
|
25
|
+
|
|
26
|
+
This prevents context loss from compaction and makes results available to subsequent skills/agents.
|
|
27
|
+
|
|
28
|
+
### File Naming
|
|
29
|
+
|
|
30
|
+
- **Directory/package analysis:** `.tmp/explore/{package-name}.md` (e.g., `.tmp/explore/solid.md`)
|
|
31
|
+
- **Single file analysis:** `.tmp/explore/{filename}.md` (e.g., `.tmp/explore/Dialog.md`)
|
|
32
|
+
- **Sub-topic deep dive:** `.tmp/explore/{package-name}--{topic}.md` (e.g., `.tmp/explore/solid--form-controls.md`)
|
|
33
|
+
|
|
34
|
+
### File Structure
|
|
35
|
+
|
|
36
|
+
```markdown
|
|
37
|
+
# {Target Name} — Explore
|
|
38
|
+
|
|
39
|
+
> Analyzed: {target path}
|
|
40
|
+
|
|
41
|
+
## Summary
|
|
42
|
+
{1-3 sentence overview}
|
|
43
|
+
|
|
44
|
+
## Architecture
|
|
45
|
+
{Design patterns, layers, key abstractions}
|
|
46
|
+
|
|
47
|
+
## Entry Points
|
|
48
|
+
{APIs, components, commands — with file:line references}
|
|
49
|
+
|
|
50
|
+
## Code Flow
|
|
51
|
+
{Step-by-step execution traces}
|
|
52
|
+
|
|
53
|
+
## Key Files
|
|
54
|
+
{Essential files for understanding the target — with file:line references}
|
|
55
|
+
|
|
56
|
+
## Dependencies
|
|
57
|
+
{Internal and external dependencies}
|
|
58
|
+
|
|
59
|
+
## Observations
|
|
60
|
+
{Strengths, issues, opportunities}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Workflow
|
|
64
|
+
|
|
65
|
+
1. Perform the analysis (read files, trace code, map architecture)
|
|
66
|
+
2. Write the full result to `.tmp/explore/{name}.md`
|
|
67
|
+
3. Output a **brief summary** to the conversation (3-5 lines max) with the file path
|
|
68
|
+
|
|
69
|
+
**Example conversation output:**
|
|
70
|
+
```
|
|
71
|
+
Analyzed `packages/solid/src/components/disclosure/` → saved to `.tmp/explore/solid--disclosure.md`
|
|
72
|
+
|
|
73
|
+
- 4 components: Dialog, Dropdown, Collapse, Tabs
|
|
74
|
+
- Shared pattern: portal + backdrop + animation via CSS transitions
|
|
75
|
+
- Key file: Dialog.tsx:45 — base implementation others extend
|
|
76
|
+
```
|