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.
Files changed (40) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +3 -0
  3. package/bin/cli.ts +0 -0
  4. package/core/skills/ct-testing-patterns/SKILL.md +117 -0
  5. package/core/skills/{typescript-conventions → ct-typescript-conventions}/SKILL.md +41 -0
  6. package/core/skills/{verification-before-completion → ct-verification-before-completion}/SKILL.md +10 -0
  7. package/docs/README.md +3 -0
  8. package/docs/best-practices/testing/README.md +84 -0
  9. package/docs/best-practices/testing/playwright-e2e.md +649 -0
  10. package/docs/best-practices/testing/storybook-interaction.md +445 -0
  11. package/docs/best-practices/testing/vitest-unit.md +451 -0
  12. package/docs/skills/systematic-debugging.md +1 -1
  13. package/docs/skills/testing-patterns.md +30 -1
  14. package/docs/skills/typescript-conventions.md +42 -1
  15. package/docs/skills/verification-before-completion.md +14 -2
  16. package/docs/stacks/cloudflare-d1-kv.md +35 -1
  17. package/docs/stacks/i18n-typesafe.md +1 -1
  18. package/docs/stacks/playwright-patterns.md +179 -0
  19. package/docs/stacks/protobuf-contracts.md +1 -1
  20. package/docs/stacks/rust-wasm-patterns.md +2 -2
  21. package/docs/stacks/solidjs-patterns.md +1 -1
  22. package/docs/stacks/storybook-patterns.md +160 -0
  23. package/docs/stacks/vanilla-extract-patterns.md +1 -1
  24. package/docs/stacks/vite-vitest-patterns.md +485 -0
  25. package/package.json +3 -3
  26. package/stacks/cloudflare/skills/{cloudflare-d1-kv → ct-cloudflare-d1-kv}/SKILL.md +22 -0
  27. package/stacks/playwright/skills/ct-playwright-patterns/SKILL.md +168 -0
  28. package/stacks/playwright/stack.json +39 -0
  29. package/stacks/solidjs/stack.json +7 -1
  30. package/stacks/storybook/skills/ct-storybook-patterns/SKILL.md +149 -0
  31. package/stacks/storybook/stack.json +46 -0
  32. package/stacks/vite/skills/ct-vite-vitest-patterns/SKILL.md +492 -0
  33. package/stacks/vite/stack.json +66 -0
  34. package/core/skills/testing-patterns/SKILL.md +0 -52
  35. /package/core/skills/{systematic-debugging → ct-systematic-debugging}/SKILL.md +0 -0
  36. /package/stacks/i18n-typesafe/skills/{i18n-typesafe → ct-i18n-typesafe}/SKILL.md +0 -0
  37. /package/stacks/protobuf/skills/{protobuf-contracts → ct-protobuf-contracts}/SKILL.md +0 -0
  38. /package/stacks/rust-wasm/skills/{rust-wasm-patterns → ct-rust-wasm-patterns}/SKILL.md +0 -0
  39. /package/stacks/solidjs/skills/{solidjs-patterns → ct-solidjs-patterns}/SKILL.md +0 -0
  40. /package/stacks/vanilla-extract/skills/{vanilla-extract-patterns → ct-vanilla-extract-patterns}/SKILL.md +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.18 (2026-04-05)
4
+
5
+ - docs: update cross-references for vite, playwright, and storybook stacks
6
+
7
+ ## 0.1.17 (2026-04-05)
8
+
9
+ - feat: add storybook stack with interaction testing and visual regression
10
+
11
+ ## 0.1.16 (2026-04-05)
12
+
13
+ - feat: add playwright stack with E2E testing, Page Objects, and CI/CD
14
+
15
+ ## 0.1.15 (2026-04-05)
16
+
17
+ - feat: add vite stack with Vitest testing, coverage, and browser mode
18
+
19
+ ## 0.1.14 (2026-04-05)
20
+
21
+ - docs: add 3-layer testing strategy and shared principles to testing patterns
22
+
23
+ ## 0.1.13 (2026-04-05)
24
+
25
+ - docs: add testing best practices for vitest, playwright, and storybook
26
+
27
+ ## 0.1.12 (2026-04-05)
28
+
29
+ - docs: update skills and docs to 2026 best practices
30
+
31
+ ## 0.1.11 (2026-04-05)
32
+
33
+ - refactor: rename skill folders to match ct- prefixed skill names
34
+
35
+ ## 0.1.10 (2026-04-05)
36
+
37
+ - chore: update typescript to ^6.0.2 and require bun >=1.3.0
38
+
3
39
  ## 0.1.9 (2026-04-04)
4
40
 
5
41
  - docs: add Zod/Valibot runtime validation section to SolidJS data fetching
package/README.md CHANGED
@@ -50,11 +50,14 @@ export default defineConfig({
50
50
  | Stack | Skills Added |
51
51
  |-------|-------------|
52
52
  | `solidjs` | SolidJS reactivity, signals, components |
53
+ | `vite` | Vite build config, plugins, Vitest testing, coverage, browser mode |
53
54
  | `vanilla-extract` | Type-safe CSS, sprinkles, recipes, themes |
54
55
  | `rust-wasm` | Rust WASM for Cloudflare Workers |
55
56
  | `protobuf` | Protocol Buffers, code generation, contracts |
56
57
  | `cloudflare` | D1 database, KV cache, Wrangler |
57
58
  | `i18n-typesafe` | typesafe-i18n internationalization |
59
+ | `playwright` | Playwright E2E testing, Page Objects, fixtures, CI/CD |
60
+ | `storybook` | Storybook interaction testing, CSF 3, visual regression |
58
61
 
59
62
  ## Core Features (always included)
60
63
 
package/bin/cli.ts CHANGED
File without changes
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: ct-testing-patterns
3
+ description: Generic test-driven development practices and patterns applicable to any language or test framework.
4
+ ---
5
+
6
+ # Testing Patterns
7
+
8
+ ## TDD Cycle
9
+
10
+ 1. **Red** -- Write a failing test for desired behavior. Confirm it fails for the right reason.
11
+ 2. **Green** -- Minimal code to pass. No optimization yet.
12
+ 3. **Refactor** -- Clean up while keeping tests green. Commit at each stage.
13
+
14
+ ## 3-Layer Testing Strategy
15
+
16
+ ```
17
+ / E2E \ Real browsers, full user flows
18
+ /----------\
19
+ / Interaction \ Component sandbox, behavior, a11y
20
+ /----------------\
21
+ / Unit \ Pure logic, signals, utilities
22
+ /--------------------\
23
+ ```
24
+
25
+ | Layer | Target Ratio | What to Cover |
26
+ | ----------- | ------------ | ---------------------------------------------------------------------------- |
27
+ | Unit | ~70% | Business logic, utilities, data transforms, reactive primitives, error paths |
28
+ | Interaction | ~20% | Component variants, user interactions, accessibility, visual regression |
29
+ | E2E | ~10% | Critical user journeys, authentication flows, cross-page workflows |
30
+
31
+ ### When to Use Which Layer
32
+
33
+ | Question | Layer |
34
+ | ------------------------------------------------- | -------------------------------------- |
35
+ | Does this logic need a DOM? | **Unit** if no, **Interaction** if yes |
36
+ | Does it involve multiple pages or navigation? | **E2E** |
37
+ | Am I testing a single component's visual states? | **Interaction** |
38
+ | Am I testing a reactive primitive (signal, memo)? | **Unit** |
39
+ | Does it require authentication or real network? | **E2E** |
40
+ | Am I testing component accessibility? | **Interaction** (axe-core) |
41
+ | Does it need the full server running? | **E2E** |
42
+
43
+ ## Test Behavior, Not Implementation
44
+
45
+ Test *what* code does (public interface, observable outputs), not *how* (internal state, call counts). Implementation-coupled tests break on every refactor.
46
+
47
+ ## Factory Pattern
48
+
49
+ ```
50
+ function getMockUser(overrides = {}) {
51
+ return { id: "user-1", email: "test@example.com", name: "Test User", role: "member", ...overrides };
52
+ }
53
+ const admin = getMockUser({ role: "admin" });
54
+ ```
55
+
56
+ New required fields update the factory once, not every test.
57
+
58
+ ## Organization
59
+
60
+ - Co-locate tests or mirror source structure. One test file per module (`module.test.ext`).
61
+ - Group with `describe`, name as sentences: `it("rejects expired tokens")`.
62
+
63
+ ## Shared Principles
64
+
65
+ - **Prefer role-based queries.** Use `getByRole`, `getByLabel`, `getByText` over test IDs or CSS selectors.
66
+ - **Never sleep.** Use framework-provided waiting mechanisms (`waitFor`, `findBy*`, web-first assertions).
67
+ - **One assertion focus per test.** Multiple assertions are fine if they verify facets of the same behavior.
68
+ - **Isolate tests.** No test should depend on another test's side effects. Reset state between tests.
69
+
70
+ ## Mocking Rules
71
+
72
+ - Prefer real dependencies (in-memory DB, local server) when feasible.
73
+ - Mock at boundaries only (external APIs, email, payments), not internal modules.
74
+ - Keep mocks minimal -- only methods your code calls. Reset between tests.
75
+ - Verify mocks match the real API. Update when APIs change.
76
+
77
+ ## Property-Based Testing
78
+
79
+ When a function has a contract ("for all valid inputs X, property Y holds"), use property-based tests to verify it across generated inputs instead of hand-picked examples:
80
+
81
+ ```
82
+ // Instead of testing 3-4 specific inputs:
83
+ test("sort is idempotent", () => {
84
+ fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
85
+ const sorted = mySort(arr);
86
+ expect(mySort(sorted)).toEqual(sorted);
87
+ }));
88
+ });
89
+ ```
90
+
91
+ Good candidates: serialization round-trips, math properties, parsers, encoding/decoding, sorting invariants.
92
+
93
+ ## Bun Test Runner
94
+
95
+ Bun includes a built-in test runner. Use `bun test` for projects on the Bun runtime:
96
+
97
+ ```
98
+ bun test # run all *.test.ts files
99
+ bun test --watch # re-run on changes
100
+ bun test --coverage # with code coverage
101
+ bun test path/to/file.test.ts # single file
102
+ ```
103
+
104
+ Bun supports `describe`, `it`/`test`, `expect`, lifecycle hooks, and snapshot testing out of the box with no additional dependencies.
105
+
106
+ ## Test Pyramid
107
+
108
+ See 3-Layer Testing Strategy above. Many unit tests (fast, focused) > some interaction tests (component sandbox) > few E2E tests (full flow). Aim for 70/20/10 distribution.
109
+
110
+ ## Anti-Patterns
111
+
112
+ 1. **Testing implementation** -- Asserting internal state or call counts breaks on refactors.
113
+ 2. **Overmocking** -- If most of the test is mock setup, you're testing mocks.
114
+ 3. **Copy-paste tests** -- Use factories and parameterized tests.
115
+ 4. **No assertions** -- Worse than no test. False confidence.
116
+ 5. **Ignoring flaky tests** -- Fix or delete; never skip indefinitely.
117
+ 6. **Happy path only** -- Error cases and boundary conditions are where bugs live.
@@ -40,6 +40,47 @@ type AsyncState<T> =
40
40
  | { status: "error"; error: Error };
41
41
  ```
42
42
 
43
+ ## `satisfies` Operator
44
+
45
+ Validate a value matches a type without widening it. Preserves the narrowest inferred type while ensuring conformance.
46
+
47
+ ```typescript
48
+ type Route = { path: string; children?: Route[] };
49
+
50
+ const routes = {
51
+ home: { path: "/" },
52
+ user: { path: "/user/:id", children: [{ path: "settings" }] },
53
+ } satisfies Record<string, Route>;
54
+
55
+ // routes.home.path is still "/" (literal), not string
56
+ ```
57
+
58
+ ## `const` Type Parameters
59
+
60
+ Infer literal types from arguments without requiring callers to write `as const`:
61
+
62
+ ```typescript
63
+ function createConfig<const T extends readonly string[]>(names: T): Record<T[number], boolean> {
64
+ return Object.fromEntries(names.map(n => [n, false])) as Record<T[number], boolean>;
65
+ }
66
+
67
+ // result type: Record<"debug" | "verbose", boolean> -- not Record<string, boolean>
68
+ const flags = createConfig(["debug", "verbose"]);
69
+ ```
70
+
71
+ ## Template Literal Types
72
+
73
+ Build precise string types from unions:
74
+
75
+ ```typescript
76
+ type EventName = "click" | "focus" | "blur";
77
+ type Handler = `on${Capitalize<EventName>}`; // "onClick" | "onFocus" | "onBlur"
78
+
79
+ type Locale = "en" | "fr" | "ja";
80
+ type Currency = "USD" | "EUR" | "JPY";
81
+ type PriceKey = `price:${Locale}:${Currency}`; // 9 valid combinations
82
+ ```
83
+
43
84
  ## Generic Constraints
44
85
 
45
86
  ```typescript
@@ -31,12 +31,22 @@ Do not assume edge cases work because the happy path works.
31
31
  - Verify consumers of changed APIs/schemas still work.
32
32
  - Smoke test the running application if applicable.
33
33
 
34
+ ## Security Check
35
+
36
+ Before completing work that touches dependencies, inputs, or external data:
37
+
38
+ - **Dependency audit** -- Run `bun audit` or `npm audit` and resolve critical/high vulnerabilities.
39
+ - **Input validation** -- Verify user-facing inputs are validated at system boundaries (no SQL injection, XSS, command injection).
40
+ - **Secret exposure** -- Confirm no secrets, API keys, or credentials in committed code or logs.
41
+
34
42
  ## Evidence Format
35
43
 
36
44
  ```
37
45
  ## Completed: [task name]
38
46
  - Tests: X passing (Y new, Z existing) -- [command output]
39
47
  - Types: tsc --noEmit: 0 errors
48
+ - Lint: 0 violations
49
+ - Security: audit clean, no exposed secrets
40
50
  - Manual: [endpoint/action]: [status/result]
41
51
  - Edge cases: [what was verified]
42
52
  ```
package/docs/README.md CHANGED
@@ -42,8 +42,11 @@ Stack-specific skills activated based on your `claude-toolkit.config.ts` configu
42
42
  | Skill | Stack | Description |
43
43
  | -------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------ |
44
44
  | [ct-solidjs-patterns](stacks/solidjs-patterns.md) | `solidjs` | Reactivity, signals, effects, component patterns, and props handling |
45
+ | [ct-vite-vitest-patterns](stacks/vite-vitest-patterns.md) | `vite` | Vite build config, plugins, env vars, Vitest testing, coverage, browser mode |
45
46
  | [ct-vanilla-extract-patterns](stacks/vanilla-extract-patterns.md) | `vanilla-extract` | Type-safe CSS with zero runtime: styles, recipes, themes, sprinkles |
46
47
  | [ct-rust-wasm-patterns](stacks/rust-wasm-patterns.md) | `rust-wasm` | Rust WASM for Cloudflare Workers: routing, handlers, env bindings |
47
48
  | [ct-protobuf-contracts](stacks/protobuf-contracts.md) | `protobuf` | Protocol Buffers for API contracts: schema design, versioning, code generation |
48
49
  | [ct-cloudflare-d1-kv](stacks/cloudflare-d1-kv.md) | `cloudflare` | D1 database and KV cache: queries, migrations, caching patterns |
49
50
  | [ct-i18n-typesafe](stacks/i18n-typesafe.md) | `i18n-typesafe` | Type-safe internationalization with compile-time key checking |
51
+ | [ct-playwright-patterns](stacks/playwright-patterns.md) | `playwright` | E2E testing with Page Objects, fixtures, auth, network mocking, CI/CD |
52
+ | [ct-storybook-patterns](stacks/storybook-patterns.md) | `storybook` | Interaction testing, CSF 3, play functions, a11y, visual regression |
@@ -0,0 +1,84 @@
1
+ # Testing Best Practices
2
+
3
+ > A curated collection of testing best practices for the rendezvous.nz stack, sourced from official documentation, framework maintainers, and the testing community as of 2026.
4
+
5
+ This project uses a **3-layer testing strategy** that maps to the classic testing pyramid. Each layer targets a different scope, runs in a different environment, and catches a different class of bugs.
6
+
7
+ ```
8
+ / E2E \ Playwright (real browsers)
9
+ /----------\ Full user flows, cross-browser
10
+ / Interaction \ Storybook (component sandbox)
11
+ /----------------\ Component behavior, visual, a11y
12
+ / Unit \ Vitest (Node/JSDOM)
13
+ /--------------------\ Pure logic, signals, utilities
14
+ ```
15
+
16
+ ## The Three Layers
17
+
18
+ | Layer | Tool | Scope | Environment | Speed |
19
+ | --------------------------------------- | ---------------- | ------------------------------------ | -------------------------------------- | ----------------- |
20
+ | [Unit](vitest-unit.md) | Vitest 4.x | Functions, signals, hooks, utilities | Node / JSDOM | ~ms per test |
21
+ | [Interaction](storybook-interaction.md) | Storybook 10.x | Component rendering, behavior, a11y | Real browser (via Vitest addon) | ~100ms per story |
22
+ | [E2E](playwright-e2e.md) | Playwright 1.58+ | Full user flows, API integration | Real browser (Chromium/Firefox/WebKit) | ~seconds per test |
23
+
24
+ ## When to Use Which Layer
25
+
26
+ | Question | Layer |
27
+ | --------------------------------------------------------- | -------------------------------------- |
28
+ | Does this logic need a DOM? | **Unit** if no, **Interaction** if yes |
29
+ | Does it involve multiple pages or navigation? | **E2E** |
30
+ | Am I testing a single component's visual states? | **Interaction** |
31
+ | Am I testing a reactive primitive (signal, memo, effect)? | **Unit** |
32
+ | Does it require authentication or real network? | **E2E** |
33
+ | Am I testing component accessibility? | **Interaction** (axe-core addon) |
34
+ | Am I testing cross-browser rendering? | **E2E** (multi-browser projects) |
35
+ | Does it need the Cloudflare Worker running? | **E2E** |
36
+
37
+ ## Distribution Guideline
38
+
39
+ Aim for the pyramid shape -- many fast unit tests at the base, fewer interaction tests in the middle, and a focused set of E2E tests at the top.
40
+
41
+ | Layer | Target Ratio | What to Cover |
42
+ | ----------- | ------------ | ---------------------------------------------------------------------------- |
43
+ | Unit | ~70% | Business logic, utilities, data transforms, reactive primitives, error paths |
44
+ | Interaction | ~20% | Component variants, user interactions, accessibility, visual regression |
45
+ | E2E | ~10% | Critical user journeys, authentication flows, cross-page workflows |
46
+
47
+ ## Shared Principles Across All Layers
48
+
49
+ 1. **Test behavior, not implementation.** Assert what the user sees or what the API returns, not internal state.
50
+ 2. **Prefer role-based queries.** Use `getByRole`, `getByLabel`, `getByText` over test IDs or CSS selectors.
51
+ 3. **Never sleep.** Use framework-provided waiting mechanisms (`waitFor`, `findBy*`, web-first assertions).
52
+ 4. **One assertion focus per test.** A test should verify one behavior. Multiple assertions are fine if they verify facets of the same behavior.
53
+ 5. **Isolate tests.** No test should depend on another test's side effects. Reset state between tests.
54
+ 6. **Mock at boundaries.** Mock network calls and external services, not internal modules.
55
+ 7. **SolidJS reactivity rules apply in tests.** Never destructure props. Use `renderHook` or `createRoot` for signal testing.
56
+
57
+ ## SolidJS-Specific Considerations
58
+
59
+ SolidJS components run once -- only reactive expressions re-execute. This affects testing:
60
+
61
+ - **`render()` takes a callback**: `render(() => <Component />)`, not `render(<Component />)`.
62
+ - **Effects are async**: Use `testEffect` from `@solidjs/testing-library` for effect assertions.
63
+ - **Storybook decorators need `createJSXDecorator`**: Standard decorators cause duplicate DOM elements with SolidJS.
64
+
65
+ ## Technology Versions (as of April 2026)
66
+
67
+ | Tool | Version | Notes |
68
+ | ------------------------ | ------- | ---------------------------------------------------- |
69
+ | Vitest | ^4.1.x | V8 coverage, test tags, builder-pattern fixtures |
70
+ | @solidjs/testing-library | ^0.8.x | SolidJS-specific render, renderHook, testEffect |
71
+ | Storybook | ^10.3.x | ESM-only, `sb.mock`, testing widget |
72
+ | storybook-solidjs-vite | ^10.0.x | Community-maintained SolidJS renderer |
73
+ | @storybook/addon-vitest | ^10.x | Replaces old test-runner, uses Vitest browser mode |
74
+ | Playwright | ^1.58.x | Timeline view, Chrome for Testing, WebSocket mocking |
75
+ | @axe-core/playwright | ^4.x | WCAG 2.1 AA automated accessibility checks |
76
+ | MSW | ^2.x | Network mocking for both Storybook and Vitest |
77
+
78
+ ## Guides
79
+
80
+ | Guide | Summary |
81
+ | --------------------------------------------------------- | ---------------------------------------------------------------------------- |
82
+ | [Vitest Unit Testing](vitest-unit.md) | AAA pattern, signal testing, mocking, coverage, performance, anti-patterns. |
83
+ | [Storybook Interaction Testing](storybook-interaction.md) | CSF 3, play functions, a11y, visual regression, MSW, portable stories. |
84
+ | [Playwright E2E Testing](playwright-e2e.md) | Page Objects, fixtures, auth, network mocking, CI/CD, flaky test prevention. |