claude-toolkit 0.1.9 → 0.1.18
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 +36 -0
- package/README.md +3 -0
- package/bin/cli.ts +0 -0
- package/core/skills/ct-testing-patterns/SKILL.md +117 -0
- package/core/skills/{typescript-conventions → ct-typescript-conventions}/SKILL.md +41 -0
- package/core/skills/{verification-before-completion → ct-verification-before-completion}/SKILL.md +10 -0
- package/docs/README.md +3 -0
- package/docs/best-practices/testing/README.md +84 -0
- package/docs/best-practices/testing/playwright-e2e.md +649 -0
- package/docs/best-practices/testing/storybook-interaction.md +445 -0
- package/docs/best-practices/testing/vitest-unit.md +451 -0
- package/docs/skills/systematic-debugging.md +1 -1
- package/docs/skills/testing-patterns.md +30 -1
- package/docs/skills/typescript-conventions.md +42 -1
- package/docs/skills/verification-before-completion.md +14 -2
- package/docs/stacks/cloudflare-d1-kv.md +35 -1
- package/docs/stacks/i18n-typesafe.md +1 -1
- package/docs/stacks/playwright-patterns.md +179 -0
- package/docs/stacks/protobuf-contracts.md +1 -1
- package/docs/stacks/rust-wasm-patterns.md +2 -2
- package/docs/stacks/solidjs-patterns.md +1 -1
- package/docs/stacks/storybook-patterns.md +160 -0
- package/docs/stacks/vanilla-extract-patterns.md +1 -1
- package/docs/stacks/vite-vitest-patterns.md +485 -0
- package/package.json +3 -3
- package/stacks/cloudflare/skills/{cloudflare-d1-kv → ct-cloudflare-d1-kv}/SKILL.md +22 -0
- package/stacks/playwright/skills/ct-playwright-patterns/SKILL.md +168 -0
- package/stacks/playwright/stack.json +39 -0
- package/stacks/solidjs/stack.json +7 -1
- package/stacks/storybook/skills/ct-storybook-patterns/SKILL.md +149 -0
- package/stacks/storybook/stack.json +46 -0
- package/stacks/vite/skills/ct-vite-vitest-patterns/SKILL.md +492 -0
- package/stacks/vite/stack.json +66 -0
- package/core/skills/testing-patterns/SKILL.md +0 -52
- /package/core/skills/{systematic-debugging → ct-systematic-debugging}/SKILL.md +0 -0
- /package/stacks/i18n-typesafe/skills/{i18n-typesafe → ct-i18n-typesafe}/SKILL.md +0 -0
- /package/stacks/protobuf/skills/{protobuf-contracts → ct-protobuf-contracts}/SKILL.md +0 -0
- /package/stacks/rust-wasm/skills/{rust-wasm-patterns → ct-rust-wasm-patterns}/SKILL.md +0 -0
- /package/stacks/solidjs/skills/{solidjs-patterns → ct-solidjs-patterns}/SKILL.md +0 -0
- /package/stacks/vanilla-extract/skills/{vanilla-extract-patterns → ct-vanilla-extract-patterns}/SKILL.md +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ct-playwright-patterns",
|
|
3
|
+
"description": "Playwright E2E testing patterns with Page Objects, fixtures, and CI/CD",
|
|
4
|
+
"defaultMappings": {
|
|
5
|
+
"e2e": "ct-playwright-patterns",
|
|
6
|
+
"playwright.config.ts": "ct-playwright-patterns"
|
|
7
|
+
},
|
|
8
|
+
"fileExtensions": ["spec.ts"],
|
|
9
|
+
"skillRules": {
|
|
10
|
+
"ct-playwright-patterns": {
|
|
11
|
+
"description": "Playwright E2E testing with Page Objects, fixtures, auth, and network mocking",
|
|
12
|
+
"priority": 7,
|
|
13
|
+
"triggers": {
|
|
14
|
+
"keywords": [
|
|
15
|
+
"playwright",
|
|
16
|
+
"e2e",
|
|
17
|
+
"end-to-end",
|
|
18
|
+
"page object",
|
|
19
|
+
"browser test",
|
|
20
|
+
"storageState"
|
|
21
|
+
],
|
|
22
|
+
"keywordPatterns": ["\\bplaywright\\b", "\\be2e\\b", "\\bpage\\s*object\\b"],
|
|
23
|
+
"pathPatterns": ["**/e2e/**", "**/*.spec.ts", "**/playwright.config.*"],
|
|
24
|
+
"intentPatterns": [
|
|
25
|
+
"(?:create|write|add).*(?:e2e|end.to.end|playwright).*(?:test)",
|
|
26
|
+
"(?:page object|fixture|browser test)"
|
|
27
|
+
],
|
|
28
|
+
"contentPatterns": [
|
|
29
|
+
"@playwright/test",
|
|
30
|
+
"page.goto",
|
|
31
|
+
"page.getByRole",
|
|
32
|
+
"storageState",
|
|
33
|
+
"base.extend"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"relatedSkills": ["ct-storybook-patterns", "ct-testing-patterns", "ct-vite-vitest-patterns"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -46,7 +46,13 @@
|
|
|
46
46
|
"<Switch"
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
|
-
"relatedSkills": [
|
|
49
|
+
"relatedSkills": [
|
|
50
|
+
"ct-vanilla-extract-patterns",
|
|
51
|
+
"ct-testing-patterns",
|
|
52
|
+
"ct-vite-vitest-patterns",
|
|
53
|
+
"ct-storybook-patterns",
|
|
54
|
+
"ct-playwright-patterns"
|
|
55
|
+
]
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ct-storybook-patterns
|
|
3
|
+
description: Storybook interaction testing, CSF 3 stories, play functions, a11y, and visual regression for SolidJS components
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Storybook Patterns
|
|
7
|
+
|
|
8
|
+
Storybook is the middle layer of the testing pyramid: component interaction testing, visual regression, and accessibility auditing in a real browser.
|
|
9
|
+
|
|
10
|
+
## SolidJS Integration
|
|
11
|
+
|
|
12
|
+
Uses community packages: `storybook-solidjs` (renderer) + `storybook-solidjs-vite` (builder).
|
|
13
|
+
|
|
14
|
+
**Critical:** Always use `createJSXDecorator` for JSX decorators. Standard decorators cause duplicate DOM elements with SolidJS.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { createJSXDecorator } from "storybook-solidjs";
|
|
18
|
+
|
|
19
|
+
const ThemeDecorator = createJSXDecorator((Story) => (
|
|
20
|
+
<ThemeProvider><Story /></ThemeProvider>
|
|
21
|
+
));
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CSF 3 Stories
|
|
25
|
+
|
|
26
|
+
Use CSF 3 (not CSF Factories -- React-only as of Storybook 10.3).
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import type { Meta, StoryObj } from "storybook-solidjs";
|
|
30
|
+
|
|
31
|
+
const meta = {
|
|
32
|
+
title: "Components/Button",
|
|
33
|
+
component: Button,
|
|
34
|
+
tags: ["autodocs"],
|
|
35
|
+
} satisfies Meta<typeof Button>;
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
|
|
40
|
+
export const Primary: Story = {
|
|
41
|
+
args: { variant: "primary", children: "Click me" },
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Coverage Checklist
|
|
46
|
+
|
|
47
|
+
Every component needs stories for: all visual states (default, hover, focus, active, disabled, loading, error, empty), viewport sizes where layout differs, theme variants, edge cases (long text, missing data).
|
|
48
|
+
|
|
49
|
+
## Interaction Testing
|
|
50
|
+
|
|
51
|
+
Import everything from `@storybook/test` (instrumented versions). Never import from `@testing-library/dom` directly.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { expect, fn, userEvent, within } from "@storybook/test";
|
|
55
|
+
|
|
56
|
+
export const SubmitForm: Story = {
|
|
57
|
+
args: { onSubmit: fn() },
|
|
58
|
+
play: async ({ canvasElement, args, step }) => {
|
|
59
|
+
const canvas = within(canvasElement);
|
|
60
|
+
await step("Fill form", async () => {
|
|
61
|
+
await userEvent.type(canvas.getByLabelText("Email"), "user@example.com");
|
|
62
|
+
});
|
|
63
|
+
await step("Submit", async () => {
|
|
64
|
+
await userEvent.click(canvas.getByRole("button", { name: "Sign in" }));
|
|
65
|
+
});
|
|
66
|
+
await expect(args.onSubmit).toHaveBeenCalledOnce();
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Key rules:**
|
|
72
|
+
1. Always `await` expect calls (enables Interactions panel logging).
|
|
73
|
+
2. Use `step()` to organize complex interactions.
|
|
74
|
+
3. Use `fn()` for spying (auto-restored between stories).
|
|
75
|
+
|
|
76
|
+
## Running in CI (Vitest Addon)
|
|
77
|
+
|
|
78
|
+
Use `@storybook/addon-vitest` (replaces old test-runner). No running Storybook instance needed.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// vitest.config.storybook.ts
|
|
82
|
+
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
plugins: [storybookTest()],
|
|
86
|
+
test: {
|
|
87
|
+
name: "storybook",
|
|
88
|
+
browser: { enabled: true, provider: "playwright", instances: [{ browser: "chromium" }] },
|
|
89
|
+
setupFiles: [".storybook/vitest.setup.ts"],
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Accessibility
|
|
95
|
+
|
|
96
|
+
Built on axe-core. Set globally in `.storybook/preview.ts`:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
export default {
|
|
100
|
+
parameters: { a11y: { test: "error" } }, // "error" | "todo" | "off"
|
|
101
|
+
tags: ["a11y-test"],
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## MSW for API Components
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// .storybook/preview.ts
|
|
109
|
+
import { initialize, mswLoader } from "msw-storybook-addon";
|
|
110
|
+
initialize();
|
|
111
|
+
export default { loaders: [mswLoader] };
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Per-story handlers via `parameters.msw.handlers`. Keep success handlers in shared `mocks/handlers.ts`, override with error/edge-case at story level.
|
|
115
|
+
|
|
116
|
+
## Module Mocking (Storybook 10)
|
|
117
|
+
|
|
118
|
+
`sb.mock` for internal module replacement. Register in `.storybook/preview.ts` only:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { sb } from "@storybook/test";
|
|
122
|
+
sb.mock("../src/api/client", () => ({ fetchUser: async () => ({ name: "Mock" }) }));
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
MSW for network-level; `sb.mock` for internal modules.
|
|
126
|
+
|
|
127
|
+
## Portable Stories
|
|
128
|
+
|
|
129
|
+
Reuse stories in Vitest with `composeStories`:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { composeStories } from "storybook-solidjs";
|
|
133
|
+
import * as stories from "./Button.stories";
|
|
134
|
+
const { Primary } = composeStories(stories);
|
|
135
|
+
|
|
136
|
+
test("renders primary", () => {
|
|
137
|
+
const { getByRole } = render(() => <Primary />);
|
|
138
|
+
expect(getByRole("button")).toBeInTheDocument();
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Anti-Patterns
|
|
143
|
+
|
|
144
|
+
1. **Destructuring SolidJS props in stories** -- Pass props via `args`; use `createJSXDecorator` for decorators.
|
|
145
|
+
2. **Importing from `@testing-library/dom`** -- Use `@storybook/test` for instrumented versions.
|
|
146
|
+
3. **Not awaiting `expect()` in play functions** -- Always `await expect(...)`.
|
|
147
|
+
4. **Skipping error/edge-case stories** -- Always include loading, error, empty, boundary states.
|
|
148
|
+
5. **Using `@storybook/test-runner`** -- Use `@storybook/addon-vitest` instead.
|
|
149
|
+
6. **Registering `sb.mock` in story files** -- Register in `.storybook/preview.ts` only.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ct-storybook-patterns",
|
|
3
|
+
"description": "Storybook interaction testing, CSF 3 stories, and visual regression for SolidJS",
|
|
4
|
+
"defaultMappings": {
|
|
5
|
+
".storybook": "ct-storybook-patterns",
|
|
6
|
+
"src/**/*.stories.tsx": "ct-storybook-patterns"
|
|
7
|
+
},
|
|
8
|
+
"fileExtensions": ["stories.tsx", "stories.ts"],
|
|
9
|
+
"skillRules": {
|
|
10
|
+
"ct-storybook-patterns": {
|
|
11
|
+
"description": "Storybook CSF 3 stories, play functions, a11y testing, and visual regression",
|
|
12
|
+
"priority": 7,
|
|
13
|
+
"triggers": {
|
|
14
|
+
"keywords": [
|
|
15
|
+
"storybook",
|
|
16
|
+
"story",
|
|
17
|
+
"stories",
|
|
18
|
+
"csf",
|
|
19
|
+
"play function",
|
|
20
|
+
"interaction test",
|
|
21
|
+
"visual regression",
|
|
22
|
+
"chromatic"
|
|
23
|
+
],
|
|
24
|
+
"keywordPatterns": ["\\bstorybook\\b", "\\bstories\\b", "\\bplay\\s+function\\b"],
|
|
25
|
+
"pathPatterns": ["**/*.stories.tsx", "**/*.stories.ts", "**/.storybook/**"],
|
|
26
|
+
"intentPatterns": [
|
|
27
|
+
"(?:create|write|add).*(?:story|stories|storybook)",
|
|
28
|
+
"(?:interaction|visual|a11y).*(?:test|testing)"
|
|
29
|
+
],
|
|
30
|
+
"contentPatterns": [
|
|
31
|
+
"satisfies Meta",
|
|
32
|
+
"StoryObj",
|
|
33
|
+
"@storybook/test",
|
|
34
|
+
"createJSXDecorator",
|
|
35
|
+
"storybook-solidjs"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"relatedSkills": [
|
|
39
|
+
"ct-solidjs-patterns",
|
|
40
|
+
"ct-testing-patterns",
|
|
41
|
+
"ct-vite-vitest-patterns",
|
|
42
|
+
"ct-playwright-patterns"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|