@stormhwdev/claude-config 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md.template +497 -0
- package/agents/backend-architect.md +185 -0
- package/agents/backend-developer.md +201 -0
- package/agents/domain-expert.md +54 -0
- package/agents/frontend-developer.md +122 -0
- package/agents/integration-tester.md +112 -0
- package/agents/interaction-designer.md +77 -0
- package/agents/product-manager.md +101 -0
- package/bin/cli.js +310 -0
- package/package.json +28 -0
- package/rules/agents.md +49 -0
- package/rules/coding-style.md +26 -0
- package/rules/git-workflow.md +45 -0
- package/rules/hooks.md +11 -0
- package/rules/patterns.md +39 -0
- package/rules/performance.md +55 -0
- package/rules/security.md +28 -0
- package/rules/testing.md +25 -0
- package/settings.json +11 -0
- package/templates/PRD.md.tpl +109 -0
- package/templates/changelog.md.tpl +78 -0
- package/templates/contracts.md.tpl +112 -0
- package/templates/design-overview.md.tpl +83 -0
- package/templates/feature.md.tpl +94 -0
- package/templates/lifecycle-archive-index.md.tpl +12 -0
- package/templates/lifecycle.md.tpl +116 -0
- package/templates/module-dependencies.md.tpl +71 -0
- package/templates/prd-feature.md.tpl +56 -0
- package/templates/service-dependencies.md.tpl +67 -0
- package/templates/topology.md.tpl +28 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
// ─── Colors ────────────────────────────────────────────────────
|
|
8
|
+
const C = {
|
|
9
|
+
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
10
|
+
yellow: (s) => `\x1b[33m${s}\x1b[0m`,
|
|
11
|
+
red: (s) => `\x1b[31m${s}\x1b[0m`,
|
|
12
|
+
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
13
|
+
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
14
|
+
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const info = (msg) => console.log(`${C.green('✓')} ${msg}`);
|
|
18
|
+
const warn = (msg) => console.log(`${C.yellow('!')} ${msg}`);
|
|
19
|
+
const error = (msg) => console.error(`${C.red('✗')} ${msg}`);
|
|
20
|
+
|
|
21
|
+
// ─── Paths ─────────────────────────────────────────────────────
|
|
22
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
23
|
+
const CLAUDE_DIR = path.join(process.env.HOME || process.env.USERPROFILE, '.claude');
|
|
24
|
+
|
|
25
|
+
// Directories to install at user level
|
|
26
|
+
const DIRS = ['agents', 'templates', 'rules'];
|
|
27
|
+
// Files to merge/install at user level
|
|
28
|
+
const MERGE_FILES = ['settings.json'];
|
|
29
|
+
|
|
30
|
+
// ─── Helpers ───────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
function ask(question) {
|
|
33
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
rl.question(question, (answer) => {
|
|
36
|
+
rl.close();
|
|
37
|
+
resolve(answer.trim().toLowerCase());
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function copyDirSync(src, dst) {
|
|
43
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
44
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
45
|
+
const srcPath = path.join(src, entry.name);
|
|
46
|
+
const dstPath = path.join(dst, entry.name);
|
|
47
|
+
if (entry.isDirectory()) {
|
|
48
|
+
copyDirSync(srcPath, dstPath);
|
|
49
|
+
} else {
|
|
50
|
+
fs.copyFileSync(srcPath, dstPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function filesEqual(a, b) {
|
|
56
|
+
try {
|
|
57
|
+
return fs.readFileSync(a).equals(fs.readFileSync(b));
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function countFiles(dir) {
|
|
64
|
+
let count = 0;
|
|
65
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
66
|
+
if (entry.isDirectory()) {
|
|
67
|
+
count += countFiles(path.join(dir, entry.name));
|
|
68
|
+
} else {
|
|
69
|
+
count++;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return count;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function deepMerge(target, source) {
|
|
76
|
+
const result = { ...target };
|
|
77
|
+
for (const key of Object.keys(source)) {
|
|
78
|
+
if (
|
|
79
|
+
source[key] &&
|
|
80
|
+
typeof source[key] === 'object' &&
|
|
81
|
+
!Array.isArray(source[key]) &&
|
|
82
|
+
target[key] &&
|
|
83
|
+
typeof target[key] === 'object' &&
|
|
84
|
+
!Array.isArray(target[key])
|
|
85
|
+
) {
|
|
86
|
+
result[key] = deepMerge(target[key], source[key]);
|
|
87
|
+
} else {
|
|
88
|
+
result[key] = source[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ─── Commands ──────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
async function cmdInit(opts) {
|
|
97
|
+
console.log('');
|
|
98
|
+
console.log(C.bold('Claude Code 研发规范配置安装'));
|
|
99
|
+
console.log(C.dim(`源: ${PKG_ROOT}`));
|
|
100
|
+
console.log(C.dim(`目标: ${CLAUDE_DIR}`));
|
|
101
|
+
console.log('');
|
|
102
|
+
|
|
103
|
+
fs.mkdirSync(CLAUDE_DIR, { recursive: true });
|
|
104
|
+
|
|
105
|
+
// 1. Copy directories
|
|
106
|
+
for (const dir of DIRS) {
|
|
107
|
+
const src = path.join(PKG_ROOT, dir);
|
|
108
|
+
const dst = path.join(CLAUDE_DIR, dir);
|
|
109
|
+
|
|
110
|
+
if (!fs.existsSync(src)) {
|
|
111
|
+
warn(`源目录不存在,跳过: ${dir}/`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// If dst is a symlink, remove it first (migrating from symlink-based install)
|
|
116
|
+
if (fs.existsSync(dst) && fs.lstatSync(dst).isSymbolicLink()) {
|
|
117
|
+
if (!opts.force) {
|
|
118
|
+
const answer = await ask(` ${dir}/ 当前是符号链接,替换为文件副本?[Y/n] `);
|
|
119
|
+
if (answer === 'n') {
|
|
120
|
+
warn(`${dir}/ 跳过`);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
fs.unlinkSync(dst);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (fs.existsSync(dst) && !opts.force) {
|
|
128
|
+
// Check if content is identical
|
|
129
|
+
const srcCount = countFiles(src);
|
|
130
|
+
const dstCount = countFiles(dst);
|
|
131
|
+
if (srcCount === dstCount) {
|
|
132
|
+
info(`${dir}/ 已是最新 (${srcCount} 个文件)`);
|
|
133
|
+
// Still overwrite to ensure content matches
|
|
134
|
+
copyDirSync(src, dst);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
copyDirSync(src, dst);
|
|
140
|
+
info(`${dir}/ 已安装 (${countFiles(src)} 个文件)`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 2. Merge settings.json
|
|
144
|
+
for (const file of MERGE_FILES) {
|
|
145
|
+
const src = path.join(PKG_ROOT, file);
|
|
146
|
+
const dst = path.join(CLAUDE_DIR, file);
|
|
147
|
+
|
|
148
|
+
if (!fs.existsSync(src)) continue;
|
|
149
|
+
|
|
150
|
+
// If dst is a symlink, remove it first
|
|
151
|
+
if (fs.existsSync(dst) && fs.lstatSync(dst).isSymbolicLink()) {
|
|
152
|
+
fs.unlinkSync(dst);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (fs.existsSync(dst) && !fs.lstatSync(dst).isSymbolicLink()) {
|
|
156
|
+
try {
|
|
157
|
+
const existing = JSON.parse(fs.readFileSync(dst, 'utf8'));
|
|
158
|
+
const incoming = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
159
|
+
const merged = deepMerge(existing, incoming);
|
|
160
|
+
|
|
161
|
+
if (JSON.stringify(existing) === JSON.stringify(merged)) {
|
|
162
|
+
info(`${file} 已是最新`);
|
|
163
|
+
} else {
|
|
164
|
+
fs.writeFileSync(dst, JSON.stringify(merged, null, 2) + '\n');
|
|
165
|
+
info(`${file} 已合并更新`);
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
// If existing file is malformed, overwrite
|
|
169
|
+
fs.copyFileSync(src, dst);
|
|
170
|
+
info(`${file} 已覆盖`);
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
fs.copyFileSync(src, dst);
|
|
174
|
+
info(`${file} 已安装`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log(C.green('安装完成!'));
|
|
180
|
+
console.log('');
|
|
181
|
+
console.log(`使用 ${C.cyan('claude-config apply')} 将 CLAUDE.md 应用到具体项目`);
|
|
182
|
+
console.log('');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function cmdApply(opts) {
|
|
186
|
+
const src = path.join(PKG_ROOT, 'CLAUDE.md.template');
|
|
187
|
+
const dst = path.join(process.cwd(), 'CLAUDE.md');
|
|
188
|
+
|
|
189
|
+
if (!fs.existsSync(src)) {
|
|
190
|
+
error('CLAUDE.md.template 不存在');
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (fs.existsSync(dst) && !opts.force) {
|
|
195
|
+
if (filesEqual(src, dst)) {
|
|
196
|
+
info('CLAUDE.md 已是最新,无需更新');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const answer = await ask(`当前目录已有 CLAUDE.md,覆盖?[Y/n] `);
|
|
201
|
+
if (answer === 'n') {
|
|
202
|
+
warn('已取消');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
fs.copyFileSync(src, dst);
|
|
208
|
+
info(`CLAUDE.md 已写入 ${process.cwd()}/CLAUDE.md`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function cmdHelp() {
|
|
212
|
+
console.log('');
|
|
213
|
+
console.log(C.bold('Claude Code 研发规范配置'));
|
|
214
|
+
console.log('');
|
|
215
|
+
console.log('命令:');
|
|
216
|
+
console.log(` ${C.cyan('init')} 安装/更新用户级配置到 ~/.claude/`);
|
|
217
|
+
console.log(` ${C.cyan('apply')} 将 CLAUDE.md 模板应用到当前项目`);
|
|
218
|
+
console.log(` ${C.cyan('status')} 查看当前配置状态`);
|
|
219
|
+
console.log(` ${C.cyan('help')} 显示帮助信息`);
|
|
220
|
+
console.log('');
|
|
221
|
+
console.log('选项:');
|
|
222
|
+
console.log(` ${C.cyan('--force')} 跳过确认提示,强制覆盖`);
|
|
223
|
+
console.log('');
|
|
224
|
+
console.log('示例:');
|
|
225
|
+
console.log(` ${C.dim('# 首次安装')}`);
|
|
226
|
+
console.log(` npx @stormhwdev/claude-config init`);
|
|
227
|
+
console.log('');
|
|
228
|
+
console.log(` ${C.dim('# 在项目根目录应用 CLAUDE.md')}`);
|
|
229
|
+
console.log(` cd your-project && npx @stormhwdev/claude-config apply`);
|
|
230
|
+
console.log('');
|
|
231
|
+
console.log(` ${C.dim('# 更新到最新版')}`);
|
|
232
|
+
console.log(` npx @stormhwdev/claude-config@latest init`);
|
|
233
|
+
console.log('');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function cmdStatus() {
|
|
237
|
+
console.log('');
|
|
238
|
+
console.log(C.bold('配置状态'));
|
|
239
|
+
console.log('');
|
|
240
|
+
|
|
241
|
+
// Check user-level
|
|
242
|
+
for (const dir of DIRS) {
|
|
243
|
+
const dst = path.join(CLAUDE_DIR, dir);
|
|
244
|
+
if (fs.existsSync(dst)) {
|
|
245
|
+
const isLink = fs.lstatSync(dst).isSymbolicLink();
|
|
246
|
+
const count = isLink ? '(symlink)' : `${countFiles(dst)} 个文件`;
|
|
247
|
+
info(`~/.claude/${dir}/ ${C.dim(count)}`);
|
|
248
|
+
} else {
|
|
249
|
+
warn(`~/.claude/${dir}/ ${C.dim('未安装')}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
for (const file of MERGE_FILES) {
|
|
254
|
+
const dst = path.join(CLAUDE_DIR, file);
|
|
255
|
+
if (fs.existsSync(dst)) {
|
|
256
|
+
info(`~/.claude/${file} ${C.dim('已配置')}`);
|
|
257
|
+
} else {
|
|
258
|
+
warn(`~/.claude/${file} ${C.dim('未安装')}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Check project-level
|
|
263
|
+
console.log('');
|
|
264
|
+
const claudeMd = path.join(process.cwd(), 'CLAUDE.md');
|
|
265
|
+
if (fs.existsSync(claudeMd)) {
|
|
266
|
+
info(`./CLAUDE.md ${C.dim('已存在')}`);
|
|
267
|
+
} else {
|
|
268
|
+
warn(`./CLAUDE.md ${C.dim('未配置 (使用 claude-config apply 应用)')}`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
console.log('');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ─── Main ──────────────────────────────────────────────────────
|
|
275
|
+
|
|
276
|
+
async function main() {
|
|
277
|
+
const args = process.argv.slice(2);
|
|
278
|
+
const command = args.find((a) => !a.startsWith('-')) || 'help';
|
|
279
|
+
const opts = {
|
|
280
|
+
force: args.includes('--force') || args.includes('-f'),
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
switch (command) {
|
|
284
|
+
case 'init':
|
|
285
|
+
case 'install':
|
|
286
|
+
case 'update':
|
|
287
|
+
await cmdInit(opts);
|
|
288
|
+
break;
|
|
289
|
+
case 'apply':
|
|
290
|
+
await cmdApply(opts);
|
|
291
|
+
break;
|
|
292
|
+
case 'status':
|
|
293
|
+
cmdStatus();
|
|
294
|
+
break;
|
|
295
|
+
case 'help':
|
|
296
|
+
case '--help':
|
|
297
|
+
case '-h':
|
|
298
|
+
cmdHelp();
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
error(`未知命令: ${command}`);
|
|
302
|
+
cmdHelp();
|
|
303
|
+
process.exit(1);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
main().catch((err) => {
|
|
308
|
+
error(err.message);
|
|
309
|
+
process.exit(1);
|
|
310
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stormhwdev/claude-config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Claude Code 研发规范配置 - 一键安装 agents、rules、templates 到 ~/.claude/",
|
|
5
|
+
"bin": {
|
|
6
|
+
"claude-config": "bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"agents/",
|
|
11
|
+
"rules/",
|
|
12
|
+
"templates/",
|
|
13
|
+
"settings.json",
|
|
14
|
+
"CLAUDE.md.template"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"claude",
|
|
18
|
+
"claude-code",
|
|
19
|
+
"ai",
|
|
20
|
+
"agent",
|
|
21
|
+
"config"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": ""
|
|
27
|
+
}
|
|
28
|
+
}
|
package/rules/agents.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Agent Orchestration
|
|
2
|
+
|
|
3
|
+
## Available Agents
|
|
4
|
+
|
|
5
|
+
Located in `~/.claude/agents/`:
|
|
6
|
+
|
|
7
|
+
| Agent | Purpose | When to Use |
|
|
8
|
+
|-------|---------|-------------|
|
|
9
|
+
| planner | Implementation planning | Complex features, refactoring |
|
|
10
|
+
| architect | System design | Architectural decisions |
|
|
11
|
+
| tdd-guide | Test-driven development | New features, bug fixes |
|
|
12
|
+
| code-reviewer | Code review | After writing code |
|
|
13
|
+
| security-reviewer | Security analysis | Before commits |
|
|
14
|
+
| build-error-resolver | Fix build errors | When build fails |
|
|
15
|
+
| e2e-runner | E2E testing | Critical user flows |
|
|
16
|
+
| refactor-cleaner | Dead code cleanup | Code maintenance |
|
|
17
|
+
| doc-updater | Documentation | Updating docs |
|
|
18
|
+
|
|
19
|
+
## Immediate Agent Usage
|
|
20
|
+
|
|
21
|
+
No user prompt needed:
|
|
22
|
+
1. Complex feature requests - Use **planner** agent
|
|
23
|
+
2. Code just written/modified - Use **code-reviewer** agent
|
|
24
|
+
3. Bug fix or new feature - Use **tdd-guide** agent
|
|
25
|
+
4. Architectural decision - Use **architect** agent
|
|
26
|
+
|
|
27
|
+
## Parallel Task Execution
|
|
28
|
+
|
|
29
|
+
ALWAYS use parallel Task execution for independent operations:
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
# GOOD: Parallel execution
|
|
33
|
+
Launch 3 agents in parallel:
|
|
34
|
+
1. Agent 1: Security analysis of auth module
|
|
35
|
+
2. Agent 2: Performance review of cache system
|
|
36
|
+
3. Agent 3: Type checking of utilities
|
|
37
|
+
|
|
38
|
+
# BAD: Sequential when unnecessary
|
|
39
|
+
First agent 1, then agent 2, then agent 3
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Multi-Perspective Analysis
|
|
43
|
+
|
|
44
|
+
For complex problems, use split role sub-agents:
|
|
45
|
+
- Factual reviewer
|
|
46
|
+
- Senior engineer
|
|
47
|
+
- Security expert
|
|
48
|
+
- Consistency reviewer
|
|
49
|
+
- Redundancy checker
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Go Coding Style
|
|
2
|
+
|
|
3
|
+
> This file extends [common/coding-style.md](../common/coding-style.md) with Go specific content.
|
|
4
|
+
|
|
5
|
+
## Formatting
|
|
6
|
+
|
|
7
|
+
- **gofmt** and **goimports** are mandatory — no style debates
|
|
8
|
+
|
|
9
|
+
## Design Principles
|
|
10
|
+
|
|
11
|
+
- Accept interfaces, return structs
|
|
12
|
+
- Keep interfaces small (1-3 methods)
|
|
13
|
+
|
|
14
|
+
## Error Handling
|
|
15
|
+
|
|
16
|
+
Always wrap errors with context:
|
|
17
|
+
|
|
18
|
+
```go
|
|
19
|
+
if err != nil {
|
|
20
|
+
return fmt.Errorf("failed to create user: %w", err)
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Reference
|
|
25
|
+
|
|
26
|
+
See skill: `golang-patterns` for comprehensive Go idioms and patterns.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Git Workflow
|
|
2
|
+
|
|
3
|
+
## Commit Message Format
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
<type>: <description>
|
|
7
|
+
|
|
8
|
+
<optional body>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Types: feat, fix, refactor, docs, test, chore, perf, ci
|
|
12
|
+
|
|
13
|
+
Note: Attribution disabled globally via ~/.claude/settings.json.
|
|
14
|
+
|
|
15
|
+
## Pull Request Workflow
|
|
16
|
+
|
|
17
|
+
When creating PRs:
|
|
18
|
+
1. Analyze full commit history (not just latest commit)
|
|
19
|
+
2. Use `git diff [base-branch]...HEAD` to see all changes
|
|
20
|
+
3. Draft comprehensive PR summary
|
|
21
|
+
4. Include test plan with TODOs
|
|
22
|
+
5. Push with `-u` flag if new branch
|
|
23
|
+
|
|
24
|
+
## Feature Implementation Workflow
|
|
25
|
+
|
|
26
|
+
1. **Plan First**
|
|
27
|
+
- Use **planner** agent to create implementation plan
|
|
28
|
+
- Identify dependencies and risks
|
|
29
|
+
- Break down into phases
|
|
30
|
+
|
|
31
|
+
2. **TDD Approach**
|
|
32
|
+
- Use **tdd-guide** agent
|
|
33
|
+
- Write tests first (RED)
|
|
34
|
+
- Implement to pass tests (GREEN)
|
|
35
|
+
- Refactor (IMPROVE)
|
|
36
|
+
- Verify 80%+ coverage
|
|
37
|
+
|
|
38
|
+
3. **Code Review**
|
|
39
|
+
- Use **code-reviewer** agent immediately after writing code
|
|
40
|
+
- Address CRITICAL and HIGH issues
|
|
41
|
+
- Fix MEDIUM issues when possible
|
|
42
|
+
|
|
43
|
+
4. **Commit & Push**
|
|
44
|
+
- Detailed commit messages
|
|
45
|
+
- Follow conventional commits format
|
package/rules/hooks.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Go Hooks
|
|
2
|
+
|
|
3
|
+
> This file extends [common/hooks.md](../common/hooks.md) with Go specific content.
|
|
4
|
+
|
|
5
|
+
## PostToolUse Hooks
|
|
6
|
+
|
|
7
|
+
Configure in `~/.claude/settings.json`:
|
|
8
|
+
|
|
9
|
+
- **gofmt/goimports**: Auto-format `.go` files after edit
|
|
10
|
+
- **go vet**: Run static analysis after editing `.go` files
|
|
11
|
+
- **staticcheck**: Run extended static checks on modified packages
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Go Patterns
|
|
2
|
+
|
|
3
|
+
> This file extends [common/patterns.md](../common/patterns.md) with Go specific content.
|
|
4
|
+
|
|
5
|
+
## Functional Options
|
|
6
|
+
|
|
7
|
+
```go
|
|
8
|
+
type Option func(*Server)
|
|
9
|
+
|
|
10
|
+
func WithPort(port int) Option {
|
|
11
|
+
return func(s *Server) { s.port = port }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func NewServer(opts ...Option) *Server {
|
|
15
|
+
s := &Server{port: 8080}
|
|
16
|
+
for _, opt := range opts {
|
|
17
|
+
opt(s)
|
|
18
|
+
}
|
|
19
|
+
return s
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Small Interfaces
|
|
24
|
+
|
|
25
|
+
Define interfaces where they are used, not where they are implemented.
|
|
26
|
+
|
|
27
|
+
## Dependency Injection
|
|
28
|
+
|
|
29
|
+
Use constructor functions to inject dependencies:
|
|
30
|
+
|
|
31
|
+
```go
|
|
32
|
+
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
|
33
|
+
return &UserService{repo: repo, logger: logger}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Reference
|
|
38
|
+
|
|
39
|
+
See skill: `golang-patterns` for comprehensive Go patterns including concurrency, error handling, and package organization.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Performance Optimization
|
|
2
|
+
|
|
3
|
+
## Model Selection Strategy
|
|
4
|
+
|
|
5
|
+
**Haiku 4.5** (90% of Sonnet capability, 3x cost savings):
|
|
6
|
+
- Lightweight agents with frequent invocation
|
|
7
|
+
- Pair programming and code generation
|
|
8
|
+
- Worker agents in multi-agent systems
|
|
9
|
+
|
|
10
|
+
**Sonnet 4.5** (Best coding model):
|
|
11
|
+
- Main development work
|
|
12
|
+
- Orchestrating multi-agent workflows
|
|
13
|
+
- Complex coding tasks
|
|
14
|
+
|
|
15
|
+
**Opus 4.5** (Deepest reasoning):
|
|
16
|
+
- Complex architectural decisions
|
|
17
|
+
- Maximum reasoning requirements
|
|
18
|
+
- Research and analysis tasks
|
|
19
|
+
|
|
20
|
+
## Context Window Management
|
|
21
|
+
|
|
22
|
+
Avoid last 20% of context window for:
|
|
23
|
+
- Large-scale refactoring
|
|
24
|
+
- Feature implementation spanning multiple files
|
|
25
|
+
- Debugging complex interactions
|
|
26
|
+
|
|
27
|
+
Lower context sensitivity tasks:
|
|
28
|
+
- Single-file edits
|
|
29
|
+
- Independent utility creation
|
|
30
|
+
- Documentation updates
|
|
31
|
+
- Simple bug fixes
|
|
32
|
+
|
|
33
|
+
## Extended Thinking + Plan Mode
|
|
34
|
+
|
|
35
|
+
Extended thinking is enabled by default, reserving up to 31,999 tokens for internal reasoning.
|
|
36
|
+
|
|
37
|
+
Control extended thinking via:
|
|
38
|
+
- **Toggle**: Option+T (macOS) / Alt+T (Windows/Linux)
|
|
39
|
+
- **Config**: Set `alwaysThinkingEnabled` in `~/.claude/settings.json`
|
|
40
|
+
- **Budget cap**: `export MAX_THINKING_TOKENS=10000`
|
|
41
|
+
- **Verbose mode**: Ctrl+O to see thinking output
|
|
42
|
+
|
|
43
|
+
For complex tasks requiring deep reasoning:
|
|
44
|
+
1. Ensure extended thinking is enabled (on by default)
|
|
45
|
+
2. Enable **Plan Mode** for structured approach
|
|
46
|
+
3. Use multiple critique rounds for thorough analysis
|
|
47
|
+
4. Use split role sub-agents for diverse perspectives
|
|
48
|
+
|
|
49
|
+
## Build Troubleshooting
|
|
50
|
+
|
|
51
|
+
If build fails:
|
|
52
|
+
1. Use **build-error-resolver** agent
|
|
53
|
+
2. Analyze error messages
|
|
54
|
+
3. Fix incrementally
|
|
55
|
+
4. Verify after each fix
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Go Security
|
|
2
|
+
|
|
3
|
+
> This file extends [common/security.md](../common/security.md) with Go specific content.
|
|
4
|
+
|
|
5
|
+
## Secret Management
|
|
6
|
+
|
|
7
|
+
```go
|
|
8
|
+
apiKey := os.Getenv("OPENAI_API_KEY")
|
|
9
|
+
if apiKey == "" {
|
|
10
|
+
log.Fatal("OPENAI_API_KEY not configured")
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Security Scanning
|
|
15
|
+
|
|
16
|
+
- Use **gosec** for static security analysis:
|
|
17
|
+
```bash
|
|
18
|
+
gosec ./...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Context & Timeouts
|
|
22
|
+
|
|
23
|
+
Always use `context.Context` for timeout control:
|
|
24
|
+
|
|
25
|
+
```go
|
|
26
|
+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
27
|
+
defer cancel()
|
|
28
|
+
```
|
package/rules/testing.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Go Testing
|
|
2
|
+
|
|
3
|
+
> This file extends [common/testing.md](../common/testing.md) with Go specific content.
|
|
4
|
+
|
|
5
|
+
## Framework
|
|
6
|
+
|
|
7
|
+
Use the standard `go test` with **table-driven tests**.
|
|
8
|
+
|
|
9
|
+
## Race Detection
|
|
10
|
+
|
|
11
|
+
Always run with the `-race` flag:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
go test -race ./...
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Coverage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
go test -cover ./...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Reference
|
|
24
|
+
|
|
25
|
+
See skill: `golang-testing` for detailed Go testing patterns and helpers.
|
package/settings.json
ADDED