@simplysm/claude 13.0.0-beta.22
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 +32 -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/rules/sd-context7.md +26 -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 +131 -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-use/SKILL.md +70 -0
- package/claude/skills/sd-worktree/SKILL.md +82 -0
- package/claude/skills/sd-worktree/sd-worktree.mjs +128 -0
- package/package.json +21 -0
- package/scripts/postinstall.mjs +99 -0
- package/scripts/sync-claude-assets.mjs +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @simplysm/claude
|
|
2
|
+
|
|
3
|
+
Simplysm Claude Code skills and agents. Automatically installs via `postinstall` when added as a dev dependency.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @simplysm/claude
|
|
9
|
+
# or
|
|
10
|
+
npm install --save-dev @simplysm/claude
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Skills and agents are automatically installed to `.claude/` on `pnpm install` / `npm install`.
|
|
14
|
+
|
|
15
|
+
## How It Works
|
|
16
|
+
|
|
17
|
+
When installed as a dependency, the `postinstall` script:
|
|
18
|
+
|
|
19
|
+
1. Copies `sd-*` assets (skills, agents, rules) to the project's `.claude/` directory
|
|
20
|
+
2. Configures `statusLine` in `.claude/settings.json`
|
|
21
|
+
3. Existing `sd-*` entries are replaced with the latest version
|
|
22
|
+
|
|
23
|
+
Updates also trigger reinstallation (`pnpm up @simplysm/claude`).
|
|
24
|
+
|
|
25
|
+
## Note
|
|
26
|
+
|
|
27
|
+
- If using `pnpm install --ignore-scripts`, the postinstall won't run
|
|
28
|
+
- If using `onlyBuiltDependencies` in `pnpm-workspace.yaml`, add `@simplysm/claude` to the list
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
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,26 @@
|
|
|
1
|
+
# Simplysm Documentation via Context7 MCP
|
|
2
|
+
|
|
3
|
+
When you need to look up usage examples or API details for `@simplysm/*` packages, use the Context7 MCP tools.
|
|
4
|
+
|
|
5
|
+
The simplysm library is registered as `/kslhunter/simplysm` on Context7.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
Skip `resolve-library-id` (the ID is already known) and call `query-docs` directly:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
query-docs(libraryId="/kslhunter/simplysm", query="<your question>")
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example queries
|
|
16
|
+
|
|
17
|
+
- `query-docs(libraryId="/kslhunter/simplysm", query="How to define ORM table with columns and primary key")`
|
|
18
|
+
- `query-docs(libraryId="/kslhunter/simplysm", query="SolidJS Select component usage")`
|
|
19
|
+
- `query-docs(libraryId="/kslhunter/simplysm", query="ServiceClient WebSocket RPC call")`
|
|
20
|
+
- `query-docs(libraryId="/kslhunter/simplysm", query="DateTime custom type usage")`
|
|
21
|
+
|
|
22
|
+
## When to use
|
|
23
|
+
|
|
24
|
+
- Before writing code that uses an unfamiliar `@simplysm/*` API
|
|
25
|
+
- When unsure about component props, method signatures, or configuration options
|
|
26
|
+
- When looking for usage patterns or code examples within the framework
|
|
@@ -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: sonnet
|
|
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
|