opencastle 1.5.0 → 1.6.1

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 (204) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/adapters/antigravity.d.ts +1 -1
  3. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  4. package/dist/cli/adapters/claude-code.d.ts +1 -1
  5. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  6. package/dist/cli/adapters/claude-code.js +1 -0
  7. package/dist/cli/adapters/claude-code.js.map +1 -1
  8. package/dist/cli/adapters/codex.d.ts +1 -1
  9. package/dist/cli/adapters/codex.d.ts.map +1 -1
  10. package/dist/cli/adapters/cursor.d.ts +1 -1
  11. package/dist/cli/adapters/cursor.d.ts.map +1 -1
  12. package/dist/cli/adapters/cursor.js +6 -0
  13. package/dist/cli/adapters/cursor.js.map +1 -1
  14. package/dist/cli/adapters/opencode.d.ts +1 -1
  15. package/dist/cli/adapters/opencode.d.ts.map +1 -1
  16. package/dist/cli/adapters/rules-dir-base.d.ts +13 -1
  17. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  18. package/dist/cli/adapters/rules-dir-base.js +37 -18
  19. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  20. package/dist/cli/adapters/rules-dir-base.test.js +34 -0
  21. package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
  22. package/dist/cli/adapters/single-file-base.d.ts +8 -0
  23. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  24. package/dist/cli/adapters/single-file-base.js +48 -22
  25. package/dist/cli/adapters/single-file-base.js.map +1 -1
  26. package/dist/cli/adapters/windsurf.d.ts +1 -1
  27. package/dist/cli/adapters/windsurf.d.ts.map +1 -1
  28. package/dist/cli/bootstrap-on-init.test.js +11 -0
  29. package/dist/cli/bootstrap-on-init.test.js.map +1 -1
  30. package/dist/cli/command-namespace.test.js +17 -0
  31. package/dist/cli/command-namespace.test.js.map +1 -1
  32. package/dist/cli/convoy/engine.d.ts +12 -0
  33. package/dist/cli/convoy/engine.d.ts.map +1 -1
  34. package/dist/cli/convoy/engine.git.test.js +55 -0
  35. package/dist/cli/convoy/engine.git.test.js.map +1 -1
  36. package/dist/cli/convoy/engine.js +39 -1
  37. package/dist/cli/convoy/engine.js.map +1 -1
  38. package/dist/cli/convoy/findings.d.ts +35 -0
  39. package/dist/cli/convoy/findings.d.ts.map +1 -0
  40. package/dist/cli/convoy/findings.js +100 -0
  41. package/dist/cli/convoy/findings.js.map +1 -0
  42. package/dist/cli/convoy/findings.test.d.ts +2 -0
  43. package/dist/cli/convoy/findings.test.d.ts.map +1 -0
  44. package/dist/cli/convoy/findings.test.js +75 -0
  45. package/dist/cli/convoy/findings.test.js.map +1 -0
  46. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  47. package/dist/cli/convoy/isolation.js +2 -1
  48. package/dist/cli/convoy/isolation.js.map +1 -1
  49. package/dist/cli/convoy/worktree.d.ts +5 -0
  50. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  51. package/dist/cli/convoy/worktree.js +12 -0
  52. package/dist/cli/convoy/worktree.js.map +1 -1
  53. package/dist/cli/docs-accuracy.test.js +34 -0
  54. package/dist/cli/docs-accuracy.test.js.map +1 -1
  55. package/dist/cli/doctor.d.ts +11 -0
  56. package/dist/cli/doctor.d.ts.map +1 -1
  57. package/dist/cli/doctor.js +72 -8
  58. package/dist/cli/doctor.js.map +1 -1
  59. package/dist/cli/doctor.test.js +82 -1
  60. package/dist/cli/doctor.test.js.map +1 -1
  61. package/dist/cli/init.d.ts.map +1 -1
  62. package/dist/cli/init.js +58 -53
  63. package/dist/cli/init.js.map +1 -1
  64. package/dist/cli/init.test.js +28 -23
  65. package/dist/cli/init.test.js.map +1 -1
  66. package/dist/cli/layers.d.ts +20 -0
  67. package/dist/cli/layers.d.ts.map +1 -1
  68. package/dist/cli/layers.js +53 -1
  69. package/dist/cli/layers.js.map +1 -1
  70. package/dist/cli/layers.test.js +67 -1
  71. package/dist/cli/layers.test.js.map +1 -1
  72. package/dist/cli/lessons.d.ts +10 -0
  73. package/dist/cli/lessons.d.ts.map +1 -1
  74. package/dist/cli/lessons.js +26 -1
  75. package/dist/cli/lessons.js.map +1 -1
  76. package/dist/cli/lessons.test.js +38 -1
  77. package/dist/cli/lessons.test.js.map +1 -1
  78. package/dist/cli/plan.test.js +10 -8
  79. package/dist/cli/plan.test.js.map +1 -1
  80. package/dist/cli/sync-check.test.js +14 -2
  81. package/dist/cli/sync-check.test.js.map +1 -1
  82. package/dist/cli/types.d.ts +2 -1
  83. package/dist/cli/types.d.ts.map +1 -1
  84. package/dist/cli/types.js.map +1 -1
  85. package/dist/orchestrator/plugins/notion/config.d.ts.map +1 -1
  86. package/dist/orchestrator/plugins/notion/config.js +21 -17
  87. package/dist/orchestrator/plugins/notion/config.js.map +1 -1
  88. package/package.json +1 -1
  89. package/src/cli/adapters/claude-code.ts +1 -0
  90. package/src/cli/adapters/cursor.ts +6 -0
  91. package/src/cli/adapters/rules-dir-base.test.ts +41 -0
  92. package/src/cli/adapters/rules-dir-base.ts +47 -19
  93. package/src/cli/adapters/single-file-base.ts +63 -31
  94. package/src/cli/bootstrap-on-init.test.ts +12 -0
  95. package/src/cli/command-namespace.test.ts +17 -0
  96. package/src/cli/convoy/engine.git.test.ts +59 -0
  97. package/src/cli/convoy/engine.ts +44 -0
  98. package/src/cli/convoy/findings.test.ts +86 -0
  99. package/src/cli/convoy/findings.ts +129 -0
  100. package/src/cli/convoy/isolation.ts +2 -1
  101. package/src/cli/convoy/worktree.ts +12 -0
  102. package/src/cli/docs-accuracy.test.ts +42 -0
  103. package/src/cli/doctor.test.ts +101 -1
  104. package/src/cli/doctor.ts +75 -9
  105. package/src/cli/init.test.ts +27 -22
  106. package/src/cli/init.ts +62 -57
  107. package/src/cli/layers.test.ts +72 -1
  108. package/src/cli/layers.ts +52 -1
  109. package/src/cli/lessons.test.ts +48 -0
  110. package/src/cli/lessons.ts +27 -1
  111. package/src/cli/plan.test.ts +10 -8
  112. package/src/cli/sync-check.test.ts +16 -2
  113. package/src/cli/types.ts +2 -1
  114. package/src/orchestrator/agent-workflows/feature-implementation.md +1 -1
  115. package/src/orchestrator/agents/team-lead.agent.md +5 -5
  116. package/src/orchestrator/agents/testing-expert.agent.md +2 -2
  117. package/src/orchestrator/customizations/LESSONS-LEARNED.md +1 -1
  118. package/src/orchestrator/instructions/ai-optimization.instructions.md +6 -23
  119. package/src/orchestrator/instructions/general.instructions.md +22 -95
  120. package/src/orchestrator/plugins/astro/skills/astro-framework/SKILL.md +1 -3
  121. package/src/orchestrator/plugins/chrome-devtools/skills/browser-testing/SKILL.md +3 -5
  122. package/src/orchestrator/plugins/cloudflare/skills/cloudflare-platform/SKILL.md +2 -2
  123. package/src/orchestrator/plugins/contentful/skills/contentful-cms/SKILL.md +1 -1
  124. package/src/orchestrator/plugins/convex/skills/convex-database/SKILL.md +1 -3
  125. package/src/orchestrator/plugins/coolify/skills/coolify-deployment/SKILL.md +1 -1
  126. package/src/orchestrator/plugins/cypress/skills/cypress-testing/SKILL.md +1 -1
  127. package/src/orchestrator/plugins/drizzle/skills/drizzle-orm/SKILL.md +1 -1
  128. package/src/orchestrator/plugins/expo/skills/expo-development/SKILL.md +2 -2
  129. package/src/orchestrator/plugins/figma/skills/figma-design/SKILL.md +1 -3
  130. package/src/orchestrator/plugins/hetzner/skills/hetzner-cloud/SKILL.md +1 -1
  131. package/src/orchestrator/plugins/jira/skills/jira-management/SKILL.md +1 -3
  132. package/src/orchestrator/plugins/linear/skills/linear-task-management/SKILL.md +1 -3
  133. package/src/orchestrator/plugins/netlify/skills/netlify-deployment/SKILL.md +2 -2
  134. package/src/orchestrator/plugins/nextjs/skills/nextjs-framework/SKILL.md +13 -6
  135. package/src/orchestrator/plugins/notion/config.ts +21 -17
  136. package/src/orchestrator/plugins/notion/skills/notion-knowledge-management/SKILL.md +8 -16
  137. package/src/orchestrator/plugins/nx/skills/nx-workspace/SKILL.md +2 -4
  138. package/src/orchestrator/plugins/playwright/skills/playwright-testing/SKILL.md +1 -3
  139. package/src/orchestrator/plugins/prisma/skills/prisma-database/SKILL.md +1 -3
  140. package/src/orchestrator/plugins/resend/skills/resend-email/SKILL.md +2 -2
  141. package/src/orchestrator/plugins/sanity/skills/sanity-cms/SKILL.md +1 -3
  142. package/src/orchestrator/plugins/sentry/skills/sentry-monitoring/SKILL.md +1 -1
  143. package/src/orchestrator/plugins/slack/skills/slack-notifications/SKILL.md +1 -3
  144. package/src/orchestrator/plugins/strapi/skills/strapi-cms/SKILL.md +1 -3
  145. package/src/orchestrator/plugins/stripe/skills/stripe-payments/SKILL.md +4 -4
  146. package/src/orchestrator/plugins/supabase/skills/supabase-database/SKILL.md +3 -5
  147. package/src/orchestrator/plugins/teams/skills/teams-notifications/SKILL.md +1 -3
  148. package/src/orchestrator/plugins/trello/skills/trello-task-management/SKILL.md +1 -1
  149. package/src/orchestrator/plugins/turborepo/skills/turborepo-monorepo/SKILL.md +15 -88
  150. package/src/orchestrator/plugins/vercel/skills/vercel-deployment/SKILL.md +2 -2
  151. package/src/orchestrator/plugins/vitest/skills/vitest-testing/SKILL.md +17 -150
  152. package/src/orchestrator/prompts/assess-complexity.prompt.md +1 -0
  153. package/src/orchestrator/prompts/create-skill.prompt.md +13 -67
  154. package/src/orchestrator/prompts/fix-convoy.prompt.md +1 -0
  155. package/src/orchestrator/prompts/fix-prd.prompt.md +1 -0
  156. package/src/orchestrator/prompts/generate-prd.prompt.md +1 -0
  157. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +2 -2
  158. package/src/orchestrator/prompts/validate-convoy.prompt.md +1 -0
  159. package/src/orchestrator/prompts/validate-prd.prompt.md +1 -0
  160. package/src/orchestrator/skills/accessibility-standards/REFERENCE.md +17 -12
  161. package/src/orchestrator/skills/accessibility-standards/SKILL.md +1 -1
  162. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -5
  163. package/src/orchestrator/skills/agent-hooks/SKILL.md +8 -6
  164. package/src/orchestrator/skills/api-patterns/SKILL.md +1 -1
  165. package/src/orchestrator/skills/code-commenting/SKILL.md +1 -1
  166. package/src/orchestrator/skills/context-map/REFERENCE.md +0 -2
  167. package/src/orchestrator/skills/context-map/SKILL.md +2 -2
  168. package/src/orchestrator/skills/data-engineering/REFERENCE.md +3 -9
  169. package/src/orchestrator/skills/data-engineering/SKILL.md +9 -16
  170. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  171. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +4 -4
  172. package/src/orchestrator/skills/documentation-standards/SKILL.md +4 -2
  173. package/src/orchestrator/skills/fast-review/REFERENCE.md +0 -2
  174. package/src/orchestrator/skills/fast-review/SKILL.md +5 -5
  175. package/src/orchestrator/skills/frontend-design/REFERENCE.md +6 -28
  176. package/src/orchestrator/skills/frontend-design/SKILL.md +19 -9
  177. package/src/orchestrator/skills/git-workflow/SKILL.md +1 -1
  178. package/src/orchestrator/skills/memory-merger/SKILL.md +13 -15
  179. package/src/orchestrator/skills/observability-logging/SKILL.md +1 -1
  180. package/src/orchestrator/skills/orchestration-protocols/REFERENCE.md +5 -9
  181. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +6 -6
  182. package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +0 -4
  183. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +1 -1
  184. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +0 -2
  185. package/src/orchestrator/skills/performance-optimization/SKILL.md +2 -2
  186. package/src/orchestrator/skills/project-consistency/SKILL.md +2 -2
  187. package/src/orchestrator/skills/project-consistency/TEMPLATES.md +0 -4
  188. package/src/orchestrator/skills/react-development/SKILL.md +3 -3
  189. package/src/orchestrator/skills/security-hardening/SKILL.md +5 -5
  190. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +0 -2
  191. package/src/orchestrator/skills/self-improvement/SKILL.md +1 -1
  192. package/src/orchestrator/skills/seo-patterns/SKILL.md +1 -1
  193. package/src/orchestrator/skills/session-checkpoints/CHECKPOINT-TEMPLATE.md +0 -2
  194. package/src/orchestrator/skills/session-checkpoints/SKILL.md +1 -1
  195. package/src/orchestrator/skills/team-lead-reference/SKILL.md +1 -1
  196. package/src/orchestrator/skills/technical-writing/SKILL.md +8 -13
  197. package/src/orchestrator/skills/testing-workflow/SKILL.md +6 -6
  198. package/src/orchestrator/skills/typescript-best-practices/SKILL.md +1 -1
  199. package/src/orchestrator/skills/unslop/SKILL.md +1 -1
  200. package/src/orchestrator/skills/validation-gates/REFERENCE.md +6 -31
  201. package/src/orchestrator/skills/validation-gates/SKILL.md +12 -26
  202. package/src/orchestrator/skills/writing-for-agents/SKILL.md +2 -2
  203. package/src/orchestrator/skills/documentation-standards/WRITING-GUIDE.md +0 -39
  204. package/src/orchestrator/skills/frontend-design/COMPONENTS.md +0 -113
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: stripe-payments
3
- description: "Stripe payment integration patterns, Checkout Sessions, billing/subscriptions, Connect platforms, and API best practices. Use when building, modifying, or reviewing any Stripe integration — including accepting payments, building marketplaces, setting up subscriptions, or implementing secure key handling."
3
+ description: "Stripe integration rules: API selection, Checkout Sessions, subscriptions, Connect, webhooks and key handling. Use when building, changing or reviewing a Stripe integration."
4
4
  ---
5
5
 
6
6
  # Stripe Payments
7
7
 
8
- Latest API version: **2026-03-25.dahlia**. Pin it explicitly on the client unless told otherwise.
8
+ Read the API version before writing code: the account's pinned version (Workbench, or the `Stripe-Version` header on any response) and the Stripe changelog (below) for anything newer. Pin the chosen version explicitly on the client unless told otherwise.
9
9
 
10
10
  ## Never use
11
11
 
@@ -23,10 +23,10 @@ Charges API, Sources API, Tokens API, legacy Card Element, Payment Element in ca
23
23
 
24
24
  - Verify webhook signatures against the **raw** request body (`await request.text()`) — a parsed JSON body fails verification.
25
25
  - Restricted keys (`rk_`) over secret keys (`sk_`); neither ever ships client-side (use ephemeral keys). Always pass `state` in Connect OAuth.
26
- - Stripe.js is evergreen, biannual, and hard-paired to its API version — no override: `https://js.stripe.com/dahlia/stripe.js`. Java/Go/.NET SDKs also fix the version to the release; bump the package instead of setting `apiVersion`.
26
+ - Stripe.js is versioned by release name in its URL (`https://js.stripe.com/<release>/stripe.js`) and hard-paired to that release's API version — no override. Java/Go/.NET SDKs also fix the version to the release; bump the package instead of setting `apiVersion`.
27
27
  - Store Stripe object IDs in columns accommodating 255 chars with case-sensitive collation.
28
28
  - Breaking changes to grep for: `paymentIntent.charges` removed 2022-11-15 → `stripe.charges.retrieve(pi.latest_charge)`; `invoice.lines.data` → `stripe.invoices.listLineItems()` 2023-08-16.
29
- - Test locally with `stripe listen --forward-to localhost:3000/api/webhooks` and `stripe trigger <event> --api-version 2026-03-25.dahlia`; probe a new version with the `Stripe-Version` header before promoting it to default.
29
+ - Test locally with `stripe listen --forward-to localhost:3000/api/webhooks` and `stripe trigger <event> --api-version <version>`; probe a new version with the `Stripe-Version` header before promoting it to default.
30
30
  - `stripe plugin install projects` then `stripe projects init` writes `stripe-project.json` and a `.stripe/` directory of local skills — prefer those local skills afterwards.
31
31
 
32
32
  Docs: [changelog](https://docs.stripe.com/changelog) · [integration options](https://docs.stripe.com/payments/payment-methods/integration-options) · [go-live checklist](https://docs.stripe.com/get-started/checklist/go-live)
@@ -1,10 +1,8 @@
1
1
  ---
2
2
  name: supabase-database
3
- description: "Generates Supabase database migrations, writes RLS policies with auth.uid(), configures auth integration, and generates TypeScript types. Use when creating tables, writing migrations, configuring RLS, or implementing Supabase auth."
3
+ description: "Supabase migrations, RLS policies, auth integration and generated TypeScript types. Use when creating Supabase tables or migrations, writing RLS policies, or wiring Supabase auth."
4
4
  ---
5
5
 
6
- <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
7
-
8
6
  # Supabase Database
9
7
 
10
8
  Project schema, roles, migration history, auth flow, and key files: `.opencastle/stack/supabase-config.md`. Docs: https://supabase.com/docs
@@ -14,7 +12,7 @@ Project schema, roles, migration history, auth flow, and key files: `.opencastle
14
12
  - **`ENABLE ROW LEVEL SECURITY` with no policy denies everything.** Enabling and adding policies must land in the same migration.
15
13
  - Policies are per-operation. `FOR SELECT USING (...)` does not cover writes; `INSERT` needs `WITH CHECK`, not `USING`.
16
14
  - `auth.uid()` is the owner check (`auth.uid() = id`). It is `NULL` for the `anon` role, so any policy relying on it silently blocks anonymous access.
17
- - Test every policy against **all three** roles — `anon`, `user`, `admin`. A policy that works as your own user tells you nothing about `anon`.
15
+ - Policies target the Postgres roles `anon`, `authenticated` and `service_role` (which bypasses RLS). Test every policy as `anon` and as `authenticated`, plus any app-level role your policies check. A policy that works as your own user tells you nothing about `anon`.
18
16
  - Reference `auth.users(id)` with `ON DELETE CASCADE` on profile-style tables, or deleted users leave orphans.
19
17
 
20
18
  Confirm RLS coverage before shipping:
@@ -25,7 +23,7 @@ SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = 'public';
25
23
 
26
24
  ## Migration workflow
27
25
 
28
- 1. Name migrations `YYYYMMDD_add_profiles.sql`; comment intent and rollback considerations inline.
26
+ 1. Create the file with `supabase migration new add_profiles` (it writes `supabase/migrations/<14-digit timestamp>_add_profiles.sql`); comment intent and rollback considerations inline.
29
27
  2. Apply to a local/ephemeral DB; run smoke tests plus per-role RLS checks.
30
28
  3. Review the SQL for destructive actions (table drops, column rewrites) — those need a backfill script and phased rollout, never a single migration.
31
29
  4. Re-run in CI against a test replica with the full suite.
@@ -1,10 +1,8 @@
1
1
  ---
2
2
  name: teams-notifications
3
- description: "Microsoft Teams MCP integration for agent-to-human notifications and bi-directional communication. Use when agents need to post progress updates, request approvals, or read user responses via Teams channels and chats."
3
+ description: "Microsoft Teams MCP for agent-to-human messages: progress updates, approval requests and reading replies. Use when an agent needs to notify people or get an approval through Teams."
4
4
  ---
5
5
 
6
- <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
7
-
8
6
  # Teams Notifications
9
7
 
10
8
  ## MCP Server
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: trello-task-management
3
- description: "Create and manage Trello cards, checklists, and boards for kanban workflows. Use when the user says: 'create a kanban board', 'add a task card', 'move card to sprint', or 'track project board'."
3
+ description: "Trello cards, checklists and boards for kanban tracking. Use when creating or moving Trello cards, adding checklists, or tracking work on a Trello board."
4
4
  ---
5
5
 
6
6
  # Task Management with Trello
@@ -1,42 +1,23 @@
1
1
  ---
2
2
  name: turborepo-monorepo
3
- description: "Configure pipelines, set up local/remote caching, and run scoped tasks in a Turborepo monorepo. Use when you say: 'enable remote caching', 'optimize pipeline inputs/outputs', or 'filter builds to affected packages'."
3
+ description: "Turborepo task pipelines, caching and package filtering. Use when editing turbo.json, running tasks for changed or filtered packages, or debugging cache misses and remote caching."
4
4
  ---
5
5
 
6
- <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
7
-
8
6
  # Turborepo Monorepo
9
7
 
10
8
  ## Commands
11
9
 
12
- ### Running Tasks
13
-
14
10
  ```bash
15
- turbo run build # Build all packages
16
- turbo run test # Test all packages
17
- turbo run lint # Lint all packages
18
- turbo run build --filter=web # Build specific package
19
- turbo run build --filter=./apps/* # Build all apps
20
- turbo run build --filter=...[HEAD~1] # Only affected since last commit
11
+ turbo run build # Build all packages
12
+ turbo run build --filter=web # One package
13
+ turbo run build --filter=./apps/* # All apps
14
+ turbo run build test lint --affected # Only packages changed vs the default branch (CI)
15
+ turbo run build --dry-run # Preview what would run
16
+ turbo run build --graph # Visualize task graph
17
+ turbo run build --force # Ignore cache, rebuild all
21
18
  ```
22
19
 
23
- ### Common Patterns
24
-
25
- ```bash
26
- turbo run build test lint # Run multiple tasks
27
- turbo run build --dry-run # Preview what would run
28
- turbo run build --graph # Visualize task graph
29
- turbo run build --force # Ignore cache, rebuild all
30
- turbo run build --concurrency=4 # Limit parallelism
31
- ```
32
-
33
- ### Forbidden Commands
34
-
35
- ```bash
36
- # NEVER use these directly — always go through turbo:
37
- npm run build # Skips caching and parallelism
38
- cd apps/web && npm test # Skips dependency resolution
39
- ```
20
+ Run tasks through `turbo run` (or a root script that wraps it). `cd apps/web && npm test` skips caching and dependency order.
40
21
 
41
22
  ## Pipeline Configuration (turbo.json)
42
23
 
@@ -63,69 +44,15 @@ cd apps/web && npm test # Skips dependency resolution
63
44
  }
64
45
  ```
65
46
 
66
- ### Key Concepts
67
-
68
47
  - `^build` — run `build` in dependencies first (topological)
69
- - `dependsOn` — declare task dependencies
70
- - `outputs` — files to cache (miss = rebuild)
71
- - `inputs` — files to hash for cache key (default: all tracked files)
72
- - `cache: false` — never cache (use for `dev`, `start`)
73
- - `persistent: true` — long-running tasks (dev servers)
48
+ - `outputs` — files to cache; leave them out and a cache hit restores no files
49
+ - `inputs` — files hashed for the cache key (default: all tracked files in the package)
50
+ - `cache: false` + `persistent: true` — long-running tasks (dev servers)
74
51
 
75
52
  ## Caching
76
53
 
77
- ### Local Cache
78
-
79
- Turborepo caches task outputs automatically in `node_modules/.cache/turbo`. Cache keys are computed from:
80
-
81
- 1. Task inputs (source files)
82
- 2. Environment variables
83
- 3. Dependencies' build outputs
84
- 4. `turbo.json` configuration
85
-
86
- ### Remote Cache
87
-
88
- ```bash
89
- turbo login # Authenticate
90
- turbo link # Link project to remote cache
91
- turbo run build --remote-only # Force remote cache usage
92
- ```
93
-
94
- - Shares cache across CI and team members
95
- - Vercel Remote Cache or self-hosted (Ducktape, TurboCache)
96
- - Set `TURBO_TOKEN` and `TURBO_TEAM` in CI environment
97
-
98
- ## Quick Workflow: Setup remote caching in CI
99
- 1. Add `TURBO_TOKEN` and `TURBO_TEAM` to your CI secrets.
100
- 2. Locally run `turbo login` and `turbo link` to verify the project is linked.
101
- 3. Add `turbo run build --remote` to the CI pipeline and watch for cache hit/miss logs.
102
- 4. If cache misses persist: verify `inputs`/`outputs` in `turbo.json`, stable env vars, then re-run.
103
-
104
- **Validation (recommended):** run `turbo run build --dry-run` locally or in CI to preview the task graph and catch misconfigured inputs/outputs before executing.
105
-
106
-
107
- ## Package Workspace Structure
108
-
109
- ```
110
- monorepo/
111
- ├── turbo.json
112
- ├── package.json # Root workspace config
113
- ├── apps/
114
- │ ├── web/ # Next.js app
115
- │ └── docs/ # Documentation site
116
- ├── packages/
117
- │ ├── ui/ # Shared UI components
118
- │ ├── config/ # Shared config (ESLint, TS)
119
- │ └── utils/ # Shared utilities
120
- ```
121
-
122
- ## Best Practices
54
+ The local cache lives in `.turbo/cache` (Turborepo 2.0+). Keys hash task inputs, declared env vars, dependencies' outputs and `turbo.json`. An env var the build reads but `env` does not declare causes stale hits; one that changes every run causes constant misses.
123
55
 
124
- - Always use `turbo run` instead of directly invoking package scripts
125
- - Define `outputs` for every cacheable task — missing outputs mean missing cache
126
- - Use `--filter` to scope commands to affected packages
127
- - Set `inputs` to narrow cache keys and avoid unnecessary rebuilds
128
- - Use `--dry-run` to debug pipeline configuration
129
- - Add `TURBO_TOKEN` and `TURBO_TEAM` to CI for remote caching
130
- - Never commit `.turbo/` or `node_modules/.cache/turbo`
56
+ Remote cache: `turbo login` and `turbo link` locally; in CI set `TURBO_TOKEN` and `TURBO_TEAM` and a plain `turbo run` reads and writes it. Persistent misses → check `inputs`/`outputs`/`env` in `turbo.json`, then compare runs with `--dry-run=json`.
131
57
 
58
+ Never commit `.turbo/`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: vercel-deployment
3
- description: "Vercel deployment workflows, environment management, domain configuration, and build troubleshooting. Use when deploying, checking deployment status, reviewing build logs, or managing environments."
3
+ description: "Vercel deployments, environments, domains and build troubleshooting through the Vercel MCP. Use when deploying to Vercel, checking a deployment, reading its build or runtime logs, or managing its environments."
4
4
  ---
5
5
 
6
6
  # Vercel Deployment
@@ -14,7 +14,7 @@ Branch → Environment mapping:
14
14
  | Branch pattern | Environment |
15
15
  |----------------|-------------|
16
16
  | `main` | Production deployment (auto) |
17
- | `feature/*`, `fix/*` | Preview deployment (auto) |
17
+ | Any other branch (`feat/*`, `fix/*`, …) | Preview deployment (auto) |
18
18
 
19
19
  ## MCP Tools
20
20
 
@@ -1,162 +1,29 @@
1
1
  ---
2
2
  name: vitest-testing
3
- description: "Vitest unit and integration testing patterns, commands, mocking (vi.mock), and coverage. Use when writing .test.ts files, configuring the test runner, or adding coverage thresholds."
3
+ description: "Vitest gotchas for mocking, timers, type tests and coverage. Use when writing or debugging Vitest tests, configuring vitest.config, or a coverage threshold fails."
4
4
  ---
5
5
 
6
- <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
7
-
8
6
  # Vitest Testing
9
7
 
10
- For project-specific test configuration, see `.opencastle/stack/testing-config.md`.
11
-
12
- ## Commands
13
-
14
- ```bash
15
- npx vitest # Run in watch mode
16
- npx vitest run # Run once (CI)
17
- npx vitest run --coverage # Run with coverage report
18
- npx vitest run src/utils/ # Run specific directory
19
- npx vitest run auth.test.ts # Run specific file
20
- npx vitest run -t "should validate" # Filter by test name
21
- npx vitest --ui # Open Vitest UI
22
- npx vitest --reporter=json # JSON output for CI
23
- npx vitest typecheck # Run type-checking tests
24
- ```
25
-
26
- ## Test Structure
27
-
28
- ### File Naming
29
-
30
- ```
31
- src/
32
- ├── utils/
33
- │ ├── format.ts
34
- │ └── format.test.ts # Co-located test
35
- ├── components/
36
- │ ├── Button.tsx
37
- │ └── Button.test.tsx # Component test
38
- └── __tests__/ # Integration tests
39
- └── auth-flow.test.ts
40
- ```
41
-
42
- ### Writing Tests
43
-
44
- ```typescript
45
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
46
- import { formatPrice } from './format';
47
-
48
- describe('formatPrice', () => {
49
- it('should format USD prices', () => {
50
- expect(formatPrice(9.99, 'USD')).toBe('$9.99');
51
- });
52
-
53
- it('should handle zero', () => {
54
- expect(formatPrice(0, 'USD')).toBe('$0.00');
55
- });
56
-
57
- it('should throw for negative values', () => {
58
- expect(() => formatPrice(-1, 'USD')).toThrow('Price cannot be negative');
59
- });
60
- });
61
- ```
62
-
63
- ## Mocking
64
-
65
- ### Module Mocking
66
-
67
- ```typescript
68
- import { vi, describe, it, expect } from 'vitest';
69
-
70
- // Mock entire module
71
- vi.mock('./database', () => ({
72
- getUser: vi.fn().mockResolvedValue({ id: '1', name: 'Alice' }),
73
- }));
74
-
75
- // Mock specific export
76
- vi.mock('./config', async (importOriginal) => {
77
- const original = await importOriginal<typeof import('./config')>();
78
- return { ...original, API_URL: 'http://test-api.example.com' };
79
- });
80
- ```
81
-
82
- ### Spy and Stub
83
-
84
- ```typescript
85
- import { vi, describe, it, expect } from 'vitest';
86
-
87
- describe('notifications', () => {
88
- it('should call the API', async () => {
89
- const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
90
- new Response(JSON.stringify({ ok: true }))
91
- );
92
-
93
- await sendNotification('Hello');
94
-
95
- expect(fetchSpy).toHaveBeenCalledWith('/api/notify', expect.objectContaining({
96
- method: 'POST',
97
- }));
98
-
99
- fetchSpy.mockRestore();
100
- });
101
- });
102
- ```
103
-
104
- ### Timer Mocking
105
-
106
- ```typescript
107
- import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
108
-
109
- describe('debounce', () => {
110
- beforeEach(() => vi.useFakeTimers());
111
- afterEach(() => vi.useRealTimers());
112
-
113
- it('should debounce calls', () => {
114
- const fn = vi.fn();
115
- const debounced = debounce(fn, 300);
116
-
117
- debounced();
118
- debounced();
119
- debounced();
8
+ Project test configuration: `.opencastle/stack/testing-config.md`. Coverage thresholds, environment and setup files: the project's `vitest.config.*` (or the `test` block of `vite.config.*`) — read them, never assume a number.
120
9
 
121
- expect(fn).not.toHaveBeenCalled();
122
- vi.advanceTimersByTime(300);
123
- expect(fn).toHaveBeenCalledOnce();
124
- });
125
- });
126
- ```
10
+ ## Running
127
11
 
128
- ## Configuration (vitest.config.ts)
12
+ - `vitest` alone starts **watch mode** in a terminal and never exits. Agents run `vitest run [file] [-t "name"]`.
13
+ - Type tests (`*.test-d.ts`, `expectTypeOf`) run with `vitest --typecheck` (or `vitest run --typecheck`). The old `vitest typecheck` subcommand is gone since 1.0.
14
+ - Coverage: `vitest run --coverage`. Below threshold → read the uncovered lines in the text report, add tests for those branches, re-run.
129
15
 
130
- ```typescript
131
- import { defineConfig } from 'vitest/config';
16
+ ## Mocking gotchas
132
17
 
133
- export default defineConfig({
134
- test: {
135
- globals: true, // Use describe/it/expect without imports
136
- environment: 'jsdom', // 'node' | 'jsdom' | 'happy-dom'
137
- include: ['src/**/*.test.{ts,tsx}'],
138
- coverage: {
139
- provider: 'v8',
140
- reporter: ['text', 'json', 'html'],
141
- include: ['src/**/*.{ts,tsx}'],
142
- exclude: ['src/**/*.test.{ts,tsx}', 'src/**/*.d.ts'],
143
- thresholds: {
144
- branches: 80,
145
- functions: 80,
146
- lines: 80,
147
- statements: 80,
148
- },
149
- },
150
- setupFiles: ['./src/test-setup.ts'],
151
- },
152
- });
153
- ```
18
+ - **`vi.mock()` is hoisted** above every import, so its factory cannot use variables declared in the file. Declare them with `vi.hoisted()`:
154
19
 
155
- ## Workflow
20
+ ```ts
21
+ const { getUser } = vi.hoisted(() => ({ getUser: vi.fn() }))
22
+ vi.mock('./database', () => ({ getUser }))
23
+ ```
156
24
 
157
- 1. Create `*.test.ts` adjacent to the source file.
158
- 2. Write focused unit tests (happy path + edge cases). Use `vi.mock()` before imports; restore in `afterEach` with `vi.restoreAllMocks()`.
159
- 3. Run `npx vitest run <file>` — fix failures.
160
- 4. If tests fail: run `npx vitest run <file> --reporter=verbose` to inspect, fix, re-run.
161
- 5. Coverage validation: run `npx vitest run --coverage --reporter=json` (CI) or `npx vitest run --coverage --reporter=text` (local) to generate coverage reports. Inspect `coverage`/`coverage-final.json` or the human-readable summary to find uncovered files/branches. If coverage is below thresholds, add targeted tests for uncovered branches, then re-run `npx vitest run --coverage` until thresholds pass.
162
- 6. Commit tests alongside source changes.
25
+ - Partial mock: `vi.mock('./config', async (importOriginal) => ({ ...(await importOriginal<typeof import('./config')>()), API_URL: 'http://test' }))`.
26
+ - `vi.spyOn(namespace, 'fn')` on a module's export misses calls made inside that module, and fails in Browser Mode; mock the module instead.
27
+ - **`vi.restoreAllMocks()` only restores `vi.spyOn` spies** (Vitest 3+). It does not reset `vi.fn()` call history; use `vi.clearAllMocks()`, or `restoreMocks` / `clearMocks` in the config, so state cannot leak between tests.
28
+ - Fake timers: `vi.useFakeTimers()` in `beforeEach`, `vi.useRealTimers()` in `afterEach`; advance with `vi.advanceTimersByTime(ms)` or `await vi.advanceTimersByTimeAsync(ms)` when promises are involved.
29
+ - One file needs a DOM in a `node` project: `// @vitest-environment jsdom` on its first line.
@@ -2,6 +2,7 @@
2
2
  description: 'Size the work in a PRD, score each workstream, and say whether to plan it in one go or as groups planned side by side. Returns JSON.'
3
3
  agent: 'Reviewer'
4
4
  output: json
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -50,53 +50,28 @@ Agents load a skill when a task matches its `description`, so the description is
50
50
 
51
51
  ### Step 3: Create the Skill File
52
52
 
53
- Create `.opencastle/skills/<skill-name>/SKILL.md`.
54
-
55
- Use this template:
53
+ Create `.opencastle/skills/<skill-name>/SKILL.md`. Load the **writing-for-agents** skill first; it holds the levers this step applies.
56
54
 
57
55
  ```markdown
58
56
  ---
59
57
  name: <skill-name>
60
- description: "<Verb1> X, <verb2> Y, and <verb3> Z. Use when <scenario1>, <scenario2>, or <scenario3>."
58
+ description: "<What the skill is for, in third person>. Use when <situation>, <situation> or <situation>."
61
59
  ---
62
60
 
63
61
  # <Display Name>
64
62
 
65
- ## Workflow
66
-
67
- 1. **<Step>** — <Action>
68
- - Checkpoint: <what to verify before proceeding>
69
- - Recovery: <what to do on failure>
70
- 2. **<Step>** — <Action>
71
- - Checkpoint: <validation>
72
- 3. **<Step>** — <Action>
73
- - Fail → fix → re-run from step N.
74
-
75
- ## <Domain Section>
76
-
77
- <Content organized by topic. Use tables, code blocks, and checklists.>
78
-
79
- ## <Executable Example>
80
-
81
- ```<lang>
82
- // Concrete, copy-paste-ready code (5-15 lines)
63
+ <What an agent gets wrong without this skill: rules, gotchas, exact commands. Numbered steps where order matters, each ending on a check it can verify.>
83
64
  ```
84
65
 
85
- ## Anti-Patterns
66
+ **Description** — the pointer that decides when the skill loads:
86
67
 
87
- | Anti-pattern | Fix |
88
- |-------------|-----|
89
- | <Bad pattern> | <What to do instead> |
68
+ - What the skill is for, then when to use it, in third person ("Checks…", "Use when…").
69
+ - One trigger per branch: each situation that should load it, named once, not a list of synonyms.
70
+ - No workflow summary: an agent that reads the steps in the description may follow them instead of the body.
71
+ - No "Trigger terms:" tail; fold the real triggers into the "Use when" sentence.
72
+ - One line, aim for 250 characters or fewer.
90
73
 
91
- ## References
92
-
93
- | Resource | Purpose |
94
- |----------|--------|
95
- | [REFERENCE.md](./REFERENCE.md) | <Extended examples, schemas, large tables> |
96
- | **<related-skill>** skill | <What it contributes> |
97
- ```
98
-
99
- If skill has large code examples (>30 lines), schema tables, or verbose reference material, create companion `REFERENCE.md` in same directory; link to it from SKILL.md. Keep SKILL.md as lean operational overview. Companion files must start with backlink: `> Parent: [SKILL.md](./SKILL.md)`.
74
+ **Body** — as short as the knowledge allows, and under 500 lines. Material only some tasks need goes in a companion file beside `SKILL.md` (e.g. `REFERENCE.md`), linked from `SKILL.md` with the condition for reading it.
100
75
 
101
76
  ### Step 4: Compile the Skill
102
77
 
@@ -109,46 +84,17 @@ If skill has large code examples (>30 lines), schema tables, or verbose referenc
109
84
  - [ ] File created at `.opencastle/skills/<skill-name>/SKILL.md`
110
85
  - [ ] Frontmatter has `name` and `description` fields; `name` equals the directory name
111
86
  - [ ] Description is single line (no line breaks)
112
- - [ ] Content follows template structure
113
87
  - [ ] No overlap with existing skills
114
88
  - [ ] `npx opencastle sync --check` passes — the compiled copies match the source
115
89
  - [ ] `npx opencastle doctor` passes — it checks that every script and path a team skill names exists
116
- - [ ] Run `npx tessl skill review <path>` — target 100 score (see Scoring Criteria below)
117
-
118
- ## Scoring Criteria
119
-
120
- Skills evaluated by `npx tessl skill review` across 8 criteria (3 pts each = 24 total). Target 100.
121
-
122
- ### Description (frontmatter `description` field)
123
-
124
- | Criterion | 3/3 Pattern | Common Pitfall |
125
- |-----------|------------|----------------|
126
- | **Specificity** | List 3+ concrete actions as verbs: "Creates X, validates Y, and manages Z" | Vague "covers" or "handles" without listing what |
127
- | **Trigger terms** | Natural phrases a user would say — broad synonyms and variations | Too specialized; missing common phrasings |
128
- | **Completeness** | Explicit `Use when...` clause with 3+ trigger scenarios | Missing when-to-use guidance |
129
- | **Distinctiveness** | Unique niche; terms unlikely to collide with other skills | Generic terms that overlap with adjacent skills |
130
-
131
- **Formula:** `"<Verb1> X, <verb2> Y, and <verb3> Z. Use when <scenario1>, <scenario2>, or <scenario3>."`
132
-
133
- ### Content (SKILL.md body)
134
-
135
- | Criterion | 3/3 Pattern | Common Pitfall |
136
- |-----------|------------|----------------|
137
- | **Conciseness** | Every line earns its place. No info Claude already knows. Tables over prose. | Explaining obvious concepts, redundant sections, verbose anti-patterns with "Why" columns |
138
- | **Actionability** | ≥1 executable code example (copy-paste ready), concrete CLI commands, specific thresholds | Deferring to other skills without fallback, abstract guidance without examples |
139
- | **Workflow clarity** | Numbered steps with validation checkpoints, explicit error recovery, feedback loops (fail → fix → re-run) | Implied sequence without numbers, no checkpoints between steps, missing recovery path |
140
- | **Progressive disclosure** | SKILL.md = lean overview. Bulky content (>30-line examples, large tables, schemas) in REFERENCE.md. External refs organized in a References section. | Everything inline making the file too heavy, or too much deferred leaving SKILL.md hollow |
90
+ - [ ] Description follows the rules in Step 3
141
91
 
142
92
  ## Quality Guidelines
143
93
 
144
94
  - **Be prescriptive** — "Use `fetchPlaces()` from `libs/queries`" beats "use the query library"
145
- - **Include executable examples** — At least one copy-paste-ready code block (5-15 lines). CLI commands with real flags, not placeholders
95
+ - **Exact commands** — CLI commands with real flags, not placeholders
146
96
  - **Keep it scannable** — Tables over prose. Headings, bullets, code blocks. Agents parse structure, not paragraphs
147
- - **Number your workflows** — Every multi-step process needs numbered steps, checkpoints ("Gate: X passes"), and recovery ("Fail → fix → re-run step N")
97
+ - **Number your workflows** — Where order matters: numbered steps, each ending on a check, with the recovery on failure
148
98
  - **Don't explain what Claude knows** — Skip "what is X" explanations, obvious anti-pattern justifications, concept definitions. Jump straight to the rules
149
99
  - **Avoid duplication** — If rule exists in another skill or instruction file, reference it: "Load **security-hardening** skill for CSP configuration"
150
- - **Use REFERENCE.md for bulk** — Large code examples, schema tables, worked examples, template libraries go in companion `REFERENCE.md`. Link once from SKILL.md
151
100
  - **Stay stack-agnostic in process skills** — Use capability slot references ("the **database** skill" not "Supabase")
152
- - **Size target** — 80-200 lines in SKILL.md. Under 80 too thin; over 200 split content to REFERENCE.md. Over 300 split into multiple skills
153
- - **No standalone trigger-term sections** — Weave trigger terms naturally into description's `Use when...` clause
154
- - **Third-person voice in descriptions** — "Creates X" not "Create X" or "This skill creates X"
@@ -2,6 +2,7 @@
2
2
  description: 'Fix the problems found in a convoy task plan with targeted JSON patches. Goal is the plan as JSON, context is the list of problems.'
3
3
  agent: 'Team Lead (OpenCastle)'
4
4
  output: json
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -2,6 +2,7 @@
2
2
  description: 'Fix the issues a PRD review found. Goal is the PRD, context is the list of issues; answers with the whole corrected PRD.'
3
3
  agent: 'Team Lead (OpenCastle)'
4
4
  output: prd
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -2,6 +2,7 @@
2
2
  description: 'Write a Product Requirements Document (PRD) from a feature request. The convoy planner breaks the PRD into agent tasks.'
3
3
  agent: 'Team Lead (OpenCastle)'
4
4
  output: prd
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -64,8 +64,8 @@ All fixes must pass applicable gates before pushing:
64
64
  1. **Gate 1: Secret Scanning** — scan diff for API keys, tokens, passwords, connection strings — block immediately if found
65
65
  2. **Gate 2: Deterministic Checks** — run lint, test, and build for all affected projects (see the **codebase-tool** skill for commands) — all zero errors
66
66
  3. **Gate 3: Blast Radius Check** — verify changes are scoped to commented files only; flag any files modified outside the comment scope
67
- 4. **Gate 4: Fast Review** (MANDATORY) — single reviewer sub-agent validates the combined PR comment fixes
68
- 5. **Gate 5: Regression Testing** — run tests for all projects consuming modified files
67
+ 4. **Gate 5: Fast Review** (MANDATORY) — single reviewer sub-agent validates the combined PR comment fixes
68
+ 5. **Gate 8: Regression Testing** — run tests for all projects consuming modified files
69
69
 
70
70
  After all gates pass:
71
71
 
@@ -2,6 +2,7 @@
2
2
  description: 'Review a convoy spec for what code cannot check: missing dependencies, missing or redundant tasks. Answers with a JSON verdict.'
3
3
  agent: 'Reviewer'
4
4
  output: validation
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -2,6 +2,7 @@
2
2
  description: 'Check a PRD for the structure the convoy planner needs. Answers with a JSON verdict: valid, or the issues to fix.'
3
3
  agent: 'Reviewer'
4
4
  output: validation
5
+ pipeline: true
5
6
  ---
6
7
 
7
8
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
@@ -1,16 +1,25 @@
1
- > Parent: [SKILL.md](./SKILL.md)
2
-
3
1
  ## Composite Widgets & Form Error Handling (Reference)
4
2
 
3
+ Composite widgets (menu, listbox, tabs, grid) take one Tab stop and manage focus inside with the arrow keys. Use one of two patterns.
4
+
5
5
  ### Roving tabindex pattern
6
6
 
7
- Use when a composite widget (menu, listbox, tabs) manages focus internally.
7
+ Focus moves onto the items themselves.
8
8
 
9
- 1. Container receives `tabindex="0"` and keyboard handlers.
10
- 2. Children are `tabindex="-1"` except one `tabindex="0"` representing active item.
11
- 3. Arrow keys update `tabindex` values and call `.focus()` on the new active child.
9
+ 1. The focused item has `tabindex="0"`; every other item has `tabindex="-1"`. The container gets no `tabindex`.
10
+ 2. Arrow keys move `tabindex="0"` to the next item and call `.focus()` on it.
11
+ 3. Tabbing out and back returns to the item that last had focus.
12
12
 
13
- Example:
13
+ ```html
14
+ <div role="tablist" aria-label="Settings">
15
+ <button role="tab" id="tab-1" aria-selected="true" tabindex="0">Profile</button>
16
+ <button role="tab" id="tab-2" aria-selected="false" tabindex="-1">Billing</button>
17
+ </div>
18
+ ```
19
+
20
+ ### `aria-activedescendant` pattern
21
+
22
+ Focus stays on the container (`tabindex="0"`); `aria-activedescendant` names the `id` of the visually active child. Update the attribute on arrow navigation.
14
23
 
15
24
  ```html
16
25
  <div role="listbox" tabindex="0" aria-activedescendant="item-1">
@@ -19,13 +28,9 @@ Example:
19
28
  </div>
20
29
  ```
21
30
 
22
- ### `aria-activedescendant` pattern
23
-
24
- When focus remains on a container but a child is visually active, use `aria-activedescendant` referencing the active child's `id`. Update the attribute on arrow navigation.
25
-
26
31
  ### Form error handling
27
32
 
28
- - On validation error, add `aria-invalid="true"` and `aria-describedby="#error-id"` to the input.
33
+ - On validation error, add `aria-invalid="true"` and `aria-describedby="error-id"` to the input (an ID reference, no `#`).
29
34
  - Ensure the error element has role `alert` or is announced by screen readers when it appears.
30
35
  - Move focus to the first invalid control and programmatically announce error summary.
31
36