catalyst-os 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.catalyst/main/project-config.yaml +11 -0
- package/.catalyst/spec-structure.yaml +241 -0
- package/.catalyst/specs/spec-config.yaml +109 -0
- package/.catalyst/standards/coding.md +187 -0
- package/.catalyst/standards/git-workflow.md +181 -0
- package/.catalyst/standards/testing.md +185 -0
- package/.catalyst/workflows/approve-spec.md +413 -0
- package/.catalyst/workflows/build-spec.md +527 -0
- package/.catalyst/workflows/build-task.md +434 -0
- package/.catalyst/workflows/catalyze-project.md +212 -0
- package/.catalyst/workflows/catalyze-spec.md +265 -0
- package/.catalyst/workflows/validate-spec.md +388 -0
- package/.claude/agents/alchemist.md +84 -0
- package/.claude/agents/arbiter.md +142 -0
- package/.claude/agents/catalyst.md +102 -0
- package/.claude/agents/enforcer.md +62 -0
- package/.claude/agents/forge-master.md +318 -0
- package/.claude/agents/forger.md +216 -0
- package/.claude/agents/inquisitor.md +70 -0
- package/.claude/agents/necromancer.md +84 -0
- package/.claude/agents/oracle.md +67 -0
- package/.claude/agents/scout.md +74 -0
- package/.claude/agents/scribe.md +163 -0
- package/.claude/agents/seer.md +108 -0
- package/.claude/agents/sentinel.md +58 -0
- package/.claude/agents/shaper.md +85 -0
- package/.claude/agents/smith.md +85 -0
- package/.claude/agents/surveyor.md +52 -0
- package/.claude/agents/watcher.md +69 -0
- package/.claude/commands/approve-spec.md +383 -0
- package/.claude/commands/build-spec.md +381 -0
- package/.claude/commands/build-task.md +210 -0
- package/.claude/commands/catalyze-project.md +112 -0
- package/.claude/commands/catalyze-spec.md +197 -0
- package/.claude/commands/mission.md +48 -0
- package/.claude/commands/reject-spec.md +125 -0
- package/.claude/commands/roadmap.md +62 -0
- package/.claude/commands/status-spec.md +289 -0
- package/.claude/commands/tech-stack.md +75 -0
- package/.claude/commands/update-spec.md +265 -0
- package/.claude/commands/validate-spec.md +265 -0
- package/.claude/settings.local.json +13 -0
- package/.claude/skills/catalysts/build-orchestration/SKILL.md +54 -0
- package/.claude/skills/catalysts/spec-orchestration/SKILL.md +52 -0
- package/.claude/skills/catalysts/validation-orchestration/SKILL.md +50 -0
- package/.claude/skills/guardians/browser-automation/SKILL.md +58 -0
- package/.claude/skills/guardians/code-review/SKILL.md +60 -0
- package/.claude/skills/guardians/dependency-audit/SKILL.md +63 -0
- package/.claude/skills/guardians/e2e-test-execution/SKILL.md +52 -0
- package/.claude/skills/guardians/lint-checking/SKILL.md +46 -0
- package/.claude/skills/guardians/secret-scanning/SKILL.md +69 -0
- package/.claude/skills/guardians/test-fixture-creation/SKILL.md +54 -0
- package/.claude/skills/guardians/unit-test-writing/SKILL.md +57 -0
- package/.claude/skills/seekers/codebase-analysis/SKILL.md +67 -0
- package/.claude/skills/seekers/context7-lookup/SKILL.md +59 -0
- package/.claude/skills/seekers/documentation-management/SKILL.md +190 -0
- package/.claude/skills/seekers/figma-analysis/SKILL.md +57 -0
- package/.claude/skills/seekers/github-research/SKILL.md +57 -0
- package/.claude/skills/seekers/reddit-research/SKILL.md +55 -0
- package/.claude/skills/seekers/requirement-elicitation/SKILL.md +53 -0
- package/.claude/skills/seekers/ui-pattern-hunting/SKILL.md +62 -0
- package/.claude/skills/seekers/web-research/SKILL.md +61 -0
- package/.claude/skills/technologists/ai-integration/SKILL.md +53 -0
- package/.claude/skills/technologists/api-development/SKILL.md +51 -0
- package/.claude/skills/technologists/migration-creation/SKILL.md +58 -0
- package/.claude/skills/technologists/ml-pipeline/SKILL.md +54 -0
- package/.claude/skills/technologists/react-development/SKILL.md +61 -0
- package/.claude/skills/technologists/schema-design/SKILL.md +54 -0
- package/.claude/skills/technologists/service-implementation/SKILL.md +49 -0
- package/.claude/skills/technologists/task-breakdown/SKILL.md +60 -0
- package/.claude/skills/technologists/ui-component-building/SKILL.md +58 -0
- package/.claude-plugin/plugin.json +43 -0
- package/README.md +440 -0
- package/bin/install.js +174 -0
- package/package.json +40 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Project Foundation Configuration
|
|
2
|
+
|
|
3
|
+
# Command to initialize project foundation
|
|
4
|
+
command: "/catalyze-project"
|
|
5
|
+
|
|
6
|
+
# Generated files
|
|
7
|
+
generated_files:
|
|
8
|
+
mission.md: "Project vision and goals"
|
|
9
|
+
roadmap.md: "Development phases"
|
|
10
|
+
tech-stack.md: "Technology decisions"
|
|
11
|
+
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Spec Folder Structure
|
|
2
|
+
# Single source of truth - all agents and commands reference this file
|
|
3
|
+
|
|
4
|
+
version: 3
|
|
5
|
+
|
|
6
|
+
folder_pattern: ".catalyst/specs/YYYY-MM-DD-{slug}/"
|
|
7
|
+
|
|
8
|
+
files:
|
|
9
|
+
spec.md:
|
|
10
|
+
owner: scribe
|
|
11
|
+
purpose: Requirements + frontmatter (context assembly metadata)
|
|
12
|
+
created: catalyze-spec
|
|
13
|
+
updated_by: [scribe, arbiter]
|
|
14
|
+
note: |
|
|
15
|
+
Frontmatter enables cross-spec context assembly.
|
|
16
|
+
Body contains requirements and acceptance criteria.
|
|
17
|
+
|
|
18
|
+
research.md:
|
|
19
|
+
owner: scribe
|
|
20
|
+
purpose: All research findings (append-only)
|
|
21
|
+
created: catalyze-spec
|
|
22
|
+
updated_by: [scout, seer, oracle, scribe]
|
|
23
|
+
pattern: append
|
|
24
|
+
|
|
25
|
+
tasks.md:
|
|
26
|
+
owner: forger
|
|
27
|
+
purpose: DAG + progress + decisions + session context (THE living doc)
|
|
28
|
+
created: build-spec
|
|
29
|
+
updated_by: [forger, forge-master, builders]
|
|
30
|
+
pattern: living
|
|
31
|
+
note: |
|
|
32
|
+
ONE FILE to read when resuming work.
|
|
33
|
+
Contains everything about execution state.
|
|
34
|
+
|
|
35
|
+
handoff.md:
|
|
36
|
+
owner: scribe
|
|
37
|
+
purpose: Human-readable summary (colleague walkthrough)
|
|
38
|
+
created: build-spec (started), validate-spec (finalized)
|
|
39
|
+
updated_by: [scribe, arbiter]
|
|
40
|
+
pattern: narrative
|
|
41
|
+
note: |
|
|
42
|
+
Written like explaining to a colleague.
|
|
43
|
+
5 minutes to read, not 50.
|
|
44
|
+
|
|
45
|
+
validation.md:
|
|
46
|
+
owner: arbiter
|
|
47
|
+
purpose: Test results, quality checks
|
|
48
|
+
created: validate-spec
|
|
49
|
+
updated_by: [arbiter, enforcer, sentinel, inquisitor, watcher]
|
|
50
|
+
|
|
51
|
+
assets/:
|
|
52
|
+
owner: any
|
|
53
|
+
purpose: Images, diagrams, mockups
|
|
54
|
+
created: as-needed
|
|
55
|
+
|
|
56
|
+
statuses:
|
|
57
|
+
- DRAFT
|
|
58
|
+
- IN_PROGRESS
|
|
59
|
+
- VALIDATING
|
|
60
|
+
- COMPLETE
|
|
61
|
+
|
|
62
|
+
rules:
|
|
63
|
+
- spec.md has frontmatter for context assembly
|
|
64
|
+
- tasks.md is THE living document during build
|
|
65
|
+
- handoff.md is human-first, no heavy YAML
|
|
66
|
+
- One file to resume = tasks.md
|
|
67
|
+
|
|
68
|
+
# =============================================================================
|
|
69
|
+
# SPEC.MD SCHEMA
|
|
70
|
+
# Requirements + frontmatter for context assembly
|
|
71
|
+
# =============================================================================
|
|
72
|
+
|
|
73
|
+
spec_schema:
|
|
74
|
+
frontmatter:
|
|
75
|
+
required:
|
|
76
|
+
spec: string # YYYY-MM-DD-slug
|
|
77
|
+
status: enum # draft | in_progress | validating | complete
|
|
78
|
+
domain: string # auth, payments, ui, api, database, etc.
|
|
79
|
+
|
|
80
|
+
context_assembly:
|
|
81
|
+
provides: # What this spec creates
|
|
82
|
+
- type: string
|
|
83
|
+
requires: # Dependencies on other specs
|
|
84
|
+
- spec: string
|
|
85
|
+
needed: string
|
|
86
|
+
affects: # What future work this impacts
|
|
87
|
+
- type: string
|
|
88
|
+
|
|
89
|
+
knowledge:
|
|
90
|
+
patterns_established: # Technical decisions (filled during/after build)
|
|
91
|
+
- type: string
|
|
92
|
+
key_files: # Important files created
|
|
93
|
+
- type: string
|
|
94
|
+
key_decisions: # Strategic choices with rationale
|
|
95
|
+
- type: string
|
|
96
|
+
|
|
97
|
+
example: |
|
|
98
|
+
---
|
|
99
|
+
spec: 2025-01-11-user-auth
|
|
100
|
+
status: complete
|
|
101
|
+
domain: auth
|
|
102
|
+
|
|
103
|
+
provides:
|
|
104
|
+
- User model with password hashing
|
|
105
|
+
- JWT middleware
|
|
106
|
+
- Login/signup endpoints
|
|
107
|
+
|
|
108
|
+
requires: []
|
|
109
|
+
|
|
110
|
+
affects:
|
|
111
|
+
- All routes needing auth
|
|
112
|
+
- User-related features
|
|
113
|
+
|
|
114
|
+
patterns_established:
|
|
115
|
+
- argon2 for password hashing (not bcrypt)
|
|
116
|
+
- jose library for JWT
|
|
117
|
+
- httpOnly cookies for tokens
|
|
118
|
+
|
|
119
|
+
key_files:
|
|
120
|
+
- src/middleware/auth.ts
|
|
121
|
+
- src/api/auth/login.ts
|
|
122
|
+
|
|
123
|
+
key_decisions:
|
|
124
|
+
- JWT over sessions (stateless scaling)
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
# User Authentication
|
|
128
|
+
|
|
129
|
+
## Overview
|
|
130
|
+
...requirements here...
|
|
131
|
+
|
|
132
|
+
# =============================================================================
|
|
133
|
+
# TASKS.MD SCHEMA
|
|
134
|
+
# The ONE file to read when resuming - DAG + progress + decisions + context
|
|
135
|
+
# =============================================================================
|
|
136
|
+
|
|
137
|
+
tasks_schema:
|
|
138
|
+
sections:
|
|
139
|
+
- "## Build DAG" # Task breakdown with phases
|
|
140
|
+
- "## Progress" # Status table
|
|
141
|
+
- "## Current Session" # Where we are, what's next
|
|
142
|
+
- "## Decisions" # Decisions made during build
|
|
143
|
+
|
|
144
|
+
example: |
|
|
145
|
+
# Tasks: User Authentication
|
|
146
|
+
|
|
147
|
+
## Build DAG
|
|
148
|
+
|
|
149
|
+
### Phase 1: Red (enforcer)
|
|
150
|
+
| ID | Agent | Scope | Depends On |
|
|
151
|
+
|----|-------|-------|------------|
|
|
152
|
+
| tests-auth | enforcer | tests/api/auth/** | - |
|
|
153
|
+
|
|
154
|
+
### Phase 2: Foundation (alchemist)
|
|
155
|
+
| ID | Agent | Scope | Depends On |
|
|
156
|
+
|----|-------|-------|------------|
|
|
157
|
+
| db-schema | alchemist | prisma/schema.prisma | tests-auth |
|
|
158
|
+
|
|
159
|
+
### Phase 3: Parallel Backend (smith × 2)
|
|
160
|
+
| ID | Agent | Scope | Reads | Depends On |
|
|
161
|
+
|----|-------|-------|-------|------------|
|
|
162
|
+
| api-auth | smith-1 | src/api/auth/** | src/types/** | db-schema |
|
|
163
|
+
| api-user | smith-2 | src/api/user/** | src/types/** | db-schema |
|
|
164
|
+
|
|
165
|
+
## Progress
|
|
166
|
+
|
|
167
|
+
| Task | Status | Tests | Commit | Notes |
|
|
168
|
+
|------|--------|-------|--------|-------|
|
|
169
|
+
| tests-auth | ✓ Done | 12 failing | a1b2c3d | RED phase complete |
|
|
170
|
+
| db-schema | ✓ Done | 12 passing | e4f5g6h | |
|
|
171
|
+
| api-auth | ⚡ Active | 8/12 | - | Working on refresh |
|
|
172
|
+
| api-user | ⏳ Waiting | - | - | Blocked by api-auth |
|
|
173
|
+
|
|
174
|
+
## Current Session
|
|
175
|
+
|
|
176
|
+
**Phase:** 3 - Parallel Backend
|
|
177
|
+
**Active:** api-auth (smith-1)
|
|
178
|
+
**Working on:** Refresh token rotation
|
|
179
|
+
**File:** `src/api/auth/refresh.ts:45`
|
|
180
|
+
**Next:** Finish refresh, then api-user can start
|
|
181
|
+
|
|
182
|
+
## Decisions
|
|
183
|
+
|
|
184
|
+
- **JWT over sessions** - Stateless for horizontal scaling
|
|
185
|
+
- **15-min access token** - Balance security vs UX
|
|
186
|
+
- **argon2 over bcrypt** - Better GPU resistance
|
|
187
|
+
|
|
188
|
+
# =============================================================================
|
|
189
|
+
# HANDOFF.MD TEMPLATE
|
|
190
|
+
# Human-readable - colleague explaining over coffee
|
|
191
|
+
# =============================================================================
|
|
192
|
+
|
|
193
|
+
handoff_template: |
|
|
194
|
+
# Handoff: {Spec Name}
|
|
195
|
+
|
|
196
|
+
> Status: {status}
|
|
197
|
+
|
|
198
|
+
## TL;DR
|
|
199
|
+
|
|
200
|
+
{One paragraph - what was built}
|
|
201
|
+
|
|
202
|
+
## What Changed
|
|
203
|
+
|
|
204
|
+
- Change 1
|
|
205
|
+
- Change 2
|
|
206
|
+
|
|
207
|
+
## Key Decisions
|
|
208
|
+
|
|
209
|
+
**Why X over Y?**
|
|
210
|
+
Rationale here.
|
|
211
|
+
|
|
212
|
+
## How to Test
|
|
213
|
+
|
|
214
|
+
1. Step 1
|
|
215
|
+
2. Step 2
|
|
216
|
+
|
|
217
|
+
## What's Next
|
|
218
|
+
|
|
219
|
+
- [ ] Next item
|
|
220
|
+
|
|
221
|
+
## Gotchas
|
|
222
|
+
|
|
223
|
+
- Thing that might trip you up
|
|
224
|
+
|
|
225
|
+
# =============================================================================
|
|
226
|
+
# CONTEXT ASSEMBLY
|
|
227
|
+
# =============================================================================
|
|
228
|
+
|
|
229
|
+
context_assembly:
|
|
230
|
+
source: spec.md # Read frontmatter from spec.md
|
|
231
|
+
|
|
232
|
+
on_new_spec:
|
|
233
|
+
- Scan .catalyst/specs/*/spec.md
|
|
234
|
+
- Parse YAML frontmatter only
|
|
235
|
+
- Match by: new spec domain vs existing "affects"
|
|
236
|
+
- Load: patterns_established, key_files, key_decisions
|
|
237
|
+
- Inject into agent prompts
|
|
238
|
+
|
|
239
|
+
on_resume:
|
|
240
|
+
- Read tasks.md "## Current Session" section
|
|
241
|
+
- Continue from recorded position
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Specifications Configuration
|
|
2
|
+
|
|
3
|
+
# Command to create a new spec
|
|
4
|
+
command: "/catalyze-spec \"description\""
|
|
5
|
+
|
|
6
|
+
# Spec folder structure
|
|
7
|
+
structure:
|
|
8
|
+
root: "specs/"
|
|
9
|
+
pattern: "YYYY-MM-DD-{slug}"
|
|
10
|
+
|
|
11
|
+
# Files in each spec folder
|
|
12
|
+
files:
|
|
13
|
+
spec.md:
|
|
14
|
+
owner: scribe
|
|
15
|
+
description: "Main specification document"
|
|
16
|
+
created_by: "/catalyze-spec"
|
|
17
|
+
|
|
18
|
+
research.md:
|
|
19
|
+
owner: scribe
|
|
20
|
+
description: "Compiled research findings"
|
|
21
|
+
created_by: "/catalyze-spec"
|
|
22
|
+
|
|
23
|
+
tasks.md:
|
|
24
|
+
owner: forger
|
|
25
|
+
description: "Build DAG with task breakdown"
|
|
26
|
+
created_by: "/build-spec"
|
|
27
|
+
structure:
|
|
28
|
+
- "Build DAG (phases, scope, dependencies)"
|
|
29
|
+
- "Task details"
|
|
30
|
+
- "Progress tracking"
|
|
31
|
+
|
|
32
|
+
validation.md:
|
|
33
|
+
owner: arbiter
|
|
34
|
+
description: "Quality validation results"
|
|
35
|
+
created_by: "/validate-spec"
|
|
36
|
+
|
|
37
|
+
handoff.md:
|
|
38
|
+
owner: arbiter
|
|
39
|
+
description: "Living document, completion summary"
|
|
40
|
+
created_by: "/validate-spec"
|
|
41
|
+
|
|
42
|
+
assets/:
|
|
43
|
+
owner: any
|
|
44
|
+
description: "Images, diagrams, visual references"
|
|
45
|
+
|
|
46
|
+
# Completed specs location
|
|
47
|
+
completed: "completed/"
|
|
48
|
+
|
|
49
|
+
# Pattern library for reusable implementations
|
|
50
|
+
library:
|
|
51
|
+
root: "library/"
|
|
52
|
+
description: "Reusable patterns extracted from completed specs"
|
|
53
|
+
created_by: "/approve-spec (optional)"
|
|
54
|
+
|
|
55
|
+
# Auto-detect patterns by keywords
|
|
56
|
+
pattern_detection:
|
|
57
|
+
payment-integration.md:
|
|
58
|
+
keywords: [stripe, payment, billing, subscription, checkout]
|
|
59
|
+
authentication.md:
|
|
60
|
+
keywords: [auth, oauth, login, sso, jwt, session]
|
|
61
|
+
file-storage.md:
|
|
62
|
+
keywords: [upload, s3, storage, file, media, image]
|
|
63
|
+
real-time-communication.md:
|
|
64
|
+
keywords: [websocket, realtime, socket, live, push]
|
|
65
|
+
notifications.md:
|
|
66
|
+
keywords: [email, notification, smtp, push, alert]
|
|
67
|
+
search-implementation.md:
|
|
68
|
+
keywords: [search, elasticsearch, algolia, fulltext]
|
|
69
|
+
caching-strategy.md:
|
|
70
|
+
keywords: [cache, redis, memcached, performance]
|
|
71
|
+
background-jobs.md:
|
|
72
|
+
keywords: [queue, job, worker, bull, async, cron]
|
|
73
|
+
|
|
74
|
+
# Build DAG structure (used by Forger)
|
|
75
|
+
build_dag:
|
|
76
|
+
phases:
|
|
77
|
+
foundation:
|
|
78
|
+
agent: alchemist
|
|
79
|
+
sequential: true
|
|
80
|
+
description: "Database schema, core setup"
|
|
81
|
+
|
|
82
|
+
contracts:
|
|
83
|
+
agent: smith
|
|
84
|
+
sequential: true
|
|
85
|
+
description: "Shared types/interfaces before parallel work"
|
|
86
|
+
|
|
87
|
+
parallel:
|
|
88
|
+
agents: [smith, shaper]
|
|
89
|
+
multi_instance: true
|
|
90
|
+
description: "Scope-isolated parallel implementation"
|
|
91
|
+
rules:
|
|
92
|
+
- "Each agent has exclusive write scope"
|
|
93
|
+
- "Agents can read but not modify shared files"
|
|
94
|
+
- "No overlapping scopes between parallel tasks"
|
|
95
|
+
|
|
96
|
+
integration:
|
|
97
|
+
agent: enforcer
|
|
98
|
+
sequential: true
|
|
99
|
+
description: "Cross-boundary testing"
|
|
100
|
+
|
|
101
|
+
task_fields:
|
|
102
|
+
- id # Unique identifier
|
|
103
|
+
- agent # Which agent type (with instance: smith-1, shaper-2)
|
|
104
|
+
- scope # Files with exclusive write access
|
|
105
|
+
- reads # Files with read-only access
|
|
106
|
+
- depends_on # Task IDs that must complete first
|
|
107
|
+
- blocks # Task patterns this blocks (e.g., api-*, ui-*)
|
|
108
|
+
- acceptance # How to verify completion
|
|
109
|
+
- estimate # Time estimate (< 2 hours)
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Coding Standards
|
|
2
|
+
|
|
3
|
+
Project-wide coding conventions and style guidelines.
|
|
4
|
+
|
|
5
|
+
## General Principles
|
|
6
|
+
|
|
7
|
+
### Code Style
|
|
8
|
+
- **Clarity over cleverness** - Write code that's easy to understand
|
|
9
|
+
- **Consistency** - Follow existing patterns in the codebase
|
|
10
|
+
- **Self-documenting** - Good names reduce need for comments
|
|
11
|
+
- **Small functions** - Single responsibility, easy to test
|
|
12
|
+
|
|
13
|
+
### Naming Conventions
|
|
14
|
+
|
|
15
|
+
| Type | Convention | Example |
|
|
16
|
+
|------|------------|---------|
|
|
17
|
+
| Variables | camelCase | `userName`, `isActive` |
|
|
18
|
+
| Constants | UPPER_SNAKE | `MAX_RETRIES`, `API_URL` |
|
|
19
|
+
| Functions | camelCase | `getUserById`, `validateInput` |
|
|
20
|
+
| Classes | PascalCase | `UserService`, `PaymentHandler` |
|
|
21
|
+
| Files | kebab-case | `user-service.ts`, `payment-handler.py` |
|
|
22
|
+
| Components | PascalCase | `UserProfile.tsx`, `Button.tsx` |
|
|
23
|
+
|
|
24
|
+
### File Organization
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
src/
|
|
28
|
+
├── components/ # UI components
|
|
29
|
+
├── hooks/ # Custom React hooks
|
|
30
|
+
├── services/ # Business logic
|
|
31
|
+
├── utils/ # Utility functions
|
|
32
|
+
├── types/ # Type definitions
|
|
33
|
+
└── api/ # API routes/handlers
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## TypeScript/JavaScript
|
|
37
|
+
|
|
38
|
+
### Prefer
|
|
39
|
+
```typescript
|
|
40
|
+
// Type interfaces for objects
|
|
41
|
+
interface User {
|
|
42
|
+
id: string
|
|
43
|
+
name: string
|
|
44
|
+
email: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Const over let
|
|
48
|
+
const user = getUser()
|
|
49
|
+
|
|
50
|
+
// Async/await over promises
|
|
51
|
+
const data = await fetchData()
|
|
52
|
+
|
|
53
|
+
// Optional chaining
|
|
54
|
+
const name = user?.profile?.name
|
|
55
|
+
|
|
56
|
+
// Nullish coalescing
|
|
57
|
+
const value = input ?? defaultValue
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Avoid
|
|
61
|
+
```typescript
|
|
62
|
+
// var keyword
|
|
63
|
+
var user = getUser() // ❌
|
|
64
|
+
|
|
65
|
+
// any type
|
|
66
|
+
const data: any = {} // ❌
|
|
67
|
+
|
|
68
|
+
// Nested callbacks
|
|
69
|
+
getData(result => {
|
|
70
|
+
process(result, processed => { // ❌
|
|
71
|
+
save(processed)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Python
|
|
77
|
+
|
|
78
|
+
### Style
|
|
79
|
+
- Follow PEP 8
|
|
80
|
+
- Use type hints
|
|
81
|
+
- Docstrings for public functions
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
def get_user_by_id(user_id: str) -> User | None:
|
|
85
|
+
"""
|
|
86
|
+
Retrieve a user by their ID.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
user_id: The unique identifier for the user
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
User object if found, None otherwise
|
|
93
|
+
"""
|
|
94
|
+
return db.users.find_one({"id": user_id})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## React Components
|
|
98
|
+
|
|
99
|
+
### Function Components
|
|
100
|
+
```tsx
|
|
101
|
+
interface ButtonProps {
|
|
102
|
+
variant: 'primary' | 'secondary'
|
|
103
|
+
children: React.ReactNode
|
|
104
|
+
onClick?: () => void
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function Button({ variant, children, onClick }: ButtonProps) {
|
|
108
|
+
return (
|
|
109
|
+
<button className={styles[variant]} onClick={onClick}>
|
|
110
|
+
{children}
|
|
111
|
+
</button>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Hooks Rules
|
|
117
|
+
- Only call at top level
|
|
118
|
+
- Only call from React functions
|
|
119
|
+
- Custom hooks start with `use`
|
|
120
|
+
|
|
121
|
+
## Error Handling
|
|
122
|
+
|
|
123
|
+
### Do
|
|
124
|
+
```typescript
|
|
125
|
+
try {
|
|
126
|
+
const result = await riskyOperation()
|
|
127
|
+
return result
|
|
128
|
+
} catch (error) {
|
|
129
|
+
logger.error('Operation failed', { error })
|
|
130
|
+
throw new AppError('OPERATION_FAILED', 'Meaningful message')
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Don't
|
|
135
|
+
```typescript
|
|
136
|
+
try {
|
|
137
|
+
const result = await riskyOperation()
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.log(e) // ❌ Silent failure
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Comments
|
|
144
|
+
|
|
145
|
+
### When to Comment
|
|
146
|
+
- Complex algorithms
|
|
147
|
+
- Non-obvious business logic
|
|
148
|
+
- Workarounds with context
|
|
149
|
+
- Public API documentation
|
|
150
|
+
|
|
151
|
+
### When NOT to Comment
|
|
152
|
+
```typescript
|
|
153
|
+
// Get the user ❌ (obvious)
|
|
154
|
+
const user = getUser()
|
|
155
|
+
|
|
156
|
+
// Increment counter ❌ (obvious)
|
|
157
|
+
counter++
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Imports
|
|
161
|
+
|
|
162
|
+
### Order
|
|
163
|
+
1. External packages
|
|
164
|
+
2. Internal modules
|
|
165
|
+
3. Relative imports
|
|
166
|
+
4. Types/interfaces
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// External
|
|
170
|
+
import React from 'react'
|
|
171
|
+
import { useQuery } from '@tanstack/react-query'
|
|
172
|
+
|
|
173
|
+
// Internal
|
|
174
|
+
import { useAuth } from '@/hooks/useAuth'
|
|
175
|
+
import { Button } from '@/components/ui/Button'
|
|
176
|
+
|
|
177
|
+
// Relative
|
|
178
|
+
import { formatDate } from './utils'
|
|
179
|
+
|
|
180
|
+
// Types
|
|
181
|
+
import type { User } from '@/types'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
*Update this file to match your project's specific standards.*
|
|
187
|
+
|