claude-toolkit 0.1.9
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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/bin/cli.ts +112 -0
- package/core/agents/ct-code-reviewer.md +123 -0
- package/core/agents/ct-github-workflow.md +137 -0
- package/core/commands/ct/code-quality.md +59 -0
- package/core/commands/ct/onboard.md +84 -0
- package/core/commands/ct/pr-review.md +104 -0
- package/core/commands/ct/pr-summary.md +59 -0
- package/core/commands/ct/proto-check.md +74 -0
- package/core/commands/ct/ticket.md +71 -0
- package/core/hooks/skill-eval.js +381 -0
- package/core/hooks/skill-eval.sh +35 -0
- package/core/hooks/skill-rules.schema.json +112 -0
- package/core/skills/systematic-debugging/SKILL.md +44 -0
- package/core/skills/testing-patterns/SKILL.md +52 -0
- package/core/skills/typescript-conventions/SKILL.md +57 -0
- package/core/skills/verification-before-completion/SKILL.md +42 -0
- package/docs/README.md +49 -0
- package/docs/agents/code-reviewer.md +76 -0
- package/docs/agents/github-workflow.md +98 -0
- package/docs/best-practices/solidjs/README.md +43 -0
- package/docs/best-practices/solidjs/anti-patterns.md +166 -0
- package/docs/best-practices/solidjs/component-patterns.md +131 -0
- package/docs/best-practices/solidjs/context-and-global-state.md +131 -0
- package/docs/best-practices/solidjs/control-flow.md +124 -0
- package/docs/best-practices/solidjs/data-fetching.md +205 -0
- package/docs/best-practices/solidjs/effects-and-lifecycle.md +113 -0
- package/docs/best-practices/solidjs/performance.md +100 -0
- package/docs/best-practices/solidjs/props-patterns.md +100 -0
- package/docs/best-practices/solidjs/reactivity-model.md +104 -0
- package/docs/best-practices/solidjs/signals-and-state.md +78 -0
- package/docs/best-practices/solidjs/stores-and-nested-state.md +111 -0
- package/docs/best-practices/solidjs/typescript-integration.md +186 -0
- package/docs/best-practices/typescript/README.md +45 -0
- package/docs/best-practices/typescript/any-and-unknown.md +73 -0
- package/docs/best-practices/typescript/deriving-vs-decoupling.md +83 -0
- package/docs/best-practices/typescript/discriminated-unions.md +75 -0
- package/docs/best-practices/typescript/enums-alternatives.md +72 -0
- package/docs/best-practices/typescript/essential-patterns.md +119 -0
- package/docs/best-practices/typescript/generics-patterns.md +105 -0
- package/docs/best-practices/typescript/micro-opinions.md +87 -0
- package/docs/best-practices/typescript/runtime-validation.md +62 -0
- package/docs/best-practices/typescript/satisfies-operator.md +100 -0
- package/docs/best-practices/typescript/tsconfig-cheat-sheet.md +129 -0
- package/docs/best-practices/typescript/type-organization.md +64 -0
- package/docs/best-practices/typescript/type-vs-interface.md +80 -0
- package/docs/commands/code-quality.md +42 -0
- package/docs/commands/onboard.md +72 -0
- package/docs/commands/pr-review.md +102 -0
- package/docs/commands/pr-summary.md +50 -0
- package/docs/commands/proto-check.md +59 -0
- package/docs/commands/ticket.md +56 -0
- package/docs/skills/systematic-debugging.md +70 -0
- package/docs/skills/testing-patterns.md +89 -0
- package/docs/skills/typescript-conventions.md +137 -0
- package/docs/skills/verification-before-completion.md +91 -0
- package/docs/stacks/cloudflare-d1-kv.md +110 -0
- package/docs/stacks/i18n-typesafe.md +141 -0
- package/docs/stacks/protobuf-contracts.md +85 -0
- package/docs/stacks/rust-wasm-patterns.md +106 -0
- package/docs/stacks/solidjs-patterns.md +110 -0
- package/docs/stacks/vanilla-extract-patterns.md +115 -0
- package/package.json +58 -0
- package/src/generator.ts +317 -0
- package/src/index.ts +30 -0
- package/src/types.ts +85 -0
- package/src/utils.ts +53 -0
- package/stacks/cloudflare/skills/cloudflare-d1-kv/SKILL.md +84 -0
- package/stacks/cloudflare/stack.json +26 -0
- package/stacks/i18n-typesafe/skills/i18n-typesafe/SKILL.md +64 -0
- package/stacks/i18n-typesafe/stack.json +25 -0
- package/stacks/protobuf/skills/protobuf-contracts/SKILL.md +78 -0
- package/stacks/protobuf/stack.json +25 -0
- package/stacks/rust-wasm/skills/rust-wasm-patterns/SKILL.md +76 -0
- package/stacks/rust-wasm/stack.json +26 -0
- package/stacks/solidjs/skills/solidjs-patterns/SKILL.md +66 -0
- package/stacks/solidjs/stack.json +52 -0
- package/stacks/vanilla-extract/skills/vanilla-extract-patterns/SKILL.md +76 -0
- package/stacks/vanilla-extract/stack.json +40 -0
- package/templates/claude-toolkit.config.ts +34 -0
- package/templates/configs/biome.base.json +35 -0
- package/templates/configs/tsconfig.base.json +16 -0
- package/templates/skill-rules.base.json +98 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Type vs Interface
|
|
2
|
+
|
|
3
|
+
> Source: [Type vs Interface: Which Should You Use?](https://www.totaltypescript.com/type-vs-interface-which-should-you-use) — Matt Pocock
|
|
4
|
+
|
|
5
|
+
## The Verdict
|
|
6
|
+
|
|
7
|
+
**Default to `type`. Use `interface` only when you need `extends`.**
|
|
8
|
+
|
|
9
|
+
This contradicts the official TypeScript team guidance (which defaults to `interface`), but Matt argues the tradeoffs favor `type` for most codebases.
|
|
10
|
+
|
|
11
|
+
## Why Default to `type`
|
|
12
|
+
|
|
13
|
+
### 1. Flexibility
|
|
14
|
+
|
|
15
|
+
Type aliases can express unions, mapped types, and conditional types. Interfaces cannot.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Only possible with type
|
|
19
|
+
type Result = Success | Failure;
|
|
20
|
+
type Mapped = { [K in keyof T]: boolean };
|
|
21
|
+
type Conditional = T extends string ? "yes" : "no";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Declaration Merging is Dangerous
|
|
25
|
+
|
|
26
|
+
If you accidentally declare the same interface name twice in the same scope, TypeScript silently merges them — no error, no warning. You end up with a type that has extra properties you never intended.
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
interface User {
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface User {
|
|
34
|
+
age: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// User is now { name: string; age: number } — silently merged
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
With `type`, a duplicate name throws a compile error immediately.
|
|
41
|
+
|
|
42
|
+
### 3. Implicit Index Signature
|
|
43
|
+
|
|
44
|
+
Type aliases have an implicit index signature, making them assignable to `Record<PropertyKey, unknown>`. Interfaces do not, which causes unexpected errors when passing interface-typed objects to functions expecting `Record` types.
|
|
45
|
+
|
|
46
|
+
## When to Use `interface`
|
|
47
|
+
|
|
48
|
+
Use `interface` specifically for **object inheritance** with `extends`:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
interface Animal {
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface Dog extends Animal {
|
|
56
|
+
breed: string;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Why?** `extends` makes TypeScript's type checker run slightly faster than `&` intersections. TypeScript caches interface relationships in an internal registry, optimizing repeated type checks.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Prefer this (faster)
|
|
64
|
+
interface Dog extends Animal {
|
|
65
|
+
breed: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Over this (slower)
|
|
69
|
+
type Dog = Animal & {
|
|
70
|
+
breed: string;
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Summary
|
|
75
|
+
|
|
76
|
+
| Scenario | Use |
|
|
77
|
+
|---|---|
|
|
78
|
+
| Object shapes (no inheritance) | `type` |
|
|
79
|
+
| Unions, mapped types, conditionals | `type` |
|
|
80
|
+
| Object inheritance | `interface` with `extends` |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# /code-quality
|
|
2
|
+
|
|
3
|
+
> Run code quality checks (lint, typecheck, format) on a directory or file.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/code-quality.md`](../core/commands/ct/code-quality.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read, Glob, Grep
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/code-quality [path]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
1. **Detect project tooling** -- reads `package.json`, `pyproject.toml`, `Makefile`, `Cargo.toml`, or equivalent to identify the linter, typechecker, and formatter configured in the project
|
|
18
|
+
2. **Run linting** -- uses the project-configured linter (e.g., `eslint`, `ruff`, `clippy`, `golangci-lint`)
|
|
19
|
+
3. **Run type checking** -- uses the project-configured typechecker (e.g., `tsc --noEmit`, `mypy`, `pyright`)
|
|
20
|
+
4. **Run format checking** -- uses the project-configured formatter in check mode (e.g., `prettier --check`, `black --check`, `rustfmt --check`)
|
|
21
|
+
5. **Compile results** -- produces a structured report
|
|
22
|
+
|
|
23
|
+
## Output Format
|
|
24
|
+
|
|
25
|
+
The command produces a structured report with:
|
|
26
|
+
|
|
27
|
+
- **Lint Issues** -- table with file, line, rule, message, and severity
|
|
28
|
+
- **Type Errors** -- table with file, line, and message
|
|
29
|
+
- **Format Issues** -- table with file and status
|
|
30
|
+
- **Summary** -- total issues across files with actionable suggestions
|
|
31
|
+
|
|
32
|
+
## Best Practices Reference
|
|
33
|
+
|
|
34
|
+
| Topic | Guide |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| Recommended `tsconfig.json` settings | [TSConfig Cheat Sheet](../best-practices/typescript/tsconfig-cheat-sheet.md) |
|
|
37
|
+
|
|
38
|
+
## Notes
|
|
39
|
+
|
|
40
|
+
- Always uses the project's own configuration; does not impose external rules
|
|
41
|
+
- For monorepos, scopes checks to the target directory rather than the entire repo
|
|
42
|
+
- If a tool is not configured, it is noted and skipped
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# /onboard
|
|
2
|
+
|
|
3
|
+
> Systematically explore and understand a codebase area, module, or task context.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/onboard.md`](../core/commands/ct/onboard.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read, Glob, Grep
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/onboard [area]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If no area is specified, starts from the project root.
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
1. **Understand the scope** -- the user specifies an area (e.g., "the auth module", "the payments flow") or the entire repo
|
|
20
|
+
2. **Read foundational files** -- `README.md`, `CLAUDE.md`, `CONTRIBUTING.md`, `package.json`, config files, entry points
|
|
21
|
+
3. **Map the architecture** -- directory structure, entry points, request/data flow, key abstractions, design patterns
|
|
22
|
+
4. **Identify conventions** -- naming, error handling, testing patterns, state management
|
|
23
|
+
5. **Understand dependencies** -- key external libraries, internal module boundaries, database schema
|
|
24
|
+
6. **Ask clarifying questions** if ambiguities or undocumented conventions exist
|
|
25
|
+
|
|
26
|
+
## Output Format
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
## Onboarding Summary: {area}
|
|
30
|
+
|
|
31
|
+
### Tech Stack
|
|
32
|
+
- **Language:** {language and version}
|
|
33
|
+
- **Framework:** {framework}
|
|
34
|
+
- **Key libraries:** {list with purpose}
|
|
35
|
+
- **Database:** {if applicable}
|
|
36
|
+
|
|
37
|
+
### Architecture
|
|
38
|
+
{2-4 sentences describing the overall structure}
|
|
39
|
+
|
|
40
|
+
### Directory Map
|
|
41
|
+
- `src/` - {purpose}
|
|
42
|
+
- `src/models/` - {purpose}
|
|
43
|
+
|
|
44
|
+
### Key Files
|
|
45
|
+
| File | Purpose | Notes |
|
|
46
|
+
|
|
47
|
+
### Data Flow
|
|
48
|
+
{How a request/action flows through the system}
|
|
49
|
+
|
|
50
|
+
### Conventions
|
|
51
|
+
- **Naming:** {patterns observed}
|
|
52
|
+
- **Error handling:** {approach}
|
|
53
|
+
- **Testing:** {framework, patterns, location}
|
|
54
|
+
|
|
55
|
+
### Questions / Gaps
|
|
56
|
+
- {Things that are unclear or undocumented}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Best Practices Reference
|
|
60
|
+
|
|
61
|
+
Conventions to look for during onboarding:
|
|
62
|
+
|
|
63
|
+
| Topic | Guide |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| TypeScript conventions and patterns | [TypeScript Best Practices](../best-practices/typescript/README.md) |
|
|
66
|
+
| SolidJS conventions and patterns | [SolidJS Best Practices](../best-practices/solidjs/README.md) |
|
|
67
|
+
|
|
68
|
+
## Notes
|
|
69
|
+
|
|
70
|
+
- Prioritizes understanding over completeness -- deeply understand 5 key files rather than skim 50
|
|
71
|
+
- Notes what is NOT there (missing tests, docs, error handling) as well as what is
|
|
72
|
+
- If onboarding for a specific task, focuses exploration on the relevant areas
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# /pr-review
|
|
2
|
+
|
|
3
|
+
> Perform a checklist-based code review on the current PR or a specified PR number.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/pr-review.md`](../core/commands/ct/pr-review.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read, Glob, Grep
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/pr-review [pr-number]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If no PR number is provided, diffs the current branch against the base branch.
|
|
16
|
+
|
|
17
|
+
## Review Checklist
|
|
18
|
+
|
|
19
|
+
The command evaluates all changed files against these criteria:
|
|
20
|
+
|
|
21
|
+
### Logic Correctness
|
|
22
|
+
|
|
23
|
+
- Conditionals and branches correct, no off-by-one errors
|
|
24
|
+
- Edge cases handled (empty inputs, null values, boundary conditions)
|
|
25
|
+
- Control flow matches intended behavior
|
|
26
|
+
- No unreachable code paths
|
|
27
|
+
|
|
28
|
+
### Type Safety
|
|
29
|
+
|
|
30
|
+
- Precise types (no `any`, no unsafe casts, no overly broad unions)
|
|
31
|
+
- Type narrowing used correctly before accessing properties
|
|
32
|
+
- Generic constraints appropriate
|
|
33
|
+
- Return types explicit where needed
|
|
34
|
+
|
|
35
|
+
### Error Handling
|
|
36
|
+
|
|
37
|
+
- Errors caught and handled meaningfully (not swallowed)
|
|
38
|
+
- Error messages provide enough context for debugging
|
|
39
|
+
- Error boundaries or fallbacks in place where needed
|
|
40
|
+
- Cleanup logic (finally blocks, defer) correct
|
|
41
|
+
|
|
42
|
+
### Test Coverage
|
|
43
|
+
|
|
44
|
+
- New behaviors covered by tests
|
|
45
|
+
- Tests focus on behavior, not implementation details
|
|
46
|
+
- Edge cases and error paths tested
|
|
47
|
+
- Test descriptions clear and descriptive
|
|
48
|
+
|
|
49
|
+
### Performance
|
|
50
|
+
|
|
51
|
+
- No unnecessary re-renders, recomputations, or allocations
|
|
52
|
+
- No N+1 query patterns or missing pagination
|
|
53
|
+
- No missing memoization for expensive operations
|
|
54
|
+
- No potential memory leaks
|
|
55
|
+
|
|
56
|
+
### Security
|
|
57
|
+
|
|
58
|
+
- No injection vulnerabilities (SQL, XSS, command injection)
|
|
59
|
+
- User inputs validated and sanitized
|
|
60
|
+
- Auth checks present on protected operations
|
|
61
|
+
- Secrets and sensitive data properly handled
|
|
62
|
+
|
|
63
|
+
### Code Style
|
|
64
|
+
|
|
65
|
+
- Naming follows project conventions
|
|
66
|
+
- Code readable without excessive comments
|
|
67
|
+
- Abstractions at the right level
|
|
68
|
+
- No unnecessary duplication
|
|
69
|
+
|
|
70
|
+
## Output Format
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
## PR Review: {title}
|
|
74
|
+
|
|
75
|
+
**Branch:** {branch} -> {base}
|
|
76
|
+
**Files changed:** {count}
|
|
77
|
+
**Verdict:** APPROVE | REQUEST_CHANGES | COMMENT
|
|
78
|
+
|
|
79
|
+
### Critical Issues
|
|
80
|
+
### Warnings
|
|
81
|
+
### Suggestions
|
|
82
|
+
### Positive Notes
|
|
83
|
+
### Summary
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Best Practices Reference
|
|
87
|
+
|
|
88
|
+
Review criteria informed by these guides:
|
|
89
|
+
|
|
90
|
+
| Review Area | Guide |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| Type safety: `any` usage, unsafe casts | [any & unknown](../best-practices/typescript/any-and-unknown.md) |
|
|
93
|
+
| State modeling with unions | [Discriminated Unions](../best-practices/typescript/discriminated-unions.md) |
|
|
94
|
+
| SolidJS-specific issues (props, reactivity) | [SolidJS Anti-Patterns](../best-practices/solidjs/anti-patterns.md) |
|
|
95
|
+
| Performance: re-renders, reactivity mistakes | [SolidJS Performance](../best-practices/solidjs/performance.md) |
|
|
96
|
+
|
|
97
|
+
## Notes
|
|
98
|
+
|
|
99
|
+
- References specific file names and line numbers
|
|
100
|
+
- Distinguishes between opinion and objective issues
|
|
101
|
+
- Acknowledges good patterns, not just problems
|
|
102
|
+
- Suggests splitting if the PR is too large to review effectively
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# /pr-summary
|
|
2
|
+
|
|
3
|
+
> Generate a structured pull request summary from the current branch.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/pr-summary.md`](../core/commands/ct/pr-summary.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
/pr-summary
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
1. **Identify the base branch** -- checks for `main` or `master`, uses `git merge-base` to find the common ancestor
|
|
18
|
+
2. **Gather the diff** -- runs `git diff {base}...HEAD --stat` for overview and full diff for details
|
|
19
|
+
3. **Gather commit history** -- runs `git log {base}...HEAD --oneline --no-merges`
|
|
20
|
+
4. **Analyze changes** -- reads modified files to understand the "why" behind each change
|
|
21
|
+
5. **Generate the summary**
|
|
22
|
+
|
|
23
|
+
## Output Format
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
## Summary
|
|
27
|
+
{1-3 bullet points describing the high-level purpose}
|
|
28
|
+
|
|
29
|
+
## What Changed
|
|
30
|
+
|
|
31
|
+
### {Category} (e.g., "Authentication", "Database", "UI")
|
|
32
|
+
- `{file}` - {what changed and why}
|
|
33
|
+
|
|
34
|
+
## Impact Assessment
|
|
35
|
+
- **Risk level:** low | medium | high
|
|
36
|
+
- **Affected areas:** {list of features or systems impacted}
|
|
37
|
+
- **Breaking changes:** none, or description
|
|
38
|
+
- **Migration needed:** none, or description
|
|
39
|
+
|
|
40
|
+
## Testing Notes
|
|
41
|
+
- {How to test this change}
|
|
42
|
+
- {Key scenarios to verify}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes
|
|
46
|
+
|
|
47
|
+
- Infers the "why" from commit messages, code comments, and the nature of changes
|
|
48
|
+
- Groups related file changes under meaningful categories
|
|
49
|
+
- Honest about risk level -- flags potential issues in Testing Notes
|
|
50
|
+
- Designed to be scannable in under 60 seconds
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# /proto-check
|
|
2
|
+
|
|
3
|
+
> Validate protobuf definitions for correctness, lint compliance, and backward compatibility.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/proto-check.md`](../core/commands/ct/proto-check.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read, Glob, Grep
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
/proto-check
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
1. **Find proto files** -- locates all `.proto` files and identifies buf configuration (`buf.yaml`, `buf.gen.yaml`)
|
|
18
|
+
2. **Run lint checks** -- executes `buf lint` or the project-configured linter
|
|
19
|
+
3. **Check for breaking changes** -- runs `buf breaking --against .git#branch=main` to detect backward-incompatible changes:
|
|
20
|
+
- Removing or renaming fields
|
|
21
|
+
- Changing field numbers or types
|
|
22
|
+
- Removing services or RPCs
|
|
23
|
+
- Changing RPC signatures
|
|
24
|
+
4. **Regenerate types** -- runs `buf generate` or the project-configured generation command
|
|
25
|
+
5. **Verify generated code compiles** -- runs the project's typecheck or build command
|
|
26
|
+
6. **Report results**
|
|
27
|
+
|
|
28
|
+
## Output Format
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
## Protobuf Validation Report
|
|
32
|
+
|
|
33
|
+
**Proto files found:** {count}
|
|
34
|
+
**Buf config:** {path or "not found"}
|
|
35
|
+
|
|
36
|
+
### Lint Results
|
|
37
|
+
- **Status:** pass | fail
|
|
38
|
+
- **Issues:** {count}
|
|
39
|
+
|
|
40
|
+
### Breaking Change Check
|
|
41
|
+
- **Status:** pass | fail
|
|
42
|
+
- **Against:** {branch or reference}
|
|
43
|
+
|
|
44
|
+
### Code Generation
|
|
45
|
+
- **Status:** success | failure
|
|
46
|
+
- **Files generated:** {count}
|
|
47
|
+
|
|
48
|
+
### Compilation Check
|
|
49
|
+
- **Status:** pass | fail
|
|
50
|
+
|
|
51
|
+
### Summary
|
|
52
|
+
{Overall status and recommended actions}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Notes
|
|
56
|
+
|
|
57
|
+
- Checks for alternative protobuf tooling (`protoc`, `grpc_tools`) if `buf` is not installed
|
|
58
|
+
- Reports clearly if no proto files are found
|
|
59
|
+
- Breaking changes are flagged for human review, not automatically treated as errors
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# /ticket
|
|
2
|
+
|
|
3
|
+
> Work end-to-end on a ticket or issue: understand, explore, plan, implement, deliver.
|
|
4
|
+
|
|
5
|
+
**Type:** Command (slash command)
|
|
6
|
+
**Source:** [`core/commands/ct/ticket.md`](../core/commands/ct/ticket.md)
|
|
7
|
+
**Allowed Tools:** Bash, Read, Write, Edit, Glob, Grep
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
/ticket [issue-number-or-description]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Phases
|
|
16
|
+
|
|
17
|
+
### Phase 1: Understand
|
|
18
|
+
|
|
19
|
+
- Read the ticket (fetches via `gh issue view` if a GitHub issue number is provided)
|
|
20
|
+
- Clarify requirements -- identify acceptance criteria, edge cases, and constraints
|
|
21
|
+
- Identify scope -- what needs to change, what should NOT change
|
|
22
|
+
|
|
23
|
+
### Phase 2: Explore
|
|
24
|
+
|
|
25
|
+
- Find relevant code -- search for files, functions, and patterns related to the ticket
|
|
26
|
+
- Understand the test landscape -- existing tests, framework, patterns, coverage
|
|
27
|
+
- Check for related changes -- recent commits or PRs in the affected area
|
|
28
|
+
|
|
29
|
+
### Phase 3: Plan
|
|
30
|
+
|
|
31
|
+
- Draft an implementation plan listing specific changes needed:
|
|
32
|
+
- Files to create or modify
|
|
33
|
+
- Functions to add or change
|
|
34
|
+
- Tests to write
|
|
35
|
+
- Migrations or config changes
|
|
36
|
+
- Share the plan with the user and get confirmation before proceeding
|
|
37
|
+
|
|
38
|
+
### Phase 4: Implement
|
|
39
|
+
|
|
40
|
+
- Create a feature branch following project conventions
|
|
41
|
+
- Write tests first when applicable (TDD)
|
|
42
|
+
- Implement changes following project conventions
|
|
43
|
+
- Run quality checks (lint, typecheck, tests)
|
|
44
|
+
|
|
45
|
+
### Phase 5: Deliver
|
|
46
|
+
|
|
47
|
+
- Commit with conventional commit messages
|
|
48
|
+
- Create a PR with clear title and description
|
|
49
|
+
- Report back with the PR link and summary
|
|
50
|
+
|
|
51
|
+
## Notes
|
|
52
|
+
|
|
53
|
+
- Always asks before making architectural decisions (new tables, new services, changing frameworks)
|
|
54
|
+
- Does not gold-plate -- implements what the ticket asks for, nothing more
|
|
55
|
+
- Proposes splitting if the ticket is too large for a single PR
|
|
56
|
+
- Notes bugs or issues outside the ticket scope but does not fix them unless they block the ticket
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Systematic Debugging
|
|
2
|
+
|
|
3
|
+
> Four-phase methodology for diagnosing and fixing bugs efficiently without guesswork.
|
|
4
|
+
|
|
5
|
+
**Type:** Core Skill (always included)
|
|
6
|
+
**Source:** [`core/skills/systematic-debugging/SKILL.md`](../core/skills/systematic-debugging/SKILL.md)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
A disciplined approach to debugging that replaces trial-and-error with structured investigation. Apply the four phases in order -- skipping phases leads to wasted time and incomplete fixes.
|
|
11
|
+
|
|
12
|
+
## Phases
|
|
13
|
+
|
|
14
|
+
### Phase 1: Observe
|
|
15
|
+
|
|
16
|
+
Reproduce the issue and gather evidence before forming any theories.
|
|
17
|
+
|
|
18
|
+
- **Reproduce reliably** -- find the minimal steps to trigger the bug
|
|
19
|
+
- **Read the actual error** -- full stack trace, error message, and relevant logs
|
|
20
|
+
- **Check recent changes** -- use `git log` and `git diff` to identify what changed
|
|
21
|
+
- **Gather context** -- note the environment, input data, user actions, and timing
|
|
22
|
+
- **Record observations** -- write down what you see, not what you think is happening
|
|
23
|
+
|
|
24
|
+
### Phase 2: Hypothesize
|
|
25
|
+
|
|
26
|
+
Form theories based on evidence, not intuition.
|
|
27
|
+
|
|
28
|
+
- **List possible causes** -- generate at least 2-3 hypotheses before investigating any
|
|
29
|
+
- **Rank by likelihood** -- what changed recently? What is the simplest explanation?
|
|
30
|
+
- **Consider the data flow** -- trace the path from input to error
|
|
31
|
+
- **Check assumptions** -- the bug is often in the code you trust most
|
|
32
|
+
|
|
33
|
+
### Phase 3: Test
|
|
34
|
+
|
|
35
|
+
Isolate variables and verify one hypothesis at a time.
|
|
36
|
+
|
|
37
|
+
- **Test one thing at a time** -- change a single variable per experiment
|
|
38
|
+
- **Use the smallest possible test** -- write a minimal reproduction
|
|
39
|
+
- **Add logging at boundaries** -- log inputs and outputs at function boundaries
|
|
40
|
+
- **Disprove hypotheses** -- design tests that would show the hypothesis is wrong
|
|
41
|
+
- **Binary search large spaces** -- bisect systematically when the problem could be anywhere
|
|
42
|
+
|
|
43
|
+
### Phase 4: Fix
|
|
44
|
+
|
|
45
|
+
Apply the minimal correct fix, then verify thoroughly.
|
|
46
|
+
|
|
47
|
+
- **Fix the root cause, not the symptom** -- if a null check prevents a crash but the value should never be null, fix the source
|
|
48
|
+
- **Make the smallest change possible** -- large fixes introduce new bugs
|
|
49
|
+
- **Verify the fix** -- run the reproduction case and confirm the bug is gone
|
|
50
|
+
- **Check for regressions** -- run the full test suite
|
|
51
|
+
- **Add a test for the bug** -- prevent the same class of bug from recurring
|
|
52
|
+
- **Document the fix** -- explain what caused the bug and why the fix is correct in the commit message
|
|
53
|
+
|
|
54
|
+
## Anti-patterns
|
|
55
|
+
|
|
56
|
+
| Anti-pattern | Description |
|
|
57
|
+
|---|---|
|
|
58
|
+
| **Shotgun debugging** | Making random changes hoping something works. Every change should be driven by a hypothesis. |
|
|
59
|
+
| **Fixing symptoms** | Adding null checks, try/catch blocks, or default values without understanding why the unexpected state occurs. |
|
|
60
|
+
| **Debugging by rewriting** | Rewriting a module because you cannot find the bug. The bug may survive the rewrite. |
|
|
61
|
+
| **Ignoring intermittent failures** | "It works now" is not a fix. Intermittent bugs are usually race conditions, state leaks, or environment dependencies. |
|
|
62
|
+
| **Assuming the bug is elsewhere** | Check your own code first. The framework or library is almost never the problem. |
|
|
63
|
+
|
|
64
|
+
## Trigger Conditions
|
|
65
|
+
|
|
66
|
+
This skill is automatically suggested when Claude detects:
|
|
67
|
+
|
|
68
|
+
- **Keywords:** `bug`, `debug`, `fix`, `error`, `issue`, `broken`, `crash`
|
|
69
|
+
- **Intent patterns:** "fix/debug/resolve the bug/error/issue"
|
|
70
|
+
- **Excludes:** "fix typo", "fix formatting", "fix lint"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Testing Patterns
|
|
2
|
+
|
|
3
|
+
> Generic test-driven development practices and patterns applicable to any language or test framework.
|
|
4
|
+
|
|
5
|
+
**Type:** Core Skill (always included)
|
|
6
|
+
**Source:** [`core/skills/testing-patterns/SKILL.md`](../core/skills/testing-patterns/SKILL.md)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Principles and patterns for writing tests that catch bugs, enable refactoring, and serve as documentation. These are framework-agnostic -- adapt the syntax to your project's test runner.
|
|
11
|
+
|
|
12
|
+
## TDD Cycle: Red, Green, Refactor
|
|
13
|
+
|
|
14
|
+
1. **Red** -- Write a failing test that describes the desired behavior. Confirm it fails for the right reason.
|
|
15
|
+
2. **Green** -- Write the minimal code to make the test pass. Do not optimize yet.
|
|
16
|
+
3. **Refactor** -- Improve the code while keeping all tests green. Remove duplication, improve naming, simplify logic.
|
|
17
|
+
|
|
18
|
+
Commit at each stage. The cycle keeps scope small and provides a safety net for every change.
|
|
19
|
+
|
|
20
|
+
## Key Principles
|
|
21
|
+
|
|
22
|
+
### Test Behavior, Not Implementation
|
|
23
|
+
|
|
24
|
+
Tests should describe *what* the code does, not *how* it does it internally.
|
|
25
|
+
|
|
26
|
+
- **Good:** "returns the user's full name when first and last name are provided"
|
|
27
|
+
- **Bad:** "calls `String.prototype.concat` with first name and space and last name"
|
|
28
|
+
|
|
29
|
+
### Factory Pattern for Test Data
|
|
30
|
+
|
|
31
|
+
Create factory functions that produce valid test objects with sensible defaults. Accept overrides for the fields relevant to each test.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
function getMockUser(overrides = {}) {
|
|
35
|
+
return {
|
|
36
|
+
id: "user-1",
|
|
37
|
+
email: "test@example.com",
|
|
38
|
+
name: "Test User",
|
|
39
|
+
role: "member",
|
|
40
|
+
createdAt: new Date("2024-01-01"),
|
|
41
|
+
...overrides,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Usage: only specify what matters for this test
|
|
46
|
+
const admin = getMockUser({ role: "admin" });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Test File Organization
|
|
50
|
+
|
|
51
|
+
- **Co-locate tests with source** or mirror the source directory structure
|
|
52
|
+
- **One test file per module** -- name it `module.test.ext` or `module.spec.ext`
|
|
53
|
+
- **Group related tests** using `describe` blocks
|
|
54
|
+
- **Use descriptive test names** that read as sentences
|
|
55
|
+
|
|
56
|
+
### Mocking Strategies
|
|
57
|
+
|
|
58
|
+
- **Prefer real dependencies** when feasible (in-memory database, local test server)
|
|
59
|
+
- **Mock at boundaries** -- external services only, not internal modules
|
|
60
|
+
- **Keep mocks minimal** -- only mock the methods your code actually calls
|
|
61
|
+
- **Verify mock contracts** -- ensure mocks match real API behavior
|
|
62
|
+
- **Reset mocks between tests** -- prevent shared state and order-dependent failures
|
|
63
|
+
|
|
64
|
+
## Test Categories
|
|
65
|
+
|
|
66
|
+
| Category | Scope | Speed | Quantity |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| **Unit tests** | Single function or class | Fast | Many |
|
|
69
|
+
| **Integration tests** | Multiple components together | Slower | Some |
|
|
70
|
+
| **End-to-end tests** | Full user flow | Slowest | Few |
|
|
71
|
+
|
|
72
|
+
The ratio should be roughly pyramid-shaped: many unit tests, some integration tests, few E2E tests.
|
|
73
|
+
|
|
74
|
+
## Anti-patterns
|
|
75
|
+
|
|
76
|
+
| Anti-pattern | Description |
|
|
77
|
+
|---|---|
|
|
78
|
+
| **Testing implementation details** | Asserting on internal state or private methods. Breaks on every refactor. |
|
|
79
|
+
| **Overmocking** | When most of the test is mock setup, you are testing mocks, not code. |
|
|
80
|
+
| **Copy-paste test cases** | Duplicated test code becomes a maintenance burden. Use factories and parameterized tests. |
|
|
81
|
+
| **No assertions** | A test that runs code but asserts nothing provides false confidence. |
|
|
82
|
+
| **Ignoring flaky tests** | A sometimes-failing test is either wrong or exposing a real bug. Fix or delete it. |
|
|
83
|
+
| **Testing only the happy path** | Error cases, edge cases, and boundary conditions are where bugs live. |
|
|
84
|
+
|
|
85
|
+
## Trigger Conditions
|
|
86
|
+
|
|
87
|
+
- **Keywords:** `test`, `spec`, `tdd`, `mock`, `factory`
|
|
88
|
+
- **File patterns:** `**/*.test.ts`, `**/*.spec.ts`
|
|
89
|
+
- **Excludes:** "e2e", "end-to-end"
|