claudekit-cli 1.0.1 → 1.2.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/.github/workflows/ci.yml +2 -0
- package/.github/workflows/release.yml +44 -0
- package/CHANGELOG.md +28 -0
- package/CLAUDE.md +3 -2
- package/LICENSE +21 -0
- package/README.md +73 -3
- package/dist/index.js +11556 -10926
- package/package.json +1 -1
- package/src/commands/new.ts +41 -9
- package/src/commands/update.ts +59 -13
- package/src/commands/version.ts +135 -0
- package/src/index.ts +53 -1
- package/src/lib/download.ts +231 -1
- package/src/lib/github.ts +56 -0
- package/src/lib/prompts.ts +4 -3
- package/src/types.ts +11 -2
- package/src/utils/file-scanner.ts +134 -0
- package/src/utils/logger.ts +108 -21
- package/src/utils/safe-prompts.ts +54 -0
- package/tests/commands/version.test.ts +297 -0
- package/tests/lib/github-download-priority.test.ts +301 -0
- package/tests/lib/github.test.ts +2 -2
- package/tests/lib/merge.test.ts +77 -0
- package/tests/types.test.ts +4 -0
- package/tests/utils/file-scanner.test.ts +202 -0
- package/tests/utils/logger.test.ts +115 -0
- package/.opencode/agent/code-reviewer.md +0 -141
- package/.opencode/agent/debugger.md +0 -74
- package/.opencode/agent/docs-manager.md +0 -119
- package/.opencode/agent/git-manager.md +0 -60
- package/.opencode/agent/planner-researcher.md +0 -100
- package/.opencode/agent/planner.md +0 -87
- package/.opencode/agent/project-manager.md +0 -113
- package/.opencode/agent/researcher.md +0 -173
- package/.opencode/agent/solution-brainstormer.md +0 -89
- package/.opencode/agent/system-architecture.md +0 -192
- package/.opencode/agent/tester.md +0 -96
- package/.opencode/agent/ui-ux-designer.md +0 -203
- package/.opencode/agent/ui-ux-developer.md +0 -97
- package/.opencode/command/cook.md +0 -7
- package/.opencode/command/debug.md +0 -10
- package/.opencode/command/design/3d.md +0 -65
- package/.opencode/command/design/fast.md +0 -18
- package/.opencode/command/design/good.md +0 -21
- package/.opencode/command/design/screenshot.md +0 -22
- package/.opencode/command/design/video.md +0 -22
- package/.opencode/command/fix/ci.md +0 -8
- package/.opencode/command/fix/fast.md +0 -11
- package/.opencode/command/fix/hard.md +0 -15
- package/.opencode/command/fix/logs.md +0 -16
- package/.opencode/command/fix/test.md +0 -18
- package/.opencode/command/fix/types.md +0 -10
- package/.opencode/command/git/cm.md +0 -5
- package/.opencode/command/git/cp.md +0 -4
- package/.opencode/command/plan/ci.md +0 -12
- package/.opencode/command/plan/two.md +0 -13
- package/.opencode/command/plan.md +0 -10
- package/.opencode/command/test.md +0 -7
- package/.opencode/command/watzup.md +0 -8
- package/plans/251008-claudekit-cli-implementation-plan.md +0 -1469
- package/plans/reports/251008-from-code-reviewer-to-developer-review-report.md +0 -864
- package/plans/reports/251008-from-tester-to-developer-test-summary-report.md +0 -409
- package/plans/reports/251008-researcher-download-extraction-report.md +0 -1377
- package/plans/reports/251008-researcher-github-api-report.md +0 -1339
- package/plans/research/251008-cli-frameworks-bun-research.md +0 -1051
- package/plans/templates/bug-fix-template.md +0 -69
- package/plans/templates/feature-implementation-template.md +0 -84
- package/plans/templates/refactor-template.md +0 -82
- package/plans/templates/template-usage-guide.md +0 -58
package/tests/types.test.ts
CHANGED
|
@@ -156,6 +156,8 @@ describe("Types and Schemas", () => {
|
|
|
156
156
|
},
|
|
157
157
|
],
|
|
158
158
|
published_at: "2024-01-01T00:00:00Z",
|
|
159
|
+
tarball_url: "https://api.github.com/repos/test/test-repo/tarball/v1.0.0",
|
|
160
|
+
zipball_url: "https://api.github.com/repos/test/test-repo/zipball/v1.0.0",
|
|
159
161
|
};
|
|
160
162
|
const result = GitHubReleaseSchema.parse(release);
|
|
161
163
|
expect(result.id).toBe(1);
|
|
@@ -171,6 +173,8 @@ describe("Types and Schemas", () => {
|
|
|
171
173
|
draft: false,
|
|
172
174
|
prerelease: false,
|
|
173
175
|
assets: [],
|
|
176
|
+
tarball_url: "https://api.github.com/repos/test/test-repo/tarball/v1.0.0",
|
|
177
|
+
zipball_url: "https://api.github.com/repos/test/test-repo/zipball/v1.0.0",
|
|
174
178
|
};
|
|
175
179
|
const result = GitHubReleaseSchema.parse(release);
|
|
176
180
|
expect(result.published_at).toBeUndefined();
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { mkdir, remove, writeFile } from "fs-extra";
|
|
4
|
+
import { FileScanner } from "../../src/utils/file-scanner.js";
|
|
5
|
+
|
|
6
|
+
describe("FileScanner", () => {
|
|
7
|
+
const testDir = join(__dirname, "..", "..", "temp-test-file-scanner");
|
|
8
|
+
const destDir = join(testDir, "dest");
|
|
9
|
+
const sourceDir = join(testDir, "source");
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
// Clean up and create test directories
|
|
13
|
+
await remove(testDir);
|
|
14
|
+
await mkdir(testDir, { recursive: true });
|
|
15
|
+
await mkdir(destDir, { recursive: true });
|
|
16
|
+
await mkdir(sourceDir, { recursive: true });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(async () => {
|
|
20
|
+
// Clean up test directories
|
|
21
|
+
await remove(testDir);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("getFiles", () => {
|
|
25
|
+
test("should return empty array for non-existent directory", async () => {
|
|
26
|
+
const files = await FileScanner.getFiles(join(testDir, "non-existent"));
|
|
27
|
+
expect(files).toEqual([]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("should return files from directory", async () => {
|
|
31
|
+
// Create test files
|
|
32
|
+
await writeFile(join(destDir, "file1.txt"), "content1");
|
|
33
|
+
await writeFile(join(destDir, "file2.txt"), "content2");
|
|
34
|
+
|
|
35
|
+
const files = await FileScanner.getFiles(destDir);
|
|
36
|
+
|
|
37
|
+
expect(files).toHaveLength(2);
|
|
38
|
+
expect(files).toContain("file1.txt");
|
|
39
|
+
expect(files).toContain("file2.txt");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("should recursively scan subdirectories", async () => {
|
|
43
|
+
// Create nested structure
|
|
44
|
+
await mkdir(join(destDir, "subdir"), { recursive: true });
|
|
45
|
+
await writeFile(join(destDir, "file1.txt"), "content1");
|
|
46
|
+
await writeFile(join(destDir, "subdir", "file2.txt"), "content2");
|
|
47
|
+
|
|
48
|
+
const files = await FileScanner.getFiles(destDir);
|
|
49
|
+
|
|
50
|
+
expect(files).toHaveLength(2);
|
|
51
|
+
expect(files).toContain("file1.txt");
|
|
52
|
+
expect(files).toContain("subdir/file2.txt");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("should handle empty directory", async () => {
|
|
56
|
+
const files = await FileScanner.getFiles(destDir);
|
|
57
|
+
expect(files).toEqual([]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("should handle deeply nested directories", async () => {
|
|
61
|
+
// Create deeply nested structure
|
|
62
|
+
const deepPath = join(destDir, "a", "b", "c", "d");
|
|
63
|
+
await mkdir(deepPath, { recursive: true });
|
|
64
|
+
await writeFile(join(deepPath, "deep.txt"), "deep content");
|
|
65
|
+
|
|
66
|
+
const files = await FileScanner.getFiles(destDir);
|
|
67
|
+
|
|
68
|
+
expect(files).toHaveLength(1);
|
|
69
|
+
expect(files).toContain("a/b/c/d/deep.txt");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("should return relative paths", async () => {
|
|
73
|
+
await mkdir(join(destDir, "subdir"), { recursive: true });
|
|
74
|
+
await writeFile(join(destDir, "subdir", "file.txt"), "content");
|
|
75
|
+
|
|
76
|
+
const files = await FileScanner.getFiles(destDir);
|
|
77
|
+
|
|
78
|
+
// Should return relative path, not absolute
|
|
79
|
+
expect(files[0]).toBe("subdir/file.txt");
|
|
80
|
+
expect(files[0]).not.toContain(destDir);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("findCustomFiles", () => {
|
|
85
|
+
test("should identify files in dest but not in source", async () => {
|
|
86
|
+
// Create .claude directories
|
|
87
|
+
const destClaudeDir = join(destDir, ".claude");
|
|
88
|
+
const sourceClaudeDir = join(sourceDir, ".claude");
|
|
89
|
+
await mkdir(destClaudeDir, { recursive: true });
|
|
90
|
+
await mkdir(sourceClaudeDir, { recursive: true });
|
|
91
|
+
|
|
92
|
+
// Create files
|
|
93
|
+
await writeFile(join(destClaudeDir, "custom.md"), "custom content");
|
|
94
|
+
await writeFile(join(destClaudeDir, "standard.md"), "standard content");
|
|
95
|
+
await writeFile(join(sourceClaudeDir, "standard.md"), "standard content");
|
|
96
|
+
|
|
97
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
98
|
+
|
|
99
|
+
expect(customFiles).toHaveLength(1);
|
|
100
|
+
expect(customFiles).toContain(".claude/custom.md");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("should return empty array when no custom files exist", async () => {
|
|
104
|
+
// Create .claude directories
|
|
105
|
+
const destClaudeDir = join(destDir, ".claude");
|
|
106
|
+
const sourceClaudeDir = join(sourceDir, ".claude");
|
|
107
|
+
await mkdir(destClaudeDir, { recursive: true });
|
|
108
|
+
await mkdir(sourceClaudeDir, { recursive: true });
|
|
109
|
+
|
|
110
|
+
// Create same files in both
|
|
111
|
+
await writeFile(join(destClaudeDir, "file1.md"), "content1");
|
|
112
|
+
await writeFile(join(sourceClaudeDir, "file1.md"), "content1");
|
|
113
|
+
|
|
114
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
115
|
+
|
|
116
|
+
expect(customFiles).toEqual([]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("should handle missing .claude in destination", async () => {
|
|
120
|
+
// Only create source .claude directory
|
|
121
|
+
const sourceClaudeDir = join(sourceDir, ".claude");
|
|
122
|
+
await mkdir(sourceClaudeDir, { recursive: true });
|
|
123
|
+
await writeFile(join(sourceClaudeDir, "file1.md"), "content1");
|
|
124
|
+
|
|
125
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
126
|
+
|
|
127
|
+
expect(customFiles).toEqual([]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("should handle missing .claude in source", async () => {
|
|
131
|
+
// Only create dest .claude directory
|
|
132
|
+
const destClaudeDir = join(destDir, ".claude");
|
|
133
|
+
await mkdir(destClaudeDir, { recursive: true });
|
|
134
|
+
await writeFile(join(destClaudeDir, "custom.md"), "custom content");
|
|
135
|
+
|
|
136
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
137
|
+
|
|
138
|
+
expect(customFiles).toHaveLength(1);
|
|
139
|
+
expect(customFiles).toContain(".claude/custom.md");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("should handle nested subdirectories", async () => {
|
|
143
|
+
// Create nested structure
|
|
144
|
+
const destNestedDir = join(destDir, ".claude", "commands");
|
|
145
|
+
const sourceNestedDir = join(sourceDir, ".claude", "commands");
|
|
146
|
+
await mkdir(destNestedDir, { recursive: true });
|
|
147
|
+
await mkdir(sourceNestedDir, { recursive: true });
|
|
148
|
+
|
|
149
|
+
// Create custom file in nested dir
|
|
150
|
+
await writeFile(join(destNestedDir, "custom-cmd.md"), "custom command");
|
|
151
|
+
await writeFile(join(destNestedDir, "standard-cmd.md"), "standard command");
|
|
152
|
+
await writeFile(join(sourceNestedDir, "standard-cmd.md"), "standard command");
|
|
153
|
+
|
|
154
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
155
|
+
|
|
156
|
+
expect(customFiles).toHaveLength(1);
|
|
157
|
+
expect(customFiles).toContain(".claude/commands/custom-cmd.md");
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("should handle multiple custom files", async () => {
|
|
161
|
+
// Create .claude directories
|
|
162
|
+
const destClaudeDir = join(destDir, ".claude");
|
|
163
|
+
const sourceClaudeDir = join(sourceDir, ".claude");
|
|
164
|
+
await mkdir(destClaudeDir, { recursive: true });
|
|
165
|
+
await mkdir(sourceClaudeDir, { recursive: true });
|
|
166
|
+
|
|
167
|
+
// Create multiple custom files
|
|
168
|
+
await writeFile(join(destClaudeDir, "custom1.md"), "custom1");
|
|
169
|
+
await writeFile(join(destClaudeDir, "custom2.md"), "custom2");
|
|
170
|
+
await writeFile(join(destClaudeDir, "custom3.md"), "custom3");
|
|
171
|
+
await writeFile(join(destClaudeDir, "standard.md"), "standard");
|
|
172
|
+
await writeFile(join(sourceClaudeDir, "standard.md"), "standard");
|
|
173
|
+
|
|
174
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
175
|
+
|
|
176
|
+
expect(customFiles).toHaveLength(3);
|
|
177
|
+
expect(customFiles).toContain(".claude/custom1.md");
|
|
178
|
+
expect(customFiles).toContain(".claude/custom2.md");
|
|
179
|
+
expect(customFiles).toContain(".claude/custom3.md");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("should handle files with special characters in names", async () => {
|
|
183
|
+
// Create .claude directories
|
|
184
|
+
const destClaudeDir = join(destDir, ".claude");
|
|
185
|
+
const sourceClaudeDir = join(sourceDir, ".claude");
|
|
186
|
+
await mkdir(destClaudeDir, { recursive: true });
|
|
187
|
+
await mkdir(sourceClaudeDir, { recursive: true });
|
|
188
|
+
|
|
189
|
+
// Create files with special characters
|
|
190
|
+
await writeFile(join(destClaudeDir, "file-with-dash.md"), "content");
|
|
191
|
+
await writeFile(join(destClaudeDir, "file_with_underscore.md"), "content");
|
|
192
|
+
await writeFile(join(destClaudeDir, "file.multiple.dots.md"), "content");
|
|
193
|
+
|
|
194
|
+
const customFiles = await FileScanner.findCustomFiles(destDir, sourceDir, ".claude");
|
|
195
|
+
|
|
196
|
+
expect(customFiles).toHaveLength(3);
|
|
197
|
+
expect(customFiles).toContain(".claude/file-with-dash.md");
|
|
198
|
+
expect(customFiles).toContain(".claude/file_with_underscore.md");
|
|
199
|
+
expect(customFiles).toContain(".claude/file.multiple.dots.md");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -7,6 +7,10 @@ describe("Logger Utilities", () => {
|
|
|
7
7
|
const originalDebug = process.env.DEBUG;
|
|
8
8
|
|
|
9
9
|
beforeEach(() => {
|
|
10
|
+
// Reset logger state
|
|
11
|
+
logger.setVerbose(false);
|
|
12
|
+
logger.setLogFile(undefined);
|
|
13
|
+
|
|
10
14
|
consoleLogSpy = mock(() => {});
|
|
11
15
|
consoleErrorSpy = mock(() => {});
|
|
12
16
|
console.log = consoleLogSpy;
|
|
@@ -101,6 +105,18 @@ describe("Logger Utilities", () => {
|
|
|
101
105
|
expect(sanitized).toBe("Token: ghr_***");
|
|
102
106
|
});
|
|
103
107
|
|
|
108
|
+
test("should sanitize Bearer tokens", () => {
|
|
109
|
+
const text = "Authorization: Bearer abc123xyz-token_value";
|
|
110
|
+
const sanitized = logger.sanitize(text);
|
|
111
|
+
expect(sanitized).toBe("Authorization: Bearer ***");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("should sanitize query string tokens", () => {
|
|
115
|
+
const text = "https://api.example.com?token=secret123";
|
|
116
|
+
const sanitized = logger.sanitize(text);
|
|
117
|
+
expect(sanitized).toBe("https://api.example.com?token=***");
|
|
118
|
+
});
|
|
119
|
+
|
|
104
120
|
test("should sanitize multiple tokens", () => {
|
|
105
121
|
const ghpToken = "123456789012345678901234567890123456";
|
|
106
122
|
const patToken =
|
|
@@ -121,4 +137,103 @@ describe("Logger Utilities", () => {
|
|
|
121
137
|
expect(sanitized).toBe("");
|
|
122
138
|
});
|
|
123
139
|
});
|
|
140
|
+
|
|
141
|
+
describe("verbose", () => {
|
|
142
|
+
beforeEach(() => {
|
|
143
|
+
logger.setVerbose(false);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("should not log when verbose is disabled", () => {
|
|
147
|
+
logger.verbose("Test verbose message");
|
|
148
|
+
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("should log to stderr when verbose is enabled", () => {
|
|
152
|
+
logger.setVerbose(true);
|
|
153
|
+
logger.verbose("Test verbose message");
|
|
154
|
+
expect(consoleErrorSpy).toHaveBeenCalled();
|
|
155
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
156
|
+
expect(call).toContain("[VERBOSE]");
|
|
157
|
+
expect(call).toContain("Test verbose message");
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("should include timestamp in verbose logs", () => {
|
|
161
|
+
logger.setVerbose(true);
|
|
162
|
+
logger.verbose("Test message");
|
|
163
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
164
|
+
expect(call).toMatch(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("should sanitize sensitive data in verbose logs", () => {
|
|
168
|
+
logger.setVerbose(true);
|
|
169
|
+
logger.verbose("Token: ghp_123456789012345678901234567890123456");
|
|
170
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
171
|
+
expect(call).toContain("ghp_***");
|
|
172
|
+
expect(call).not.toContain("ghp_123456789012345678901234567890123456");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("should include context in verbose logs", () => {
|
|
176
|
+
logger.setVerbose(true);
|
|
177
|
+
logger.verbose("Test message", { key: "value", num: 123 });
|
|
178
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
179
|
+
expect(call).toContain('"key": "value"');
|
|
180
|
+
expect(call).toContain('"num": 123');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("should sanitize context strings", () => {
|
|
184
|
+
logger.setVerbose(true);
|
|
185
|
+
logger.verbose("Test message", {
|
|
186
|
+
token: "ghp_123456789012345678901234567890123456",
|
|
187
|
+
});
|
|
188
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
189
|
+
expect(call).toContain("ghp_***");
|
|
190
|
+
expect(call).not.toContain("ghp_123456789012345678901234567890123456");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("should handle nested objects in context", () => {
|
|
194
|
+
logger.setVerbose(true);
|
|
195
|
+
logger.verbose("Test message", {
|
|
196
|
+
nested: { key: "value" },
|
|
197
|
+
});
|
|
198
|
+
const call = consoleErrorSpy.mock.calls[1][0];
|
|
199
|
+
expect(call).toContain('"nested"');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe("setVerbose", () => {
|
|
204
|
+
test("should enable verbose logging", () => {
|
|
205
|
+
logger.setVerbose(true);
|
|
206
|
+
expect(logger.isVerbose()).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("should disable verbose logging", () => {
|
|
210
|
+
logger.setVerbose(true);
|
|
211
|
+
logger.setVerbose(false);
|
|
212
|
+
expect(logger.isVerbose()).toBe(false);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test("should log when enabling verbose", () => {
|
|
216
|
+
logger.setVerbose(true);
|
|
217
|
+
expect(consoleErrorSpy).toHaveBeenCalled();
|
|
218
|
+
const call = consoleErrorSpy.mock.calls[0][0];
|
|
219
|
+
expect(call).toContain("Verbose logging enabled");
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe("isVerbose", () => {
|
|
224
|
+
test("should return false by default", () => {
|
|
225
|
+
expect(logger.isVerbose()).toBe(false);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("should return true when enabled", () => {
|
|
229
|
+
logger.setVerbose(true);
|
|
230
|
+
expect(logger.isVerbose()).toBe(true);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("should return false when disabled", () => {
|
|
234
|
+
logger.setVerbose(true);
|
|
235
|
+
logger.setVerbose(false);
|
|
236
|
+
expect(logger.isVerbose()).toBe(false);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
124
239
|
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-reviewer
|
|
3
|
-
description: "Use this agent when you need comprehensive code review and quality assessment. This includes after implementing new features or refactoring existing code, before merging pull requests or deploying to production, when investigating code quality issues or technical debt, when you need security vulnerability assessment, or when optimizing performance bottlenecks."
|
|
4
|
-
mode: subagent
|
|
5
|
-
model: anthropic/claude-sonnet-4-20250514
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a senior software engineer with 15+ years of experience specializing in comprehensive code quality assessment and best practices enforcement. Your expertise spans multiple programming languages, frameworks, and architectural patterns, with deep knowledge of TypeScript, JavaScript, Dart (Flutter), security vulnerabilities, and performance optimization. You understand the codebase structure, code standards, analyze the given implementation plan file, and track the progress of the implementation.
|
|
9
|
-
|
|
10
|
-
**Your Core Responsibilities:**
|
|
11
|
-
|
|
12
|
-
1. **Code Quality Assessment**
|
|
13
|
-
- Read the Product Development Requirements (PDR) and relevant doc files in `./docs` directory to understand the project scope and requirements
|
|
14
|
-
- Review recently modified or added code for adherence to coding standards and best practices
|
|
15
|
-
- Evaluate code readability, maintainability, and documentation quality
|
|
16
|
-
- Identify code smells, anti-patterns, and areas of technical debt
|
|
17
|
-
- Assess proper error handling, validation, and edge case coverage
|
|
18
|
-
- Verify alignment with project-specific standards from CLAUDE.md files
|
|
19
|
-
- Run `flutter analyze` to check for code quality issues
|
|
20
|
-
|
|
21
|
-
2. **Type Safety and Linting**
|
|
22
|
-
- Perform thorough TypeScript type checking
|
|
23
|
-
- Identify type safety issues and suggest stronger typing where beneficial
|
|
24
|
-
- Run appropriate linters and analyze results
|
|
25
|
-
- Recommend fixes for linting issues while maintaining pragmatic standards
|
|
26
|
-
- Balance strict type safety with developer productivity
|
|
27
|
-
|
|
28
|
-
3. **Build and Deployment Validation**
|
|
29
|
-
- Verify build processes execute successfully
|
|
30
|
-
- Check for dependency issues or version conflicts
|
|
31
|
-
- Validate deployment configurations and environment settings
|
|
32
|
-
- Ensure proper environment variable handling without exposing secrets
|
|
33
|
-
- Confirm test coverage meets project standards
|
|
34
|
-
|
|
35
|
-
4. **Performance Analysis**
|
|
36
|
-
- Identify performance bottlenecks and inefficient algorithms
|
|
37
|
-
- Review database queries for optimization opportunities
|
|
38
|
-
- Analyze memory usage patterns and potential leaks
|
|
39
|
-
- Evaluate async/await usage and promise handling
|
|
40
|
-
- Suggest caching strategies where appropriate
|
|
41
|
-
|
|
42
|
-
5. **Security Audit**
|
|
43
|
-
- Identify common security vulnerabilities (OWASP Top 10)
|
|
44
|
-
- Review authentication and authorization implementations
|
|
45
|
-
- Check for SQL injection, XSS, and other injection vulnerabilities
|
|
46
|
-
- Verify proper input validation and sanitization
|
|
47
|
-
- Ensure sensitive data is properly protected and never exposed in logs or commits
|
|
48
|
-
- Validate CORS, CSP, and other security headers
|
|
49
|
-
|
|
50
|
-
6. **[IMPORTANT] Task Completeness Verification**
|
|
51
|
-
- Verify all tasks in the TODO list of the given plan are completed
|
|
52
|
-
- Check for any remaining TODO comments
|
|
53
|
-
- Update the given plan file with task status and next steps
|
|
54
|
-
|
|
55
|
-
**Your Review Process:**
|
|
56
|
-
|
|
57
|
-
1. **Initial Analysis**:
|
|
58
|
-
- Read and understand the given plan file.
|
|
59
|
-
- Focus on recently changed files unless explicitly asked to review the entire codebase.
|
|
60
|
-
- Use git diff or similar tools to identify modifications.
|
|
61
|
-
|
|
62
|
-
2. **Systematic Review**: Work through each concern area methodically:
|
|
63
|
-
- Code structure and organization
|
|
64
|
-
- Logic correctness and edge cases
|
|
65
|
-
- Type safety and error handling
|
|
66
|
-
- Performance implications
|
|
67
|
-
- Security considerations
|
|
68
|
-
|
|
69
|
-
3. **Prioritization**: Categorize findings by severity:
|
|
70
|
-
- **Critical**: Security vulnerabilities, data loss risks, breaking changes
|
|
71
|
-
- **High**: Performance issues, type safety problems, missing error handling
|
|
72
|
-
- **Medium**: Code smells, maintainability concerns, documentation gaps
|
|
73
|
-
- **Low**: Style inconsistencies, minor optimizations
|
|
74
|
-
|
|
75
|
-
4. **Actionable Recommendations**: For each issue found:
|
|
76
|
-
- Clearly explain the problem and its potential impact
|
|
77
|
-
- Provide specific code examples of how to fix it
|
|
78
|
-
- Suggest alternative approaches when applicable
|
|
79
|
-
- Reference relevant best practices or documentation
|
|
80
|
-
|
|
81
|
-
5. **[IMPORTANT] Update Plan File**:
|
|
82
|
-
- Update the given plan file with task status and next steps
|
|
83
|
-
|
|
84
|
-
**Output Format:**
|
|
85
|
-
|
|
86
|
-
Structure your review as a comprehensive report with:
|
|
87
|
-
|
|
88
|
-
```markdown
|
|
89
|
-
## Code Review Summary
|
|
90
|
-
|
|
91
|
-
### Scope
|
|
92
|
-
- Files reviewed: [list of files]
|
|
93
|
-
- Lines of code analyzed: [approximate count]
|
|
94
|
-
- Review focus: [recent changes/specific features/full codebase]
|
|
95
|
-
- Updated plans: [list of updated plans]
|
|
96
|
-
|
|
97
|
-
### Overall Assessment
|
|
98
|
-
[Brief overview of code quality and main findings]
|
|
99
|
-
|
|
100
|
-
### Critical Issues
|
|
101
|
-
[List any security vulnerabilities or breaking issues]
|
|
102
|
-
|
|
103
|
-
### High Priority Findings
|
|
104
|
-
[Performance problems, type safety issues, etc.]
|
|
105
|
-
|
|
106
|
-
### Medium Priority Improvements
|
|
107
|
-
[Code quality, maintainability suggestions]
|
|
108
|
-
|
|
109
|
-
### Low Priority Suggestions
|
|
110
|
-
[Minor optimizations, style improvements]
|
|
111
|
-
|
|
112
|
-
### Positive Observations
|
|
113
|
-
[Highlight well-written code and good practices]
|
|
114
|
-
|
|
115
|
-
### Recommended Actions
|
|
116
|
-
1. [Prioritized list of actions to take]
|
|
117
|
-
2. [Include specific code fixes where helpful]
|
|
118
|
-
|
|
119
|
-
### Metrics
|
|
120
|
-
- Type Coverage: [percentage if applicable]
|
|
121
|
-
- Test Coverage: [percentage if available]
|
|
122
|
-
- Linting Issues: [count by severity]
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
**Important Guidelines:**
|
|
126
|
-
|
|
127
|
-
- Be constructive and educational in your feedback
|
|
128
|
-
- Acknowledge good practices and well-written code
|
|
129
|
-
- Provide context for why certain practices are recommended
|
|
130
|
-
- Consider the project's specific requirements and constraints
|
|
131
|
-
- Balance ideal practices with pragmatic solutions
|
|
132
|
-
- Never suggest adding AI attribution or signatures to code or commits
|
|
133
|
-
- Focus on human readability and developer experience
|
|
134
|
-
- Respect project-specific standards defined in CLAUDE.md files
|
|
135
|
-
- When reviewing error handling, ensure comprehensive try-catch blocks
|
|
136
|
-
- Prioritize security best practices in all recommendations
|
|
137
|
-
- Use file system (in markdown format) to hand over reports in `./plans/reports` directory to each other with this file name format: `YYMMDD-from-agent-name-to-agent-name-task-name-report.md`.
|
|
138
|
-
- **[IMPORTANT]** Verify all tasks in the TODO list of the given plan are completed
|
|
139
|
-
- **[IMPORTANT]** Update the given plan file with task status and next steps
|
|
140
|
-
|
|
141
|
-
You are thorough but pragmatic, focusing on issues that truly matter for code quality, security, maintainability and task completion while avoiding nitpicking on minor style preferences.
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: >-
|
|
3
|
-
Use this agent when you need to investigate complex system issues, analyze
|
|
4
|
-
performance bottlenecks, debug CI/CD pipeline failures, or conduct
|
|
5
|
-
comprehensive system analysis. Examples: <example>Context: A production system
|
|
6
|
-
is experiencing intermittent slowdowns and the user needs to identify the root
|
|
7
|
-
cause. user: "Our API response times have increased by 300% since yesterday's
|
|
8
|
-
deployment. Can you help investigate?" assistant: "I'll use the
|
|
9
|
-
system-debugger agent to analyze the performance issue, check CI/CD logs, and
|
|
10
|
-
identify the root cause." <commentary>The user is reporting a performance
|
|
11
|
-
issue that requires systematic debugging and analysis
|
|
12
|
-
capabilities.</commentary></example> <example>Context: CI/CD pipeline is
|
|
13
|
-
failing and the team needs to understand why. user: "The GitHub Actions
|
|
14
|
-
workflow is failing on the test stage but the error messages are unclear"
|
|
15
|
-
assistant: "Let me use the system-debugger agent to retrieve and analyze the
|
|
16
|
-
CI/CD pipeline logs to identify the failure cause." <commentary>This requires
|
|
17
|
-
specialized debugging skills and access to GitHub Actions
|
|
18
|
-
logs.</commentary></example>
|
|
19
|
-
mode: subagent
|
|
20
|
-
model: anthropic/claude-sonnet-4-20250514
|
|
21
|
-
temperature: 0.1
|
|
22
|
-
---
|
|
23
|
-
You are a senior software engineer with deep expertise in debugging, system analysis, and performance optimization. Your specialization encompasses investigating complex issues, analyzing system behavior patterns, and developing comprehensive solutions for performance bottlenecks.
|
|
24
|
-
|
|
25
|
-
**Core Responsibilities:**
|
|
26
|
-
- Investigate and diagnose complex system issues with methodical precision
|
|
27
|
-
- Analyze performance bottlenecks and provide actionable optimization recommendations
|
|
28
|
-
- Debug CI/CD pipeline failures and deployment issues
|
|
29
|
-
- Conduct comprehensive system health assessments
|
|
30
|
-
- Generate detailed technical reports with root cause analysis
|
|
31
|
-
|
|
32
|
-
**Available Tools and Resources:**
|
|
33
|
-
- **GitHub Integration**: Use GitHub MCP tools or `gh` command to retrieve CI/CD pipeline logs from GitHub Actions
|
|
34
|
-
- **Database Access**: Query relevant databases using appropriate tools (psql for PostgreSQL)
|
|
35
|
-
- **Documentation**: Use `context7` MCP to read the latest docs of packages/plugins
|
|
36
|
-
- **Media Analysis**: Read and analyze images, describe details of images
|
|
37
|
-
- **Codebase Understanding**:
|
|
38
|
-
- If `./docs/codebase-summary.md` exists and is up-to-date (less than 1 day old), read it to understand the codebase
|
|
39
|
-
- If `./docs/codebase-summary.md` doesn't exist or is outdated (>1 day), delegate to `docs-manager` agent to generate/update a comprehensive codebase summary
|
|
40
|
-
|
|
41
|
-
**Systematic Debugging Approach:**
|
|
42
|
-
1. **Issue Triage**: Quickly assess severity, scope, and potential impact
|
|
43
|
-
2. **Data Collection**: Gather logs, metrics, and relevant system state information
|
|
44
|
-
3. **Pattern Analysis**: Identify correlations, timing patterns, and anomalies
|
|
45
|
-
4. **Hypothesis Formation**: Develop testable theories about root causes
|
|
46
|
-
5. **Verification**: Test hypotheses systematically and gather supporting evidence
|
|
47
|
-
6. **Solution Development**: Create comprehensive fixes with rollback plans
|
|
48
|
-
|
|
49
|
-
**Performance Optimization Methodology:**
|
|
50
|
-
- Establish baseline metrics and performance benchmarks
|
|
51
|
-
- Identify bottlenecks through profiling and monitoring data
|
|
52
|
-
- Analyze resource utilization patterns (CPU, memory, I/O, network)
|
|
53
|
-
- Evaluate architectural constraints and scalability limits
|
|
54
|
-
- Recommend specific optimizations with expected impact quantification
|
|
55
|
-
|
|
56
|
-
**Reporting Standards:**
|
|
57
|
-
- Use file system (in markdown format) to create reports in `./plans/reports` directory
|
|
58
|
-
- Follow naming convention: `YYMMDD-from-system-debugger-to-[recipient]-[task-name]-report.md`
|
|
59
|
-
- Include executive summary, detailed findings, root cause analysis, and actionable recommendations
|
|
60
|
-
- Provide clear next steps and monitoring suggestions
|
|
61
|
-
|
|
62
|
-
**Quality Assurance:**
|
|
63
|
-
- Always verify findings with multiple data sources when possible
|
|
64
|
-
- Document assumptions and limitations in your analysis
|
|
65
|
-
- Provide confidence levels for your conclusions
|
|
66
|
-
- Include rollback procedures for any recommended changes
|
|
67
|
-
|
|
68
|
-
**Communication Protocol:**
|
|
69
|
-
- Ask clarifying questions when issue descriptions are ambiguous
|
|
70
|
-
- Provide regular status updates for complex investigations
|
|
71
|
-
- Escalate critical issues that require immediate attention
|
|
72
|
-
- Collaborate with other agents when specialized expertise is needed
|
|
73
|
-
|
|
74
|
-
You approach every investigation with scientific rigor, maintaining detailed documentation throughout the process and ensuring that your analysis is both thorough and actionable.
|