Skip to content

Commit ae2e00e

Browse files
authored
feat: integrate warden for automated code review (#6)
Add warden.toml with code-simplifier (getsentry/skills) and find-bugs (getsentry/warden) triggers. Update validate skill to run warden -v after tests pass. Address warden findings: extract shared exercise parsing helper and add schema validation in updateTemplate.
1 parent 889bade commit ae2e00e

File tree

4 files changed

+60
-36
lines changed

4 files changed

+60
-36
lines changed

.claude/skills/validate.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
---
2-
description: Run full validation (lint, format, typecheck, tests, build). Use before committing or after changes.
2+
description: Run full validation (lint, format, typecheck, tests, build) and warden code review. Use before committing or after changes.
33
---
44

55
# Validate
66

7-
Run the full validation suite to ensure code quality.
7+
Run the full validation suite and code review to ensure code quality.
88

9-
## Command
9+
## Steps
1010

11-
```bash
12-
bun run validate
13-
```
11+
1. Run the validation suite:
12+
```bash
13+
bun run validate
14+
```
15+
This runs:
16+
- `oxlint` - Linting with type-aware rules
17+
- `oxfmt --check` - Format verification
18+
- `tsc --noEmit` - Type checking
19+
- `vitest run` - Unit tests
20+
- `tsc` - Build
1421

15-
This runs:
16-
1. `oxlint` - Linting with type-aware rules
17-
2. `oxfmt --check` - Format verification
18-
3. `tsc --noEmit` - Type checking
19-
4. `vitest run` - Unit tests
20-
5. `tsc` - Build
22+
2. If validation passes, run warden for code review feedback:
23+
```bash
24+
warden -v
25+
```
26+
The `-v` flag streams findings in real-time (code simplification, bug detection).
27+
Fix any issues warden finds before proceeding.
2128

2229
## When to Use
2330

@@ -27,4 +34,4 @@ This runs:
2734

2835
## Expected Output
2936

30-
All checks should pass with no errors. If any step fails, fix the issues before proceeding.
37+
All checks should pass with no errors. Warden findings should be addressed before proceeding.

src/commands/templates.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function parseExerciseSpec(spec: string): TemplateExercise {
2323
};
2424
}
2525

26+
function parseExerciseSpecs(input: string): TemplateExercise[] {
27+
return input.split(',').map((s) => parseExerciseSpec(s.trim()));
28+
}
29+
2630
export function createTemplatesCommand(getProfile: () => string | undefined): Command {
2731
const templates = new Command('templates').description('Manage workout templates');
2832

@@ -100,16 +104,12 @@ export function createTemplatesCommand(getProfile: () => string | undefined): Co
100104
const storage = getStorage(getProfile());
101105
const id = options.id ?? slugify(name);
102106

103-
const exerciseSpecs = options.exercises.split(',').map((s) => s.trim());
104-
const exercises: TemplateExercise[] = [];
105-
106-
for (const spec of exerciseSpecs) {
107-
try {
108-
exercises.push(parseExerciseSpec(spec));
109-
} catch (err) {
110-
console.error((err as Error).message);
111-
process.exit(1);
112-
}
107+
let exercises: TemplateExercise[];
108+
try {
109+
exercises = parseExerciseSpecs(options.exercises);
110+
} catch (err) {
111+
console.error((err as Error).message);
112+
process.exit(1);
113113
}
114114

115115
const template = Template.parse({
@@ -166,19 +166,12 @@ export function createTemplatesCommand(getProfile: () => string | undefined): Co
166166
}
167167

168168
if (options.exercises) {
169-
const exerciseSpecs = options.exercises.split(',').map((s) => s.trim());
170-
const exercises: TemplateExercise[] = [];
171-
172-
for (const spec of exerciseSpecs) {
173-
try {
174-
exercises.push(parseExerciseSpec(spec));
175-
} catch (err) {
176-
console.error((err as Error).message);
177-
process.exit(1);
178-
}
169+
try {
170+
updates.exercises = parseExerciseSpecs(options.exercises);
171+
} catch (err) {
172+
console.error((err as Error).message);
173+
process.exit(1);
179174
}
180-
181-
updates.exercises = exercises;
182175
}
183176

184177
if (Object.keys(updates).length === 0) {

src/data/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class Storage {
165165
if (index === -1) {
166166
throw new Error(`Template "${id}" not found`);
167167
}
168-
templates[index] = { ...templates[index]!, ...updates };
168+
templates[index] = Template.parse({ ...templates[index]!, ...updates });
169169
this.saveTemplates(templates);
170170
}
171171

warden.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version = 1
2+
3+
[defaults.filters]
4+
ignorePaths = ["**/*.md", "**/*.lock", "**/*.json"]
5+
6+
[[triggers]]
7+
name = "code-simplifier"
8+
event = "pull_request"
9+
actions = ["opened", "synchronize", "reopened"]
10+
skill = "code-simplifier"
11+
remote = "getsentry/skills"
12+
13+
[triggers.filters]
14+
paths = ["src/**", "test/**"]
15+
16+
[[triggers]]
17+
name = "find-bugs"
18+
event = "pull_request"
19+
actions = ["opened", "synchronize", "reopened"]
20+
skill = "find-bugs"
21+
remote = "getsentry/warden"
22+
23+
[triggers.filters]
24+
paths = ["src/**"]

0 commit comments

Comments
 (0)