opencastle 0.32.4 → 0.32.6

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 (108) hide show
  1. package/README.md +13 -3
  2. package/bin/cli.mjs +2 -0
  3. package/dist/cli/bootstrap.js +1 -1
  4. package/dist/cli/bootstrap.js.map +1 -1
  5. package/dist/cli/bootstrap.test.js +16 -0
  6. package/dist/cli/bootstrap.test.js.map +1 -1
  7. package/dist/cli/init.test.js +38 -0
  8. package/dist/cli/init.test.js.map +1 -1
  9. package/dist/cli/stack-config-update.test.js +18 -0
  10. package/dist/cli/stack-config-update.test.js.map +1 -1
  11. package/dist/cli/stack-config.d.ts.map +1 -1
  12. package/dist/cli/stack-config.js +1 -0
  13. package/dist/cli/stack-config.js.map +1 -1
  14. package/dist/cli/types.d.ts +1 -1
  15. package/dist/cli/types.d.ts.map +1 -1
  16. package/dist/orchestrator/plugins/index.d.ts.map +1 -1
  17. package/dist/orchestrator/plugins/index.js +4 -0
  18. package/dist/orchestrator/plugins/index.js.map +1 -1
  19. package/dist/orchestrator/plugins/notion/config.d.ts +3 -0
  20. package/dist/orchestrator/plugins/notion/config.d.ts.map +1 -0
  21. package/dist/orchestrator/plugins/notion/config.js +46 -0
  22. package/dist/orchestrator/plugins/notion/config.js.map +1 -0
  23. package/dist/orchestrator/plugins/trello/config.d.ts +3 -0
  24. package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -0
  25. package/dist/orchestrator/plugins/trello/config.js +43 -0
  26. package/dist/orchestrator/plugins/trello/config.js.map +1 -0
  27. package/dist/orchestrator/plugins/types.d.ts +1 -1
  28. package/dist/orchestrator/plugins/types.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/cli/bootstrap.test.ts +21 -0
  31. package/src/cli/bootstrap.ts +1 -1
  32. package/src/cli/init.test.ts +46 -0
  33. package/src/cli/stack-config-update.test.ts +20 -0
  34. package/src/cli/stack-config.ts +1 -0
  35. package/src/cli/types.ts +1 -1
  36. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  37. package/src/orchestrator/agents/api-designer.agent.md +25 -34
  38. package/src/orchestrator/agents/architect.agent.md +40 -84
  39. package/src/orchestrator/agents/content-engineer.agent.md +29 -31
  40. package/src/orchestrator/agents/copywriter.agent.md +35 -60
  41. package/src/orchestrator/agents/data-expert.agent.md +24 -30
  42. package/src/orchestrator/agents/database-engineer.agent.md +26 -31
  43. package/src/orchestrator/agents/developer.agent.md +32 -34
  44. package/src/orchestrator/agents/devops-expert.agent.md +31 -26
  45. package/src/orchestrator/agents/documentation-writer.agent.md +29 -29
  46. package/src/orchestrator/agents/performance-expert.agent.md +36 -33
  47. package/src/orchestrator/agents/release-manager.agent.md +25 -34
  48. package/src/orchestrator/agents/researcher.agent.md +41 -95
  49. package/src/orchestrator/agents/reviewer.agent.md +24 -34
  50. package/src/orchestrator/agents/security-expert.agent.md +35 -39
  51. package/src/orchestrator/agents/seo-specialist.agent.md +25 -32
  52. package/src/orchestrator/agents/session-guard.agent.md +20 -79
  53. package/src/orchestrator/agents/team-lead.agent.md +50 -254
  54. package/src/orchestrator/agents/testing-expert.agent.md +37 -49
  55. package/src/orchestrator/agents/ui-ux-expert.agent.md +33 -39
  56. package/src/orchestrator/customizations/KNOWN-ISSUES.md +0 -1
  57. package/src/orchestrator/customizations/agents/skill-matrix.json +20 -4
  58. package/src/orchestrator/customizations/agents/skill-matrix.md +20 -0
  59. package/src/orchestrator/instructions/general.instructions.md +24 -84
  60. package/src/orchestrator/plugins/astro/SKILL.md +23 -179
  61. package/src/orchestrator/plugins/convex/SKILL.md +38 -12
  62. package/src/orchestrator/plugins/index.ts +4 -0
  63. package/src/orchestrator/plugins/netlify/SKILL.md +17 -13
  64. package/src/orchestrator/plugins/nextjs/SKILL.md +55 -261
  65. package/src/orchestrator/plugins/notion/SKILL.md +205 -0
  66. package/src/orchestrator/plugins/notion/config.ts +47 -0
  67. package/src/orchestrator/plugins/nx/SKILL.md +20 -72
  68. package/src/orchestrator/plugins/playwright/SKILL.md +5 -17
  69. package/src/orchestrator/plugins/slack/SKILL.md +28 -190
  70. package/src/orchestrator/plugins/teams/SKILL.md +10 -140
  71. package/src/orchestrator/plugins/trello/SKILL.md +151 -0
  72. package/src/orchestrator/plugins/trello/config.ts +44 -0
  73. package/src/orchestrator/plugins/types.ts +1 -1
  74. package/src/orchestrator/plugins/vitest/SKILL.md +2 -2
  75. package/src/orchestrator/prompts/bug-fix.prompt.md +25 -63
  76. package/src/orchestrator/prompts/implement-feature.prompt.md +29 -66
  77. package/src/orchestrator/prompts/quick-refinement.prompt.md +31 -66
  78. package/src/orchestrator/skills/accessibility-standards/SKILL.md +50 -105
  79. package/src/orchestrator/skills/agent-hooks/SKILL.md +60 -110
  80. package/src/orchestrator/skills/agent-memory/SKILL.md +44 -93
  81. package/src/orchestrator/skills/api-patterns/SKILL.md +20 -68
  82. package/src/orchestrator/skills/code-commenting/SKILL.md +49 -101
  83. package/src/orchestrator/skills/context-map/SKILL.md +47 -88
  84. package/src/orchestrator/skills/data-engineering/SKILL.md +27 -74
  85. package/src/orchestrator/skills/decomposition/SKILL.md +50 -98
  86. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +44 -107
  87. package/src/orchestrator/skills/documentation-standards/SKILL.md +28 -89
  88. package/src/orchestrator/skills/fast-review/SKILL.md +51 -276
  89. package/src/orchestrator/skills/frontend-design/SKILL.md +53 -163
  90. package/src/orchestrator/skills/git-workflow/SKILL.md +18 -54
  91. package/src/orchestrator/skills/memory-merger/SKILL.md +51 -88
  92. package/src/orchestrator/skills/observability-logging/SKILL.md +29 -75
  93. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +58 -117
  94. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +65 -140
  95. package/src/orchestrator/skills/performance-optimization/SKILL.md +21 -85
  96. package/src/orchestrator/skills/project-consistency/SKILL.md +62 -281
  97. package/src/orchestrator/skills/react-development/SKILL.md +38 -86
  98. package/src/orchestrator/skills/security-hardening/SKILL.md +40 -84
  99. package/src/orchestrator/skills/self-improvement/SKILL.md +26 -60
  100. package/src/orchestrator/skills/seo-patterns/SKILL.md +40 -105
  101. package/src/orchestrator/skills/session-checkpoints/SKILL.md +26 -68
  102. package/src/orchestrator/skills/team-lead-reference/SKILL.md +66 -206
  103. package/src/orchestrator/skills/testing-workflow/SKILL.md +42 -112
  104. package/src/orchestrator/skills/validation-gates/SKILL.md +39 -170
  105. package/src/orchestrator/snippets/base-output-contract.md +14 -0
  106. package/src/orchestrator/snippets/discovered-issues-policy.md +15 -0
  107. package/src/orchestrator/snippets/logging-mandatory.md +11 -0
  108. package/src/orchestrator/snippets/never-expose-secrets.md +22 -0
@@ -5,154 +5,106 @@ description: "Task decomposition patterns for the Team Lead: dependency resoluti
5
5
 
6
6
  # Task Decomposition
7
7
 
8
- Detailed decomposition and delegation patterns for the Team Lead. **Load at:** Decompose & Partition phase (Step 2) or when writing delegation prompts (Step 3).
8
+ Load at: Decompose & Partition phase (Step 2) or when writing delegation prompts (Step 3).
9
9
 
10
10
  ## Dependency Resolution
11
11
 
12
- Declare dependencies between subtasks using arrow notation: `TaskB → TaskA` means B depends on A (A must finish first).
12
+ `TaskB → TaskA` = B depends on A (must finish first).
13
13
 
14
- **Topological sort rules:**
15
- 1. Tasks with no dependencies go in Phase 1 (can run in parallel)
16
- 2. Tasks depending only on Phase 1 tasks go in Phase 2
17
- 3. Continue until all tasks are assigned to phases
18
- 4. Tasks in the same phase with no mutual dependencies run in parallel
14
+ **Topological sort:** No-dep tasks → Phase 1. Tasks depending only on Phase N → Phase N+1. Same-phase tasks with no mutual deps run in parallel.
19
15
 
20
- **Cycle detection:** If A → B → C → A, break the cycle by: (a) finding a task that can partially complete independently, (b) splitting that task into an independent part and a dependent part.
21
-
22
- **Visual example:**
16
+ **Cycle detection:** If A → B → C → A, split one task into an independent part + a dependent part.
23
17
 
24
18
  ```
25
- Dependency Graph: Execution Plan:
26
- E → C → A Phase 1: A, B (parallel)
27
- D → B Phase 2: C, D (parallel, depend on Phase 1)
28
- F → C, D Phase 3: E, F (parallel, depend on Phase 2)
19
+ Graph: Plan:
20
+ E → C → A Phase 1: A, B (parallel)
21
+ D → B Phase 2: C, D (parallel)
22
+ F → C, D Phase 3: E, F (parallel)
29
23
  ```
30
24
 
31
- Always draw the dependency graph before assigning phases. Missed dependencies cause agents to block on missing inputs; redundant sequencing wastes time.
32
-
33
- ## Delegation Spec Template
25
+ ## Delegation Spec (Score 5+)
34
26
 
35
- For complex tasks (score 5+), generate a structured spec rather than a free-form prompt:
27
+ For score 1-3, objective + files + criteria is sufficient.
36
28
 
37
29
  ```
38
30
  ## Delegation Spec: [Task Title]
39
-
40
31
  **Tracker Issue:** TAS-XX — [Title]
41
32
  **Complexity:** [score]/13 → [tier] tier
42
33
  **Agent:** [Agent Name]
43
34
 
44
35
  ### Objective
45
- What to build/change and why. 1-3 sentences max.
36
+ 1-3 sentences: what to build/change and why.
46
37
 
47
38
  ### Context
48
- - Key files to read first: [list]
49
- - Related patterns to follow: [file:line references]
50
- - Prior phase output (compacted): [summary from Context Compaction protocol if this task depends on a prior phase]
51
- - Relevant lessons: [LES-XXX references from LESSONS-LEARNED.md]
39
+ - Key files: [list]
40
+ - Related patterns: [file:line references]
41
+ - Prior phase output: [compacted summary if applicable]
42
+ - Relevant lessons: [LES-XXX from LESSONS-LEARNED.md]
52
43
 
53
44
  ### Constraints
54
45
  - File partition: Only modify files under [paths]
55
46
  - Do NOT modify: [explicit exclusions]
56
- - Dependencies: Requires [TAS-XX] to be Done first
47
+ - Dependencies: Requires [TAS-XX] Done first
57
48
 
58
49
  ### Acceptance Criteria
59
- - [ ] Criterion 1 (copied from tracker issue)
60
- - [ ] Criterion 2
61
- - [ ] Criterion 3
50
+ - [ ] Criterion 1
62
51
 
63
52
  ### Expected Output
64
- Return a structured summary with:
65
- - Files changed (path + one-line description)
66
- - Verification results (lint/test/build pass/fail)
67
- - Acceptance criteria status (each item ✅/❌)
68
- - Discovered issues (if any)
69
- - Lessons applied or added
70
-
71
- **Note:** Follow the Structured Output Contract from the team-lead-reference skill. Include all standard fields plus agent-specific extensions.
72
-
73
- ### Self-Improvement
74
- Read `.opencastle/LESSONS-LEARNED.md` before starting. If you retry any command/tool with a different approach that works, use the **self-improvement** skill to add a lesson immediately.
53
+ Files changed · Verification (lint/test/build) · AC status (✅/❌) · Discovered issues · Lessons applied
75
54
  ```
76
55
 
77
- For simpler tasks (score 1-3), the existing prompt format (objective + files + criteria) is sufficient. Don't over-engineer delegation for trivial work.
78
-
79
- **For sub-agents** — also specify what information to return in the result message.
80
-
81
- **For background agents** — include full self-contained context since they cannot ask follow-up questions.
82
-
83
- ## Prompt Quality Examples
84
-
85
- **Strong prompt (simple task, score 2):**
86
- > "**Tracker issue:** TAS-42 — [Auth] Fix token refresh logic
87
- > Users report 'Invalid token' errors after 30 minutes. JWT tokens are configured with 1-hour expiration in `libs/auth/src/server.ts`. Investigate why tokens expire early and fix the refresh logic. Only modify files under `libs/auth/`. Run the auth library tests to verify."
56
+ Read `.opencastle/LESSONS-LEARNED.md` before starting. Add a lesson if you retry any approach.
88
57
 
89
- **Strong prompt (complex task, score 8):**
90
- > Use the Delegation Spec Template above. Fill in all sections for tasks scoring 5+.
58
+ ## Prompt Quality
91
59
 
92
- **Weak prompt:**
93
- > "Fix the authentication bug."
60
+ | Quality | Example |
61
+ |---------|---------|
62
+ | Strong (score 2) | "**TAS-42** — Fix token refresh. Users get 'Invalid token' after 30 min. JWT 1h expiry in `libs/auth/src/server.ts`. Fix refresh logic. Only `libs/auth/`. Run auth tests." |
63
+ | Strong (score 8) | Use Delegation Spec Template above (all sections). |
64
+ | Weak | "Fix the authentication bug." |
94
65
 
95
- ## Delegation Mechanism Selection
66
+ ## Delegation Mechanism
96
67
 
97
68
  ```
98
- Need result immediately?
99
- / \
100
- YES NO
101
- | |
102
- Is it a dependency Expected duration
103
- for the next step? > 5 minutes?
104
- / \ / \
105
- YES NO YES NO
106
- | | | |
107
- Sub-Agent Sub-Agent Background Sub-Agent
108
- (inline) (if small enough, Agent (sequential)
109
- else Background)
69
+ Need result immediately?
70
+ YES → Is dependency for next step?
71
+ YES → Sub-Agent (inline)
72
+ NO → Sub-Agent or Background (if large)
73
+ NO → Expected > 5 min?
74
+ YES Background Agent
75
+ NO → Sub-Agent (sequential)
110
76
  ```
111
77
 
112
- ## Mixed Delegation Orchestration
78
+ ## Mixed Delegation
113
79
 
114
- Combine sub-agents and background agents for maximum efficiency:
80
+ | Phase | Mode | Work |
81
+ |-------|------|------|
82
+ | 1 | sub-agent | Research — context, patterns, file map |
83
+ | 2 | background | Foundation — DB migration + scaffolding (parallel) |
84
+ | 3 | sub-agent | Integration — wire components to data |
85
+ | 4 | background | Validation — security audit + tests + docs (parallel) |
86
+ | 5 | sub-agent | QA gate — verify phases, run builds |
87
+ | 6 | sub-agent | Panel review — load panel-majority-vote skill |
115
88
 
116
- ```
117
- Phase 1 (sub-agent): Research — gather context, identify patterns, map files
118
- Phase 2 (background): Foundation — DB migration + Component scaffolding (parallel)
119
- Phase 3 (sub-agent): Integration — wire components to data (needs Phase 2 results)
120
- Phase 4 (background): Validation — Security audit + Tests + Docs (parallel)
121
- Phase 5 (sub-agent): QA gate — verify all phases, run builds, self-review
122
- Phase 6 (sub-agent): Panel review — load panel-majority-vote skill for high-stakes validation
123
- ```
124
-
125
- ## Foundation-First Decomposition
126
-
127
- When decomposing a multi-page or multi-component project, always apply the Foundation-First Pattern to maintain cross-agent consistency:
89
+ ## Foundation-First Pattern
128
90
 
129
- ### When to apply
130
-
131
- - Goal involves 2+ pages, views, or UI sections
132
- - Multiple agents (same or different phase) will produce visual output
133
- - The project doesn't have an existing design system
134
-
135
- ### Phase structure
91
+ Apply when: 2+ pages/views/UI sections · multiple agents produce visual output · no existing design system.
136
92
 
137
93
  ```
138
94
  Phase 1: foundation-setup
139
- ├── Creates: design tokens, layout, UI component library
140
- ├── Defines: style guide brief (aesthetic, tone, terminology)
95
+ ├── Creates: design tokens, layout, UI component library, style guide brief
141
96
  └── All visual tasks → depends_on: [foundation-setup]
142
97
 
143
98
  Phase 2+: page tasks (parallel)
144
99
  ├── Each prompt includes 5 Foundation References
145
- └── Agents consume tokens — never create new values
100
+ └── Consume tokens — never create new values
146
101
  ```
147
102
 
148
- ### Partition rules for foundation
149
-
150
- - Foundation task owns: `src/styles/`, `src/components/Layout.*`, `src/components/ui/`
151
- - Page tasks own: their specific page file + page-specific components only
103
+ **Partition rules:**
104
+ - Foundation owns: `src/styles/`, `src/components/Layout.*`, `src/components/ui/`
105
+ - Page tasks own: their page file + page-specific components only
152
106
  - No page task may list a foundation-owned path in its `files[]`
153
107
 
154
- ### Common mistake
155
-
156
- Decomposing pages as independent Phase 1 tasks (no foundation). This produces partition-clean, dependency-valid specs that fail aesthetically — each agent invents its own design. Always add the foundation task as the root of the DAG for visual work.
108
+ **Common mistake:** Decomposing pages as independent Phase 1 tasks → each agent invents its own design.
157
109
 
158
110
  > Load the **project-consistency** skill for the full Foundation Phase pattern, prompt templates, and anti-patterns.
@@ -3,39 +3,31 @@ name: deployment-infrastructure
3
3
  description: "Deployment architecture, environment variables, cron jobs, security headers, and caching patterns. Use when configuring deployments, managing environment variables, setting up cron jobs, or troubleshooting build/deployment issues."
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
  # Deployment Infrastructure
9
7
 
10
8
  All deployment configuration is project-specific. See [deployment-config.md](../../.opencastle/stack/deployment-config.md) for the full architecture, environment variables, cron jobs, caching headers, and key files.
11
9
 
12
10
  ## Generic Deployment Principles
13
11
 
14
- - Use platform-native Git integration for CI/CD (push to main = production, push to branch = preview)
12
+ - Use platform-native Git integration for CI/CD (push to `main` = production, push to branch = preview)
15
13
  - Store all secrets as environment variables — never in code, commits, or logs
16
14
  - Use `Bearer` token auth for cron job endpoints
17
15
  - Apply security headers via framework config (HSTS, CSP, X-Frame-Options, Permissions-Policy)
18
- - Set immutable cache headers for static assets (`max-age=31536000, immutable`)
19
- - Use short cache durations for frequently changing assets (e.g., favicon: `max-age=86400`)
16
+ - Cache static assets with `max-age=31536000, immutable`; use `max-age=86400` for favicon/manifest
20
17
  - Load the **security-hardening** skill for full header inventory and CSP configuration
21
18
 
22
- ## Environment Variable Management
19
+ ## Environment Variables
23
20
 
24
21
  ### Layering & Precedence
25
22
 
26
- Environment variables follow a layered override model (lowest to highest priority):
27
-
28
- 1. `.env` — shared defaults, committed to repo (no secrets)
29
- 2. `.env.local` — developer-specific overrides, git-ignored
23
+ 1. `.env` shared defaults; committed, no secrets
24
+ 2. `.env.local` — developer overrides; git-ignored
30
25
  3. `.env.production` / `.env.preview` — environment-specific values
31
- 4. Platform-injected variables — set in hosting dashboard, highest priority
26
+ 4. Platform-injected — set in hosting dashboard (highest priority)
32
27
 
33
- ### Validation at Startup
34
-
35
- Validate required variables at application startup. Fail fast with clear messages:
28
+ ### Startup Validation
36
29
 
37
30
  ```typescript
38
- // src/lib/env.ts
39
31
  import { z } from 'zod';
40
32
 
41
33
  const envSchema = z.object({
@@ -49,71 +41,46 @@ const envSchema = z.object({
49
41
  export const env = envSchema.parse(process.env);
50
42
  ```
51
43
 
52
- ### Naming & .gitignore
53
-
54
- - `PUBLIC_*` or `NEXT_PUBLIC_*` — safe to expose to the browser
55
- - `SECRET_*` or `*_SECRET` — server-only, never bundled into client code
56
- - `CRON_SECRET` — authenticates scheduled job endpoints
57
- - Use `SCREAMING_SNAKE_CASE` for all variable names
58
- - Always gitignore `.env.local`, `.env.*.local`, and `.env.production`
44
+ ### Naming
59
45
 
60
- ## CI/CD Pipeline Patterns
46
+ - Prefix: `PUBLIC_*`/`NEXT_PUBLIC_*` (browser-safe), `SECRET_*`/`*_SECRET` (server-only), `CRON_SECRET` (cron)
47
+ - `SCREAMING_SNAKE_CASE`; gitignore `.env.local`, `.env.*.local`, `.env.production`
61
48
 
62
- ### Branch-Based Deployment
63
-
64
- ```
65
- main branch → Production deployment (auto)
66
- feature/* → Preview deployment (auto)
67
- fix/* → Preview deployment (auto)
68
- ```
49
+ ## CI/CD Pipeline
69
50
 
70
- ### Generic Pipeline Stages
51
+ **Branch deployment:** `main` → Production (auto) | `feature/*`, `fix/*` → Preview (auto)
71
52
 
72
- Every pipeline should include these stages in order:
53
+ **Stages (in order):** Install (`--frozen-lockfile`), Lint, Test (unit + integration + coverage), Build (production build), Deploy
73
54
 
74
- 1. **Install** — restore dependencies from lockfile (`--frozen-lockfile`)
75
- 2. **Lint** — static analysis and formatting checks
76
- 3. **Test** — unit and integration tests with coverage
77
- 4. **Build** — production build (catches type errors and build-time issues)
78
- 5. **Deploy** — push artifacts to hosting platform
79
-
80
- ### Cron Job Authentication
81
-
82
- Protect scheduled endpoints with a shared secret:
55
+ **Cron auth:**
83
56
 
84
57
  ```typescript
85
- // app/api/cron/route.ts
86
58
  export async function GET(request: Request) {
87
59
  const authHeader = request.headers.get('authorization');
88
- if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
60
+ if (authHeader !== `Bearer ${process.env.CRON_SECRET}`)
89
61
  return new Response('Unauthorized', { status: 401 });
90
- }
91
- // ... run scheduled task
92
62
  return Response.json({ ok: true });
93
63
  }
94
64
  ```
95
65
 
96
66
  ## Caching Strategy
97
67
 
98
- ### Cache Duration Reference
99
-
100
68
  | Asset Type | `Cache-Control` Header | Rationale |
101
69
  |---|---|---|
102
- | Hashed static assets (JS, CSS) | `public, max-age=31536000, immutable` | Content-addressed filenames; safe to cache forever |
103
- | Images / fonts | `public, max-age=31536000, immutable` | Typically fingerprinted; long-lived |
104
- | Favicon / manifest | `public, max-age=86400` | Changes rarely but should refresh within a day |
70
+ | Hashed static assets (JS, CSS) | `public, max-age=31536000, immutable` | Content-addressed; safe to cache forever |
71
+ | Images / fonts | `public, max-age=31536000, immutable` | Typically fingerprinted |
72
+ | Favicon / manifest | `public, max-age=86400` | Refreshes within a day |
105
73
  | HTML pages (SSG) | `public, max-age=0, must-revalidate` | Serve stale while revalidating |
106
74
  | API responses | `private, no-cache` | User-specific or frequently changing |
107
- | Prerendered pages (ISR) | `public, s-maxage=3600, stale-while-revalidate=86400` | CDN caches for 1 hour, serves stale for up to 1 day |
75
+ | Prerendered pages (ISR) | `public, s-maxage=3600, stale-while-revalidate=86400` | CDN: 1h cache, 1d stale |
108
76
 
109
- Apply cache headers via framework config (e.g., `headers()` in `next.config.js`) or CDN rules. Match each route pattern to the appropriate duration from the table above.
77
+ Apply via framework `headers()` config or CDN rules.
110
78
 
111
79
  ## Security Headers
112
80
 
113
- Apply these headers globally via framework config or middleware. See the **security-hardening** skill for full CSP configuration.
81
+ Apply globally via framework config or middleware. See **security-hardening** skill for full CSP configuration.
114
82
 
115
83
  ```javascript
116
- // Recommended security headers
117
84
  const securityHeaders = [
118
85
  { key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
119
86
  { key: 'X-Content-Type-Options', value: 'nosniff' },
@@ -125,68 +92,38 @@ const securityHeaders = [
125
92
  ];
126
93
  ```
127
94
 
128
- **Key rules:**
129
-
130
- - HSTS `max-age` must be at least 1 year (31536000 seconds) for preload eligibility
131
- - `X-Frame-Options: DENY` prevents clickjacking — use `SAMEORIGIN` only if you embed your own pages
132
- - CSP should be as restrictive as possible; expand only when needed, document each exception
95
+ - HSTS `max-age` ≥ 31536000 for preload eligibility
96
+ - `X-Frame-Options: DENY` prevents clickjacking; use `SAMEORIGIN` only for self-embeds
97
+ - Keep CSP as restrictive as possible; document each exception
133
98
  - Disable unused browser features via `Permissions-Policy`
134
99
 
135
100
  ## Release Process
136
101
 
137
- ### 1. Pre-Release Audit
138
- - Run lint, test, and build for all affected projects (see the **codebase-tool** skill for commands)
139
- - Review all changed files since last release (`git diff` against last tag/release)
140
- - Check for uncommitted work or unmerged branches
141
- - Verify no draft PRs are accidentally included
142
-
143
- ### 2. Regression Check
144
- - Identify features adjacent to changes and spot-check them
145
- - Run full test suites for all affected projects (not just changed files)
146
- - Check deployment preview builds for visual regressions
147
- - Verify critical user flows still work (e.g., primary navigation, form submissions, authenticated pages)
148
-
149
- ### 3. Changelog & Release Notes
150
- - Generate changelog from commit messages and PR titles since last release
151
- - Categorize changes: Features, Bug Fixes, Performance, Breaking Changes, Internal
152
- - Write human-readable release notes summarizing impact
153
- - Include migration notes for any breaking changes
154
-
155
- ### 4. Version Management
156
- - Follow semver: MAJOR (breaking), MINOR (features), PATCH (fixes)
157
- - Tag releases in git with the version number
158
- - Update version references in relevant files
159
-
160
- ### 5. Release Verification
161
- - Confirm deployment succeeded on production
162
- - Smoke-test production URLs for critical pages
163
- - Monitor error rates and performance metrics post-release
164
- - Have rollback steps documented and ready (see § Rollback Procedures)
102
+ 1. **Pre-Release Audit** — lint, test, build all affected projects; check `git diff` since last tag; verify no draft PRs
103
+ 2. **Regression Check** spot-check adjacent features; run full test suites; verify critical user flows
104
+ 3. **Changelog** generate from commits/PR titles; categorize (Features, Bug Fixes, Performance, Breaking Changes); include migration notes
105
+ 4. **Version** semver (MAJOR/MINOR/PATCH); tag in git; update version references
106
+ 5. **Verify** smoke-test production URLs; monitor error rates; document rollback steps
165
107
 
166
108
  ## Rollback Procedures
167
109
 
168
- **Two rollback strategies** (prefer platform-level when available):
169
-
170
- 1. **Platform rollback** — promote the last known-good deployment from the hosting dashboard
171
- 2. **Git revert** — `git revert -m 1 HEAD && git push origin main` (triggers a clean redeploy)
172
-
173
- ### Rollback Checklist
110
+ 1. **Platform rollback** promote last known-good deployment from hosting dashboard
111
+ 2. **Git revert** — `git revert -m 1 HEAD && git push origin main`
174
112
 
175
- - [ ] Confirm the issue is deployment-related (not a data or third-party issue)
176
- - [ ] Roll back via platform or git revert — never force-push to `main`
177
- - [ ] Verify the rollback deployment is healthy (smoke tests)
178
- - [ ] Notify the team with a summary of what was rolled back and why
179
- - [ ] Create a post-mortem ticket to investigate root cause
113
+ - [ ] Confirm issue is deployment-related (not data or third-party)
114
+ - [ ] Roll back via platform or git revert — never force-push `main`
115
+ - [ ] Smoke-test the rollback deployment
116
+ - [ ] Notify team; create post-mortem ticket
180
117
 
181
118
  ## Anti-Patterns
182
119
 
183
- | Anti-Pattern | Why It's Wrong | Correct Approach |
120
+ | Anti-Pattern | Why | Fix |
184
121
  |---|---|---|
185
- | Hardcoding secrets in source code | Secrets leak via git history, logs, and client bundles | Use environment variables; validate with Zod at startup |
186
- | Skipping preview deployments | Bugs reach production without visual review | Deploy every branch to a preview environment |
187
- | Using `Cache-Control: no-store` everywhere | Destroys performance; every request hits origin | Use appropriate cache durations per asset type (see table above) |
188
- | Force-pushing to `main` to "fix" a bad deploy | Destroys git history; breaks other developers' branches | Use `git revert` to cleanly undo changes |
189
- | Disabling security headers "temporarily" | Temporary becomes permanent; opens attack surface | Keep headers strict; expand only with documented exceptions |
190
- | Running builds without `--frozen-lockfile` | Non-deterministic installs; works locally, fails in CI | Always use `--frozen-lockfile` (or equivalent) in CI |
191
- | Storing `.env.local` in the repository | Developer secrets and tokens leak to all contributors | Add `.env.local` to `.gitignore`; share via secure vault |
192
- | No startup validation of env vars | App starts but crashes later with cryptic errors | Validate all required variables at boot (fail fast) |
122
+ | Hardcoding secrets | Leak via git, logs, bundles | Env vars + Zod startup validation |
123
+ | Skipping preview deployments | Bugs reach production unreviewed | Deploy every branch to preview |
124
+ | `Cache-Control: no-store` everywhere | Every request hits origin | Per-asset cache durations (see table) |
125
+ | Force-push `main` to fix a deploy | Destroys history; breaks teammates | `git revert` to undo cleanly |
126
+ | Disabling security headers "temporarily" | Temporary becomes permanent | Keep strict; document exceptions |
127
+ | Builds without `--frozen-lockfile` | Non-deterministic installs | Always use `--frozen-lockfile` in CI |
128
+ | `.env.local` in repository | Developer secrets leak | Gitignore; share via secure vault |
129
+ | No startup env validation | Cryptic late-failure errors | Validate all vars at boot (fail fast) |
@@ -3,8 +3,6 @@ name: documentation-standards
3
3
  description: "Documentation templates, structure, and standards for project docs, roadmaps, ADRs, and known issues. Use when writing or updating documentation files."
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
  # Documentation Standards
9
7
 
10
8
  Generic documentation templates and writing standards. For project-specific directory structure and practices, see [docs-structure.md](../../.opencastle/project/docs-structure.md).
@@ -26,9 +24,7 @@ Generic documentation templates and writing standards. For project-specific dire
26
24
  [Technical explanation]
27
25
 
28
26
  #### Solution Options
29
- 1. **Option A** — [Description]
30
- - Pros: ...
31
- - Cons: ...
27
+ 1. **Option A** — [Description] — Pros: ... Cons: ...
32
28
  2. **Option B** — [Description]
33
29
 
34
30
  #### Related Files
@@ -46,7 +42,6 @@ When a feature is completed:
46
42
 
47
43
  ```markdown
48
44
  ## ADR-NNN: Decision Title
49
-
50
45
  **Date:** YYYY-MM-DD
51
46
  **Status:** Accepted | Superseded | Deprecated
52
47
  **Context:** [Why this decision was needed]
@@ -57,127 +52,71 @@ When a feature is completed:
57
52
 
58
53
  ## README Template
59
54
 
60
- Use this structure for library or feature-level READMEs:
61
-
62
55
  ```markdown
63
56
  # Feature / Library Name
64
-
65
57
  One-sentence summary of what this does and why it exists.
66
-
67
58
  ## Quick Start
68
-
69
59
  Brief usage example or setup steps.
70
-
71
60
  ## Architecture
72
-
73
61
  High-level overview. Include a Mermaid diagram for non-trivial systems.
74
-
75
62
  ## Key Files
76
-
77
63
  | File | Purpose |
78
64
  |------|---------|
79
65
  | `src/handler.ts` | Request handling logic |
80
66
  | `src/schema.ts` | Validation schemas |
81
67
  ```
82
68
 
83
- ## Mermaid Diagram Patterns
69
+ ## Mermaid Diagrams
84
70
 
85
71
  Keep diagrams focused — one concern per diagram.
86
- ### Flowchart (decision logic, pipelines)
72
+
73
+ | Type | Use For | Directive |
74
+ |------|---------|-----------|
75
+ | Flowchart | Decision logic, pipelines | `flowchart TD` (top-down) / `flowchart LR` (left-right) |
76
+ | Sequence | API flows, multi-service interactions | `sequenceDiagram` |
77
+ | ER | Data models, relationships | `erDiagram` |
87
78
 
88
79
  ```mermaid
89
80
  flowchart TD
90
81
  A[Receive Request] --> B{Authenticated?}
91
- B -- Yes --> C[Process Request]
82
+ B -- Yes --> C[Process]
92
83
  B -- No --> D[Return 401]
93
- C --> E{Valid Input?}
94
- E -- Yes --> F[Execute Action]
95
- E -- No --> G[Return 400]
96
- ```
97
-
98
- ### Sequence Diagram (API flows, multi-service interactions)
99
-
100
- ```mermaid
101
- sequenceDiagram
102
- participant Client
103
- participant API
104
- participant DB
105
- Client->>API: POST /resource
106
- API->>DB: INSERT record
107
- DB-->>API: OK
108
- API-->>Client: 201 Created
109
84
  ```
110
85
 
111
- ### ER Diagram (data models, relationships)
112
-
113
- ```mermaid
114
- erDiagram
115
- USER ||--o{ ORDER : places
116
- ORDER ||--|{ LINE_ITEM : contains
117
- USER { string id PK; string email }
118
- ORDER { string id PK; date created_at }
119
- ```
120
-
121
- ### Diagram Guidelines
122
-
123
- - Add a title comment (`%% Title: ...`) at the top of complex diagrams
124
- - Use verb labels on relationship arrows
125
- - Limit nodes to 10–12 per diagram; split larger systems into sub-diagrams
126
- - Prefer `flowchart TD` (top-down) for pipelines and `flowchart LR` (left-right) for request flows
86
+ - Add `%% Title: ...` on complex diagrams; use verb labels on arrows
87
+ - Limit to 10–12 nodes per diagram; `flowchart TD` for pipelines, `LR` for request flows
127
88
 
128
89
  ## Changelog Entry Template
129
90
 
130
- Follow Conventional Commits format. Group entries by type under a version heading:
91
+ Group entries by Conventional Commits type under a version heading:
131
92
 
132
93
  ```markdown
133
94
  ## [1.2.0] — YYYY-MM-DD
134
-
135
95
  ### Added
136
96
  - feat: Add retry logic to API client (#123)
137
-
138
97
  ### Fixed
139
98
  - fix: Resolve race condition in queue processor (#127)
140
-
141
99
  ### Changed
142
100
  - refactor: Extract validation into shared module (#125)
143
101
  ```
144
102
 
145
- ### Changelog Rules
146
-
147
103
  - One line per change; reference the PR or issue number
148
- - Use imperative mood: "Add", "Fix", "Remove" — not "Added", "Fixed"
149
- - Group under `Added`, `Fixed`, `Changed`, `Removed`, `Deprecated`, `Security`
150
- - Most recent version at the top
151
-
152
- ## Writing Guidelines
153
-
154
- - Write clear, concise prose avoid jargon unless necessary
155
- - Include Mermaid diagrams for architecture
156
- - Link to related files using relative paths
157
- - Use tables for structured data; include "Last Updated" dates on all documents
158
- - Archive outdated docs rather than deleting; cross-reference between documents
159
-
160
- ### Formatting Rules
161
-
162
- - **Headings**: Use H2 for sections, H3 for subsections. Do not use H1 — generated from title. Avoid H4+
163
- - **Lists**: Use `-` for bullet points and `1.` for numbered lists; indent nested lists with two spaces
164
- - **Code Blocks**: Use fenced code blocks with language specified for syntax highlighting
165
- - **Links**: Use `[link text](URL)` with descriptive text and valid URLs
166
- - **Images**: Use `![alt text](image URL)` with brief descriptive alt text
167
- - **Tables**: Use `|` tables with properly aligned columns and headers
168
- - **Whitespace**: Use blank lines to separate sections; avoid excessive whitespace
169
-
170
- ### Front Matter
171
-
172
- Include YAML front matter at the beginning of instruction/skill files:
173
-
174
- - `title` / `name`: The title of the document
175
- - `description`: A brief description of the document content
176
- - `applyTo`: (for instruction files) Glob pattern for which files the instructions apply to
177
-
178
- ## Documentation Review Checklist
179
-
180
- Before merging docs, verify:
104
+ - Imperative mood: "Add", "Fix", "Remove" — not "Added", "Fixed"
105
+ - Groups: `Added`, `Fixed`, `Changed`, `Removed`, `Deprecated`, `Security`; most recent version first
106
+
107
+ ## Writing & Formatting
108
+
109
+ - Clear, concise prose; avoid jargon; use relative paths for links; tables for structured data; include "Last Updated" dates
110
+ - Archive outdated docs rather than deleting; cross-reference between documents; Mermaid for architecture
111
+ - **Headings:** H2 for sections, H3 for subsections; no H1 (auto-generated from title), no H4+
112
+ - **Lists:** `-` for bullets, `1.` for numbered; 2-space nested indent
113
+ - **Code Blocks:** Fenced with language tag for syntax highlighting
114
+ - **Links:** `[text](URL)` with descriptive text and valid URLs
115
+ - **Images:** `![alt](url)` with brief alt text
116
+ - **Whitespace:** Blank lines between sections; no excessive whitespace
117
+ - **Front Matter:** YAML required for instruction/skill files — `title`/`name`, `description`, `applyTo` (instructions: glob of applicable files)
118
+
119
+ ## Pre-Merge Checklist
181
120
 
182
121
  - [ ] **Accuracy** — all code snippets, file paths, and commands are correct and tested
183
122
  - [ ] **Completeness** — no TODO placeholders or empty sections remain