@simplysm/sd-claude 13.0.0-beta.11
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 +41 -0
- package/claude/agents/sd-api-reviewer.md +81 -0
- package/claude/agents/sd-code-reviewer.md +49 -0
- package/claude/agents/sd-code-simplifier.md +50 -0
- package/claude/sd-statusline.js +270 -0
- package/claude/skills/sd-api-name-review/SKILL.md +49 -0
- package/claude/skills/sd-brainstorm/SKILL.md +55 -0
- package/claude/skills/sd-check/SKILL.md +88 -0
- package/claude/skills/sd-commit/SKILL.md +48 -0
- package/claude/skills/sd-explore/SKILL.md +63 -0
- package/claude/skills/sd-plan/SKILL.md +104 -0
- package/claude/skills/sd-plan-dev/SKILL.md +266 -0
- package/claude/skills/sd-plan-dev/code-quality-reviewer-prompt.md +69 -0
- package/claude/skills/sd-plan-dev/implementer-prompt.md +50 -0
- package/claude/skills/sd-plan-dev/spec-reviewer-prompt.md +38 -0
- package/claude/skills/sd-readme/SKILL.md +95 -0
- package/claude/skills/sd-review/SKILL.md +93 -0
- package/claude/skills/sd-skill/SKILL.md +639 -0
- package/claude/skills/sd-skill/anthropic-best-practices.md +1150 -0
- package/claude/skills/sd-skill/examples/CLAUDE_MD_TESTING.md +189 -0
- package/claude/skills/sd-skill/persuasion-principles.md +187 -0
- package/claude/skills/sd-skill/testing-skills-with-subagents.md +384 -0
- package/claude/skills/sd-tdd/SKILL.md +373 -0
- package/claude/skills/sd-tdd/testing-anti-patterns.md +299 -0
- package/claude/skills/sd-worktree/SKILL.md +82 -0
- package/claude/skills/sd-worktree/sd-worktree.mjs +128 -0
- package/dist/commands/install.js +64 -0
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/uninstall.js +40 -0
- package/dist/commands/uninstall.js.map +7 -0
- package/dist/core-common/src/common.types.d.ts +74 -0
- package/dist/core-common/src/common.types.d.ts.map +1 -0
- package/dist/core-common/src/env.d.ts +6 -0
- package/dist/core-common/src/env.d.ts.map +1 -0
- package/dist/core-common/src/errors/argument-error.d.ts +25 -0
- package/dist/core-common/src/errors/argument-error.d.ts.map +1 -0
- package/dist/core-common/src/errors/not-implemented-error.d.ts +29 -0
- package/dist/core-common/src/errors/not-implemented-error.d.ts.map +1 -0
- package/dist/core-common/src/errors/sd-error.d.ts +27 -0
- package/dist/core-common/src/errors/sd-error.d.ts.map +1 -0
- package/dist/core-common/src/errors/timeout-error.d.ts +31 -0
- package/dist/core-common/src/errors/timeout-error.d.ts.map +1 -0
- package/dist/core-common/src/extensions/arr-ext.d.ts +15 -0
- package/dist/core-common/src/extensions/arr-ext.d.ts.map +1 -0
- package/dist/core-common/src/extensions/arr-ext.helpers.d.ts +19 -0
- package/dist/core-common/src/extensions/arr-ext.helpers.d.ts.map +1 -0
- package/dist/core-common/src/extensions/arr-ext.types.d.ts +215 -0
- package/dist/core-common/src/extensions/arr-ext.types.d.ts.map +1 -0
- package/dist/core-common/src/extensions/map-ext.d.ts +57 -0
- package/dist/core-common/src/extensions/map-ext.d.ts.map +1 -0
- package/dist/core-common/src/extensions/set-ext.d.ts +36 -0
- package/dist/core-common/src/extensions/set-ext.d.ts.map +1 -0
- package/dist/core-common/src/features/debounce-queue.d.ts +53 -0
- package/dist/core-common/src/features/debounce-queue.d.ts.map +1 -0
- package/dist/core-common/src/features/event-emitter.d.ts +66 -0
- package/dist/core-common/src/features/event-emitter.d.ts.map +1 -0
- package/dist/core-common/src/features/serial-queue.d.ts +47 -0
- package/dist/core-common/src/features/serial-queue.d.ts.map +1 -0
- package/dist/core-common/src/index.d.ts +32 -0
- package/dist/core-common/src/index.d.ts.map +1 -0
- package/dist/core-common/src/types/date-only.d.ts +152 -0
- package/dist/core-common/src/types/date-only.d.ts.map +1 -0
- package/dist/core-common/src/types/date-time.d.ts +96 -0
- package/dist/core-common/src/types/date-time.d.ts.map +1 -0
- package/dist/core-common/src/types/lazy-gc-map.d.ts +80 -0
- package/dist/core-common/src/types/lazy-gc-map.d.ts.map +1 -0
- package/dist/core-common/src/types/time.d.ts +68 -0
- package/dist/core-common/src/types/time.d.ts.map +1 -0
- package/dist/core-common/src/types/uuid.d.ts +35 -0
- package/dist/core-common/src/types/uuid.d.ts.map +1 -0
- package/dist/core-common/src/utils/bytes.d.ts +51 -0
- package/dist/core-common/src/utils/bytes.d.ts.map +1 -0
- package/dist/core-common/src/utils/date-format.d.ts +90 -0
- package/dist/core-common/src/utils/date-format.d.ts.map +1 -0
- package/dist/core-common/src/utils/json.d.ts +34 -0
- package/dist/core-common/src/utils/json.d.ts.map +1 -0
- package/dist/core-common/src/utils/num.d.ts +60 -0
- package/dist/core-common/src/utils/num.d.ts.map +1 -0
- package/dist/core-common/src/utils/obj.d.ts +258 -0
- package/dist/core-common/src/utils/obj.d.ts.map +1 -0
- package/dist/core-common/src/utils/path.d.ts +23 -0
- package/dist/core-common/src/utils/path.d.ts.map +1 -0
- package/dist/core-common/src/utils/primitive.d.ts +18 -0
- package/dist/core-common/src/utils/primitive.d.ts.map +1 -0
- package/dist/core-common/src/utils/str.d.ts +103 -0
- package/dist/core-common/src/utils/str.d.ts.map +1 -0
- package/dist/core-common/src/utils/template-strings.d.ts +84 -0
- package/dist/core-common/src/utils/template-strings.d.ts.map +1 -0
- package/dist/core-common/src/utils/transferable.d.ts +47 -0
- package/dist/core-common/src/utils/transferable.d.ts.map +1 -0
- package/dist/core-common/src/utils/wait.d.ts +19 -0
- package/dist/core-common/src/utils/wait.d.ts.map +1 -0
- package/dist/core-common/src/utils/xml.d.ts +36 -0
- package/dist/core-common/src/utils/xml.d.ts.map +1 -0
- package/dist/core-common/src/zip/sd-zip.d.ts +80 -0
- package/dist/core-common/src/zip/sd-zip.d.ts.map +1 -0
- package/dist/core-node/src/features/fs-watcher.d.ts +70 -0
- package/dist/core-node/src/features/fs-watcher.d.ts.map +1 -0
- package/dist/core-node/src/index.d.ts +7 -0
- package/dist/core-node/src/index.d.ts.map +1 -0
- package/dist/core-node/src/utils/fs.d.ts +197 -0
- package/dist/core-node/src/utils/fs.d.ts.map +1 -0
- package/dist/core-node/src/utils/path.d.ts +75 -0
- package/dist/core-node/src/utils/path.d.ts.map +1 -0
- package/dist/core-node/src/worker/create-worker.d.ts +23 -0
- package/dist/core-node/src/worker/create-worker.d.ts.map +1 -0
- package/dist/core-node/src/worker/types.d.ts +67 -0
- package/dist/core-node/src/worker/types.d.ts.map +1 -0
- package/dist/core-node/src/worker/worker.d.ts +27 -0
- package/dist/core-node/src/worker/worker.d.ts.map +1 -0
- package/dist/sd-claude/src/commands/install.d.ts +14 -0
- package/dist/sd-claude/src/commands/install.d.ts.map +1 -0
- package/dist/sd-claude/src/commands/uninstall.d.ts +10 -0
- package/dist/sd-claude/src/commands/uninstall.d.ts.map +1 -0
- package/dist/sd-claude/src/sd-claude.d.ts +8 -0
- package/dist/sd-claude/src/sd-claude.d.ts.map +1 -0
- package/dist/sd-claude.js +40 -0
- package/dist/sd-claude.js.map +7 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @simplysm/sd-claude
|
|
2
|
+
|
|
3
|
+
CLI tool for installing and uninstalling Simplysm Claude Code skills and agents. Standalone package — does not require `@simplysm/sd-cli`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @simplysm/sd-claude
|
|
9
|
+
# or
|
|
10
|
+
pnpm add -D @simplysm/sd-claude
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or run directly with `npx`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @simplysm/sd-claude install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
The CLI binary name is `sd-claude`. All commands support the `--debug` option to output detailed logs.
|
|
22
|
+
|
|
23
|
+
### install
|
|
24
|
+
|
|
25
|
+
Installs Claude Code skills/agents to the current project. Reads `sd-*` assets from the package's `claude/` directory and copies them to the project's `.claude/`. Existing `sd-*` entries are completely removed before new ones are copied. Also adds `statusLine` configuration to `.claude/settings.json`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
sd-claude install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### uninstall
|
|
32
|
+
|
|
33
|
+
Removes `sd-*` skills/agents from the current project's `.claude/`. Also removes `statusLine` configuration from `.claude/settings.json`.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
sd-claude uninstall
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
Apache-2.0
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-api-reviewer
|
|
3
|
+
description: Reviews a library's public API for developer experience (DX) quality - naming consistency, industry standard alignment, intuitiveness, error messages, type hints, configuration complexity, and usage pattern coherence
|
|
4
|
+
model: inherit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert API/DX reviewer who evaluates libraries from the **consumer's perspective**. Your goal is to identify friction points that developers encounter when using a package.
|
|
8
|
+
|
|
9
|
+
## Review Scope
|
|
10
|
+
|
|
11
|
+
Analyze the specified package's public API surface (exports, types, configuration). The user will provide the target path.
|
|
12
|
+
|
|
13
|
+
## Core Review Responsibilities
|
|
14
|
+
|
|
15
|
+
### 1. Naming Review
|
|
16
|
+
|
|
17
|
+
- **Industry standard comparison**: Compare naming patterns against major libraries in the same domain (use WebSearch)
|
|
18
|
+
- **Internal consistency**: Same concept with different names, same pattern with different prefixes/suffixes
|
|
19
|
+
- **Intuitiveness**: Whether the behavior can be predicted from the name alone
|
|
20
|
+
- **Internal consistency over external standards**: Before suggesting a naming change, verify the existing pattern across ALL similar components in the library. If the library consistently uses one convention (e.g., `value`/`onValueChange` for all form controls), do NOT suggest an industry-standard alternative (e.g., `checked`/`onCheckedChange`) that would break internal consistency.
|
|
21
|
+
|
|
22
|
+
### 2. API Intuitiveness
|
|
23
|
+
|
|
24
|
+
- **Learning curve**: Whether a first-time developer can use it without documentation
|
|
25
|
+
- **Principle of least surprise**: APIs that behave differently than expected
|
|
26
|
+
- **Default value quality**: Whether most use cases work without additional configuration
|
|
27
|
+
|
|
28
|
+
### 3. Type Hints & Error Messages
|
|
29
|
+
|
|
30
|
+
- **Type sufficiency**: Whether enough type information is provided for autocompletion and compile-time validation
|
|
31
|
+
- **Error message quality**: Whether error messages guide the user to the cause and solution
|
|
32
|
+
- **Generic usage**: Whether type inference works naturally
|
|
33
|
+
|
|
34
|
+
### 4. Configuration & Boilerplate
|
|
35
|
+
|
|
36
|
+
- **Configuration complexity**: Whether basic usage requires excessive setup
|
|
37
|
+
- **Boilerplate**: Whether too much repetitive code is needed
|
|
38
|
+
- **Progressive complexity**: Whether it scales naturally from simple to advanced usage
|
|
39
|
+
|
|
40
|
+
### 5. Usage Pattern Coherence
|
|
41
|
+
|
|
42
|
+
- **Pattern consistency**: Whether similar tasks use similar patterns
|
|
43
|
+
- **Composition**: Whether features combine naturally
|
|
44
|
+
- **Escape hatch**: Whether there are ways to break out of framework constraints when needed
|
|
45
|
+
|
|
46
|
+
## Confidence Scoring
|
|
47
|
+
|
|
48
|
+
Rate each issue 0-100:
|
|
49
|
+
|
|
50
|
+
- **0**: False positive or subjective preference
|
|
51
|
+
- **25**: Minor friction, workaround is obvious
|
|
52
|
+
- **50**: Real friction but not blocking
|
|
53
|
+
- **75**: Significant DX issue, developers will struggle
|
|
54
|
+
- **100**: Critical — developers will misuse or give up
|
|
55
|
+
|
|
56
|
+
**Only report issues with confidence >= 70.**
|
|
57
|
+
|
|
58
|
+
## Output Format
|
|
59
|
+
|
|
60
|
+
Start with a brief summary of the package's public API surface.
|
|
61
|
+
|
|
62
|
+
### Findings by Category
|
|
63
|
+
|
|
64
|
+
For each high-confidence issue:
|
|
65
|
+
- Clear description with confidence score
|
|
66
|
+
- File path and relevant export/type
|
|
67
|
+
- Comparison with industry standard libraries (if applicable)
|
|
68
|
+
- Concrete improvement suggestion
|
|
69
|
+
|
|
70
|
+
### Priority
|
|
71
|
+
|
|
72
|
+
| Priority | Criteria |
|
|
73
|
+
|----------|----------|
|
|
74
|
+
| **P0** | API misuse likely — naming misleads or types insufficient |
|
|
75
|
+
| **P1** | Significant friction — unnecessary complexity or inconsistency |
|
|
76
|
+
| **P2** | Minor improvement — better naming or defaults exist |
|
|
77
|
+
| **Keep** | Already aligned with standards |
|
|
78
|
+
|
|
79
|
+
### Summary Table
|
|
80
|
+
|
|
81
|
+
End with a table: current API, suggested change, priority, rationale.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-code-reviewer
|
|
3
|
+
description: Reviews code for bugs, logic errors, security vulnerabilities, code quality issues, and adherence to project conventions, using confidence-based filtering to report only high-priority issues that truly matter
|
|
4
|
+
model: inherit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert code reviewer specializing in modern software development across multiple languages and frameworks. Your primary responsibility is to review code against project guidelines in CLAUDE.md with high precision to minimize false positives.
|
|
8
|
+
|
|
9
|
+
## Review Scope
|
|
10
|
+
|
|
11
|
+
By default, review unstaged changes from `git diff`. The user may specify different files or scope to review.
|
|
12
|
+
|
|
13
|
+
## Core Review Responsibilities
|
|
14
|
+
|
|
15
|
+
**Project Guidelines Compliance**: Verify adherence to explicit project rules (typically in CLAUDE.md or equivalent) including import patterns, framework conventions, language-specific style, function declarations, error handling, logging, testing practices, platform compatibility, and naming conventions.
|
|
16
|
+
|
|
17
|
+
**Bug Detection**: Identify actual bugs that will impact functionality - logic errors, null/undefined handling, race conditions, memory leaks, security vulnerabilities, and performance problems.
|
|
18
|
+
|
|
19
|
+
**Code Quality**: Evaluate significant issues like code duplication, missing critical error handling, accessibility problems, and inadequate test coverage.
|
|
20
|
+
|
|
21
|
+
## Confidence Scoring
|
|
22
|
+
|
|
23
|
+
Rate each potential issue on a scale from 0-100:
|
|
24
|
+
|
|
25
|
+
- **0**: Not confident at all. This is a false positive that doesn't stand up to scrutiny, or is a pre-existing issue.
|
|
26
|
+
- **25**: Somewhat confident. This might be a real issue, but may also be a false positive. If stylistic, it wasn't explicitly called out in project guidelines.
|
|
27
|
+
- **50**: Moderately confident. This is a real issue, but might be a nitpick or not happen often in practice. Not very important relative to the rest of the changes.
|
|
28
|
+
- **75**: Highly confident. Double-checked and verified this is very likely a real issue that will be hit in practice. The existing approach is insufficient. Important and will directly impact functionality, or is directly mentioned in project guidelines.
|
|
29
|
+
- **100**: Absolutely certain. Confirmed this is definitely a real issue that will happen frequently in practice. The evidence directly confirms this.
|
|
30
|
+
|
|
31
|
+
**Only report issues with confidence ≥ 80.** Focus on issues that truly matter - quality over quantity.
|
|
32
|
+
|
|
33
|
+
## False Positive Prevention
|
|
34
|
+
|
|
35
|
+
- **Visual/UI behavior**: Do NOT flag CSS transforms (rotate, translate, scale) or visual states without verifying the actual rendering context (e.g., icon position, layout direction). CSS rotate values depend on icon placement — rotate-90 on a right-aligned chevron is correct for a "collapsed" state.
|
|
36
|
+
- **Pre-existing patterns**: If an issue exists in unchanged code and is part of an established pattern, do NOT report it unless it causes actual bugs.
|
|
37
|
+
|
|
38
|
+
## Output Guidance
|
|
39
|
+
|
|
40
|
+
Start by clearly stating what you're reviewing. For each high-confidence issue, provide:
|
|
41
|
+
|
|
42
|
+
- Clear description with confidence score
|
|
43
|
+
- File path and line number
|
|
44
|
+
- Specific project guideline reference or bug explanation
|
|
45
|
+
- Concrete fix suggestion
|
|
46
|
+
|
|
47
|
+
Group issues by severity (Critical vs Important). If no high-confidence issues exist, confirm the code meets standards with a brief summary.
|
|
48
|
+
|
|
49
|
+
Structure your response for maximum actionability - developers should know exactly what to fix and why.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-code-simplifier
|
|
3
|
+
description: Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
|
|
4
|
+
model: inherit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions. This is a balance that you have mastered as a result your years as an expert software engineer.
|
|
8
|
+
|
|
9
|
+
You will analyze recently modified code and apply refinements that:
|
|
10
|
+
|
|
11
|
+
1. **Preserve Functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
|
|
12
|
+
|
|
13
|
+
2. **Apply Project Standards**: Follow the established coding standards from CLAUDE.md including:
|
|
14
|
+
|
|
15
|
+
- Import patterns, module structure, and naming conventions
|
|
16
|
+
- Framework-specific component patterns (as defined in CLAUDE.md)
|
|
17
|
+
- Error handling patterns
|
|
18
|
+
- Type annotation conventions
|
|
19
|
+
|
|
20
|
+
3. **Enhance Clarity**: Simplify code structure by:
|
|
21
|
+
|
|
22
|
+
- Reducing unnecessary complexity and nesting
|
|
23
|
+
- Eliminating redundant code and abstractions
|
|
24
|
+
- Improving readability through clear variable and function names
|
|
25
|
+
- Consolidating related logic
|
|
26
|
+
- Removing unnecessary comments that describe obvious code
|
|
27
|
+
- IMPORTANT: Avoid nested ternary operators - prefer switch statements or if/else chains for multiple conditions
|
|
28
|
+
- Choose clarity over brevity - explicit code is often better than overly compact code
|
|
29
|
+
|
|
30
|
+
4. **Maintain Balance**: Avoid over-simplification that could:
|
|
31
|
+
|
|
32
|
+
- Reduce code clarity or maintainability
|
|
33
|
+
- Create overly clever solutions that are hard to understand
|
|
34
|
+
- Combine too many concerns into single functions or components
|
|
35
|
+
- Remove helpful abstractions that improve code organization
|
|
36
|
+
- Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
|
|
37
|
+
- Make the code harder to debug or extend
|
|
38
|
+
|
|
39
|
+
5. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
|
|
40
|
+
|
|
41
|
+
Your refinement process:
|
|
42
|
+
|
|
43
|
+
1. Identify the recently modified code sections
|
|
44
|
+
2. Analyze for opportunities to improve elegance and consistency
|
|
45
|
+
3. Apply project-specific best practices and coding standards
|
|
46
|
+
4. Ensure all functionality remains unchanged
|
|
47
|
+
5. Verify the refined code is simpler and more maintainable
|
|
48
|
+
6. Document only significant changes that affect understanding
|
|
49
|
+
|
|
50
|
+
You operate autonomously and proactively, refining code immediately after it's written or modified without requiring explicit requests. Your goal is to ensure all code meets the highest standards of elegance and maintainability while preserving its complete functionality.
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import os from "os";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { stdin } from "process";
|
|
6
|
+
|
|
7
|
+
//#region Constants
|
|
8
|
+
|
|
9
|
+
const STDIN_TIMEOUT_MS = 5000;
|
|
10
|
+
const FETCH_TIMEOUT_MS = 3000;
|
|
11
|
+
const PROGRESS_BAR_SIZE = 5;
|
|
12
|
+
const PROGRESS_BAR_UNIT = 100 / PROGRESS_BAR_SIZE; // 20
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
|
|
16
|
+
//#region Stdin
|
|
17
|
+
|
|
18
|
+
/** @returns {Promise<string>} */
|
|
19
|
+
function readStdin() {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
let data = "";
|
|
22
|
+
|
|
23
|
+
const cleanup = () => {
|
|
24
|
+
stdin.removeAllListeners("data");
|
|
25
|
+
stdin.removeAllListeners("end");
|
|
26
|
+
stdin.removeAllListeners("error");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const timeout = setTimeout(() => {
|
|
30
|
+
cleanup();
|
|
31
|
+
resolve("");
|
|
32
|
+
}, STDIN_TIMEOUT_MS);
|
|
33
|
+
|
|
34
|
+
stdin.setEncoding("utf8");
|
|
35
|
+
stdin.on("data", (chunk) => {
|
|
36
|
+
data += chunk;
|
|
37
|
+
});
|
|
38
|
+
stdin.on("end", () => {
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
cleanup();
|
|
41
|
+
resolve(data);
|
|
42
|
+
});
|
|
43
|
+
stdin.on("error", () => {
|
|
44
|
+
clearTimeout(timeout);
|
|
45
|
+
cleanup();
|
|
46
|
+
resolve("");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
|
|
53
|
+
//#region OAuth
|
|
54
|
+
|
|
55
|
+
/** @returns {string | undefined} */
|
|
56
|
+
function getOAuthToken() {
|
|
57
|
+
try {
|
|
58
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
|
|
59
|
+
const credentialsPath = path.join(configDir, ".credentials.json");
|
|
60
|
+
if (!fs.existsSync(credentialsPath)) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const content = fs.readFileSync(credentialsPath, "utf-8");
|
|
65
|
+
const credentials = JSON.parse(content);
|
|
66
|
+
const oauth = credentials.claudeAiOauth;
|
|
67
|
+
|
|
68
|
+
// 토큰 만료 체크
|
|
69
|
+
if (oauth?.expiresAt != null && Date.now() > oauth.expiresAt) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return oauth?.accessToken;
|
|
74
|
+
} catch {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* OAuth 토큰을 사용하여 Anthropic API 사용량 정보를 조회한다.
|
|
81
|
+
* @param {string} token - OAuth 액세스 토큰
|
|
82
|
+
* @returns {Promise<{
|
|
83
|
+
* seven_day?: {utilization?: number, resets_at?: string}, // 7일 사용량
|
|
84
|
+
* daily?: {utilization?: number, resets_at?: string}, // 일일 사용량
|
|
85
|
+
* five_hour?: {utilization?: number, resets_at?: string}, // 5시간 사용량
|
|
86
|
+
* extra_usage?: {is_enabled?: boolean, monthly_limit?: number | null, used_credits?: number} // extra usage
|
|
87
|
+
* } | undefined>}
|
|
88
|
+
*/
|
|
89
|
+
async function fetchUsage(token) {
|
|
90
|
+
try {
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
93
|
+
|
|
94
|
+
const response = await fetch("https://api.anthropic.com/api/oauth/usage", {
|
|
95
|
+
headers: {
|
|
96
|
+
"Authorization": `Bearer ${token}`,
|
|
97
|
+
"anthropic-beta": "oauth-2025-04-20",
|
|
98
|
+
},
|
|
99
|
+
signal: controller.signal,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const data = await response.json();
|
|
109
|
+
|
|
110
|
+
// 응답 구조 검증
|
|
111
|
+
if (data == null || typeof data !== "object") {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return data;
|
|
116
|
+
} catch {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
|
|
123
|
+
//#region Formatting
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {number | undefined} value
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
function formatPercent(value) {
|
|
130
|
+
if (value == null) return "?";
|
|
131
|
+
return Math.round(value).toString();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param {string | undefined} isoDate
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
function formatTimeRemaining(isoDate) {
|
|
139
|
+
if (isoDate == null) return "";
|
|
140
|
+
try {
|
|
141
|
+
const resetTime = new Date(isoDate).getTime();
|
|
142
|
+
if (Number.isNaN(resetTime)) return "";
|
|
143
|
+
|
|
144
|
+
const now = Date.now();
|
|
145
|
+
const diffMs = resetTime - now;
|
|
146
|
+
|
|
147
|
+
if (diffMs <= 0) return "";
|
|
148
|
+
|
|
149
|
+
const diffMinutes = Math.floor(diffMs / (1000 * 60));
|
|
150
|
+
const diffHours = Math.floor(diffMinutes / 60);
|
|
151
|
+
const days = Math.floor(diffHours / 24);
|
|
152
|
+
const hours = diffHours % 24;
|
|
153
|
+
const minutes = diffMinutes % 60;
|
|
154
|
+
|
|
155
|
+
if (days > 0) {
|
|
156
|
+
return `${days}d${hours}h`;
|
|
157
|
+
}
|
|
158
|
+
if (hours > 0) {
|
|
159
|
+
return `${hours}h${minutes}m`;
|
|
160
|
+
}
|
|
161
|
+
return `${minutes}m`;
|
|
162
|
+
} catch {
|
|
163
|
+
return "";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 퍼센트 값을 5칸 프로그레스 바 문자열로 변환한다.
|
|
169
|
+
* 각 칸은 20%를 나타내며, 채워진 칸은 ■, 빈 칸은 □로 표시한다.
|
|
170
|
+
* @param {number} percent - 0~100 범위의 퍼센트 값
|
|
171
|
+
* @returns {string} 5글자 프로그레스 바 문자열 (예: "■■■□□")
|
|
172
|
+
*/
|
|
173
|
+
function formatProgressBar(percent) {
|
|
174
|
+
const clamped = Math.min(Math.max(percent, 0), 100);
|
|
175
|
+
const filled = Math.round(clamped / PROGRESS_BAR_UNIT);
|
|
176
|
+
const empty = PROGRESS_BAR_SIZE - filled;
|
|
177
|
+
return "■".repeat(filled) + "□".repeat(empty);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
|
|
182
|
+
//#region Main
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* stdin으로 입력받은 JSON 정보
|
|
186
|
+
* @typedef {object} StdinInput
|
|
187
|
+
* @property {{display_name?: string}} [model] - 모델 정보
|
|
188
|
+
* @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] - 컨텍스트 윈도우 정보
|
|
189
|
+
* @property {{tokens_used?: number, tokens_limit?: number}} [weekly_token_usage] - 주간 토큰 사용량 (fallback용)
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Claude Code 상태 표시줄 정보를 출력한다.
|
|
194
|
+
* stdin으로 입력받은 JSON과 OAuth API 응답을 조합하여
|
|
195
|
+
* 모델명, 컨텍스트 사용량, 일일/주간 사용량을 출력한다.
|
|
196
|
+
*/
|
|
197
|
+
async function main() {
|
|
198
|
+
const inputStr = await readStdin();
|
|
199
|
+
/** @type {StdinInput} */
|
|
200
|
+
let input = {};
|
|
201
|
+
|
|
202
|
+
if (inputStr !== "") {
|
|
203
|
+
try {
|
|
204
|
+
input = JSON.parse(inputStr);
|
|
205
|
+
} catch {
|
|
206
|
+
// JSON 파싱 실패 시 빈 객체 사용
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 기본 정보
|
|
211
|
+
const modelName = input.model?.display_name ?? "Unknown";
|
|
212
|
+
const contextSize = input.context_window?.context_window_size ?? 0;
|
|
213
|
+
const usage = input.context_window?.current_usage;
|
|
214
|
+
const contextUsed =
|
|
215
|
+
(usage?.input_tokens ?? 0) +
|
|
216
|
+
(usage?.output_tokens ?? 0) +
|
|
217
|
+
(usage?.cache_creation_input_tokens ?? 0) +
|
|
218
|
+
(usage?.cache_read_input_tokens ?? 0);
|
|
219
|
+
const contextPercent = contextSize > 0 ? Math.round((contextUsed / contextSize) * 100) : 0;
|
|
220
|
+
|
|
221
|
+
// OAuth 토큰으로 사용량 조회 시도
|
|
222
|
+
const token = getOAuthToken();
|
|
223
|
+
let dailyPercent = "?";
|
|
224
|
+
let dailyResetTime = "";
|
|
225
|
+
let weekPercent = "?";
|
|
226
|
+
let weekResetDay = "";
|
|
227
|
+
let extraUsage = "";
|
|
228
|
+
|
|
229
|
+
if (token != null) {
|
|
230
|
+
const usageResponse = await fetchUsage(token);
|
|
231
|
+
if (usageResponse != null) {
|
|
232
|
+
// daily 또는 five_hour 사용
|
|
233
|
+
const dailyData = usageResponse.daily ?? usageResponse.five_hour;
|
|
234
|
+
dailyPercent = formatPercent(dailyData?.utilization);
|
|
235
|
+
dailyResetTime = formatTimeRemaining(dailyData?.resets_at);
|
|
236
|
+
weekPercent = formatPercent(usageResponse.seven_day?.utilization);
|
|
237
|
+
weekResetDay = formatTimeRemaining(usageResponse.seven_day?.resets_at);
|
|
238
|
+
|
|
239
|
+
// extra usage
|
|
240
|
+
if (usageResponse.extra_usage?.is_enabled && usageResponse.extra_usage.used_credits != null) {
|
|
241
|
+
extraUsage = `$${(usageResponse.extra_usage.used_credits / 100).toFixed(2)}`;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// fallback: weekly_token_usage
|
|
247
|
+
if (weekPercent === "?" && input.weekly_token_usage != null) {
|
|
248
|
+
const used = input.weekly_token_usage.tokens_used ?? 0;
|
|
249
|
+
const limit = input.weekly_token_usage.tokens_limit ?? 0;
|
|
250
|
+
if (limit > 0) {
|
|
251
|
+
weekPercent = Math.round((used / limit) * 100).toString();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 폴더명 + git 브랜치
|
|
256
|
+
const cwd = input.cwd ?? process.cwd();
|
|
257
|
+
const folderName = path.basename(cwd);
|
|
258
|
+
|
|
259
|
+
// 출력
|
|
260
|
+
const ctxBar = formatProgressBar(contextPercent);
|
|
261
|
+
const dailyBar = dailyPercent !== "?" ? formatProgressBar(Number(dailyPercent)) : "□□□□□";
|
|
262
|
+
const weekBar = weekPercent !== "?" ? formatProgressBar(Number(weekPercent)) : "□□□□□";
|
|
263
|
+
console.log(
|
|
264
|
+
`${modelName} ${ctxBar} ${contextPercent}% ─ ${dailyResetTime} ${dailyBar} ${dailyPercent}% ─ ${weekResetDay} ${weekBar} ${weekPercent}% ─ ${extraUsage} ─ ${folderName}`,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
void main();
|
|
269
|
+
|
|
270
|
+
//#endregion
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-api-name-review
|
|
3
|
+
description: Use when reviewing a library or module's public API naming for consistency and industry standard alignment - function names, parameter names, option keys, enum values, type names
|
|
4
|
+
model: haiku
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# sd-api-name-review
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Compare a library/module's public API names against industry standards and review internal consistency, producing a standardization report. **Analysis only — no code modifications.**
|
|
12
|
+
|
|
13
|
+
## Target Selection
|
|
14
|
+
|
|
15
|
+
1. If args contain a path, use that path
|
|
16
|
+
2. Otherwise, ask the user for the target path
|
|
17
|
+
|
|
18
|
+
## Phase 1: API Extraction
|
|
19
|
+
|
|
20
|
+
Use an Explore agent to extract the target's public API surface:
|
|
21
|
+
|
|
22
|
+
- All exported identifiers (functions, classes, types, constants, etc.)
|
|
23
|
+
- Names and types of user-facing parameters/options/config
|
|
24
|
+
- Naming pattern classification (prefixes, suffixes, verb/adjective/noun usage, abbreviations, etc.)
|
|
25
|
+
|
|
26
|
+
## Phase 2: Industry Standard Research
|
|
27
|
+
|
|
28
|
+
Based on Phase 1 results, determine comparison targets and perspectives:
|
|
29
|
+
|
|
30
|
+
1. Identify **recurring naming patterns** from the extracted API
|
|
31
|
+
2. Determine the target's domain and tech stack to **select comparable libraries**
|
|
32
|
+
3. Use **parallel agents** to web-search/fetch official docs for each library, investigating naming conventions for the same pattern categories
|
|
33
|
+
|
|
34
|
+
## Phase 3: Comparative Analysis & Report
|
|
35
|
+
|
|
36
|
+
Cross-compare Phase 1 and Phase 2 results to produce the report.
|
|
37
|
+
|
|
38
|
+
| Priority | Criteria |
|
|
39
|
+
|----------|----------|
|
|
40
|
+
| **P0** | Misaligned with majority of surveyed libraries |
|
|
41
|
+
| **P1** | Internal inconsistency (same concept, different names) |
|
|
42
|
+
| **P2** | Better industry term exists (optional) |
|
|
43
|
+
| **Keep** | Already aligned with standards |
|
|
44
|
+
|
|
45
|
+
Each item includes: current name, recommended change, rationale (usage patterns per library).
|
|
46
|
+
|
|
47
|
+
## Completion Criteria
|
|
48
|
+
|
|
49
|
+
Present the report to the user. No code modifications.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-brainstorm
|
|
3
|
+
description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
|
|
4
|
+
model: inherit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Brainstorming Ideas Into Designs
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
|
|
12
|
+
|
|
13
|
+
Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
|
|
14
|
+
|
|
15
|
+
## The Process
|
|
16
|
+
|
|
17
|
+
**Understanding the idea:**
|
|
18
|
+
- Check out the current project state first (files, docs, recent commits)
|
|
19
|
+
- Ask questions one at a time to refine the idea
|
|
20
|
+
- Prefer multiple choice questions when possible, but open-ended is fine too
|
|
21
|
+
- Only one question per message - if a topic needs more exploration, break it into multiple questions
|
|
22
|
+
- Focus on understanding: purpose, constraints, success criteria
|
|
23
|
+
|
|
24
|
+
**Exploring approaches:**
|
|
25
|
+
- Propose 2-3 different approaches with trade-offs
|
|
26
|
+
- Present options conversationally with your recommendation and reasoning
|
|
27
|
+
- Lead with your recommended option and explain why
|
|
28
|
+
|
|
29
|
+
**Presenting the design:**
|
|
30
|
+
- Once you believe you understand what you're building, present the design
|
|
31
|
+
- Break it into sections of 200-300 words
|
|
32
|
+
- Ask after each section whether it looks right so far
|
|
33
|
+
- Cover: architecture, components, data flow, error handling, testing
|
|
34
|
+
- Be ready to go back and clarify if something doesn't make sense
|
|
35
|
+
|
|
36
|
+
## After the Design
|
|
37
|
+
|
|
38
|
+
**Documentation:**
|
|
39
|
+
- Write the validated design to `docs/plans/YYYY-MM-DD-<topic>-design.md`
|
|
40
|
+
- Commit the design document to git
|
|
41
|
+
|
|
42
|
+
**Implementation (if continuing):**
|
|
43
|
+
- Ask: "Ready to set up for implementation?"
|
|
44
|
+
- Guide the user to next steps:
|
|
45
|
+
- `/sd-worktree` — Create a git worktree for branch isolation before starting work
|
|
46
|
+
- `/sd-plan` — Create a detailed implementation plan from the design
|
|
47
|
+
|
|
48
|
+
## Key Principles
|
|
49
|
+
|
|
50
|
+
- **One question at a time** - Don't overwhelm with multiple questions
|
|
51
|
+
- **Multiple choice preferred** - Easier to answer than open-ended when possible
|
|
52
|
+
- **YAGNI ruthlessly** - Remove unnecessary features from all designs
|
|
53
|
+
- **Explore alternatives** - Always propose 2-3 approaches before settling
|
|
54
|
+
- **Incremental validation** - Present design in sections, validate each
|
|
55
|
+
- **Be flexible** - Go back and clarify when something doesn't make sense
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sd-check
|
|
3
|
+
description: Verify code via typecheck, lint, and tests
|
|
4
|
+
argument-hint: "[path]"
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
- `/sd-check` — verify the entire project
|
|
11
|
+
- `/sd-check packages/core-common` — verify a specific path only
|
|
12
|
+
|
|
13
|
+
If an argument is provided, run against that path. Otherwise, run against the entire project.
|
|
14
|
+
|
|
15
|
+
## Environment Pre-check
|
|
16
|
+
|
|
17
|
+
Before running any verification, confirm the project environment is properly set up.
|
|
18
|
+
Run these checks **in parallel** and report results before proceeding.
|
|
19
|
+
|
|
20
|
+
### 1. pnpm workspace
|
|
21
|
+
|
|
22
|
+
Verify this is a pnpm project:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
ls pnpm-workspace.yaml pnpm-lock.yaml
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Both files must exist. If missing, stop and report to the user.
|
|
29
|
+
|
|
30
|
+
### 2. package.json scripts
|
|
31
|
+
|
|
32
|
+
Read the root `package.json` and confirm these scripts are defined:
|
|
33
|
+
|
|
34
|
+
- `typecheck`
|
|
35
|
+
- `lint`
|
|
36
|
+
|
|
37
|
+
If either is missing, stop and report to the user.
|
|
38
|
+
|
|
39
|
+
### 3. Vitest config
|
|
40
|
+
|
|
41
|
+
Verify vitest is configured:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
ls vitest.config.ts
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If missing, stop and report to the user.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
If all pre-checks pass, report "Environment OK" and proceed to code verification.
|
|
52
|
+
|
|
53
|
+
## Code Verification
|
|
54
|
+
|
|
55
|
+
Run the following 3 checks **in order**.
|
|
56
|
+
If errors occur at any step, **fix the code directly** and re-run that step.
|
|
57
|
+
Repeat until no errors remain, then proceed to the next step.
|
|
58
|
+
|
|
59
|
+
### Step 1: TypeScript Typecheck
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
pnpm typecheck $ARGUMENTS
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
On error: Read the failing file to identify the cause, fix with Edit, then re-run typecheck.
|
|
66
|
+
|
|
67
|
+
### Step 2: ESLint Lint
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
pnpm lint --fix $ARGUMENTS
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
On error: Read the failing file, fix with Edit, then re-run lint.
|
|
74
|
+
|
|
75
|
+
### Step 3: Tests (Vitest)
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
pnpm vitest $ARGUMENTS --run
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Run with `--run` flag for single execution (no watch mode).
|
|
82
|
+
Some packages may require integration tests as configured in vitest.config.ts.
|
|
83
|
+
|
|
84
|
+
On failure: Read the failing test and related source files to identify the cause, fix with Edit, then re-run tests.
|
|
85
|
+
|
|
86
|
+
## Completion Criteria
|
|
87
|
+
|
|
88
|
+
Complete when all 3 steps pass without errors.
|