@leing2021/super-pi 0.17.0 → 0.18.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.
Files changed (84) hide show
  1. package/README.md +122 -9
  2. package/package.json +2 -1
  3. package/rules/README.md +111 -0
  4. package/rules/common/agents.md +50 -0
  5. package/rules/common/code-review.md +124 -0
  6. package/rules/common/coding-style.md +90 -0
  7. package/rules/common/development-workflow.md +44 -0
  8. package/rules/common/git-workflow.md +24 -0
  9. package/rules/common/hooks.md +30 -0
  10. package/rules/common/patterns.md +31 -0
  11. package/rules/common/performance.md +55 -0
  12. package/rules/common/security.md +29 -0
  13. package/rules/common/testing.md +57 -0
  14. package/rules/cpp/coding-style.md +44 -0
  15. package/rules/cpp/hooks.md +39 -0
  16. package/rules/cpp/patterns.md +51 -0
  17. package/rules/cpp/security.md +51 -0
  18. package/rules/cpp/testing.md +44 -0
  19. package/rules/csharp/coding-style.md +72 -0
  20. package/rules/csharp/hooks.md +25 -0
  21. package/rules/csharp/patterns.md +50 -0
  22. package/rules/csharp/security.md +58 -0
  23. package/rules/csharp/testing.md +46 -0
  24. package/rules/dart/coding-style.md +159 -0
  25. package/rules/dart/hooks.md +66 -0
  26. package/rules/dart/patterns.md +261 -0
  27. package/rules/dart/security.md +135 -0
  28. package/rules/dart/testing.md +215 -0
  29. package/rules/golang/coding-style.md +32 -0
  30. package/rules/golang/hooks.md +17 -0
  31. package/rules/golang/patterns.md +45 -0
  32. package/rules/golang/security.md +34 -0
  33. package/rules/golang/testing.md +31 -0
  34. package/rules/java/coding-style.md +114 -0
  35. package/rules/java/hooks.md +18 -0
  36. package/rules/java/patterns.md +146 -0
  37. package/rules/java/security.md +100 -0
  38. package/rules/java/testing.md +131 -0
  39. package/rules/kotlin/coding-style.md +86 -0
  40. package/rules/kotlin/hooks.md +17 -0
  41. package/rules/kotlin/patterns.md +146 -0
  42. package/rules/kotlin/security.md +82 -0
  43. package/rules/kotlin/testing.md +128 -0
  44. package/rules/perl/coding-style.md +46 -0
  45. package/rules/perl/hooks.md +22 -0
  46. package/rules/perl/patterns.md +76 -0
  47. package/rules/perl/security.md +69 -0
  48. package/rules/perl/testing.md +54 -0
  49. package/rules/php/coding-style.md +40 -0
  50. package/rules/php/hooks.md +24 -0
  51. package/rules/php/patterns.md +33 -0
  52. package/rules/php/security.md +37 -0
  53. package/rules/php/testing.md +39 -0
  54. package/rules/python/coding-style.md +42 -0
  55. package/rules/python/hooks.md +19 -0
  56. package/rules/python/patterns.md +39 -0
  57. package/rules/python/security.md +30 -0
  58. package/rules/python/testing.md +38 -0
  59. package/rules/rust/coding-style.md +151 -0
  60. package/rules/rust/hooks.md +16 -0
  61. package/rules/rust/patterns.md +168 -0
  62. package/rules/rust/security.md +141 -0
  63. package/rules/rust/testing.md +154 -0
  64. package/rules/swift/coding-style.md +47 -0
  65. package/rules/swift/hooks.md +20 -0
  66. package/rules/swift/patterns.md +66 -0
  67. package/rules/swift/security.md +33 -0
  68. package/rules/swift/testing.md +45 -0
  69. package/rules/typescript/coding-style.md +199 -0
  70. package/rules/typescript/hooks.md +22 -0
  71. package/rules/typescript/patterns.md +52 -0
  72. package/rules/typescript/security.md +28 -0
  73. package/rules/typescript/testing.md +18 -0
  74. package/rules/web/coding-style.md +96 -0
  75. package/rules/web/design-quality.md +63 -0
  76. package/rules/web/hooks.md +120 -0
  77. package/rules/web/patterns.md +79 -0
  78. package/rules/web/performance.md +64 -0
  79. package/rules/web/security.md +57 -0
  80. package/rules/web/testing.md +55 -0
  81. package/skills/02-plan/SKILL.md +1 -0
  82. package/skills/03-work/SKILL.md +1 -0
  83. package/skills/04-review/SKILL.md +1 -0
  84. package/skills/10-rules/SKILL.md +68 -0
package/README.md CHANGED
@@ -85,7 +85,7 @@ Next time `02-plan` or `04-review` runs, a grep-first search strategy automatica
85
85
 
86
86
  ## Technical Architecture
87
87
 
88
- ### 9 Skills (workflow nodes)
88
+ ### 10 Skills (workflow nodes)
89
89
 
90
90
  | Skill | One-liner | Core Tool |
91
91
  |-------|-----------|-----------|
@@ -98,6 +98,7 @@ Next time `02-plan` or `04-review` runs, a grep-first search strategy automatica
98
98
  | `07-worktree` | Git worktree isolated development | `worktree_manager` |
99
99
  | `08-status` | Scan artifacts, report progress | `workflow_state`, `session_history` |
100
100
  | `09-help` | Usage guide | — |
101
+ | `10-rules` | Progressive rule loading for coding standards | — |
101
102
 
102
103
  ### 15 Tools (underlying capabilities)
103
104
 
@@ -121,9 +122,33 @@ Next time `02-plan` or `04-review` runs, a grep-first search strategy automatica
121
122
 
122
123
  ---
123
124
 
125
+ ## Token Cost
126
+
127
+ New conversation overhead: **~2,500 tokens** (1.26% of Claude Sonnet 4's 200K context).
128
+
129
+ | Component | Tokens | When loaded |
130
+ |-----------|--------|-------------|
131
+ | 10 skill registrations | ~615 | Every conversation (fixed) |
132
+ | 13 tool registrations | ~1,914 | Every conversation (fixed) |
133
+ | Hooks & filters | 0 | Runtime interception, zero prompt cost |
134
+ | Single skill trigger | ~1,000–4,000 | On-demand via `read` |
135
+ | Rules minimal (2 files) | ~900 | Before plan/work |
136
+ | Rules + language (7 files) | ~2,600 | Before work with specific language |
137
+
138
+ | vs bare Pi | vs global rules injection | vs super-pi |
139
+ |-----------|----------------------|------------|
140
+ | No rules | All rules loaded upfront | Progressive on-demand |
141
+ | No output filtering | No output filtering | Auto-compress (bash ~65–98%, read ~30–60%) |
142
+ | No TDD gate | No TDD gate | Hard gate prevents rework |
143
+ | 0 tokens | ~5,000–36,000 tokens | **~2,500 tokens** |
144
+
145
+ Single `npm install` output filtered once pays for the entire overhead. Full evaluation → [`docs/token-cost-evaluation.md`](docs/token-cost-evaluation.md)
146
+
147
+ ---
148
+
124
149
  ## Code Scale
125
150
 
126
- ~2500 lines of TypeScript implementing 15 tools, 22 Markdown reference files driving 9 skills' behavioral strategies, 162 tests covering all tool logic.
151
+ ~2500 lines of TypeScript implementing 15 tools, 22 Markdown reference files + 78 rule files driving 10 skills, 162 tests covering all tool logic.
127
152
 
128
153
  Not a heavy framework. Each tool has a single responsibility, each skill works independently, and together they form a complete workflow.
129
154
 
@@ -204,22 +229,103 @@ your-project/
204
229
 
205
230
  **Recommendation: commit everything to git** — these files are the project's traceable memory.
206
231
 
232
+ ### `10-rules`: Progressive Rule Loading
233
+
234
+ Built-in coding rules live under `rules/` in the package. The `10-rules` skill loads them **progressively** — never all at once, only what the current task needs.
235
+
236
+ **How it works:**
237
+
238
+ ```
239
+ system prompt (30 tokens: skill name + description)
240
+ → 10-rules SKILL.md (~200 tokens: loading decision tree)
241
+ → specific rule files via read tool (on-demand, 900–2600 tokens)
242
+ ```
243
+
244
+ Three CE skills auto-trigger rule loading at their entry points:
245
+
246
+ | Skill | Rules pre-loaded |
247
+ |-------|-----------------|
248
+ | `02-plan` | `common/development-workflow.md` + `common/testing.md` |
249
+ | `03-work` | Language-specific rules matching the active codebase |
250
+ | `04-review` | `common/code-review.md` + language rules for changed files |
251
+
252
+ **Rule precedence** (when layers overlap on the same topic):
253
+
254
+ ```
255
+ language-specific > web > common
256
+ ```
257
+
258
+ No rules are loaded when you brainstorm, check status, or do non-code tasks. Zero waste.
259
+
260
+ #### Included rule layers
261
+
262
+ | Layer | Files | When loaded |
263
+ |-------|-------|------------|
264
+ | `common/` | 10 files | Always (baseline for all tasks) |
265
+ | `typescript/`, `python/`, `cpp/`, `csharp/`, `dart/`, `golang/`, `java/`, `kotlin/`, `perl/`, `php/`, `rust/`, `swift/` | 5 files each | When the task touches that language |
266
+ | `web/` | 7 files (includes `design-quality.md`, `performance.md`) | When frontend/browser is relevant |
267
+
268
+ #### Customizing rules for your project
269
+
270
+ Rules are plain Markdown files in the `rules/` directory. Edit them freely:
271
+
272
+ **Add a language** — create a new directory with the 5 standard topics:
273
+
274
+ ```bash
275
+ mkdir rules/elixir
276
+ touch rules/elixir/{coding-style,testing,patterns,security,hooks}.md
277
+ ```
278
+
279
+ Each file should start with:
280
+
281
+ ```markdown
282
+ > This file extends [common/xxx.md](../common/xxx.md) with Elixir-specific content.
283
+ ```
284
+
285
+ **Remove unused languages** — just delete the directory:
286
+
287
+ ```bash
288
+ rm -rf rules/perl rules/cpp # don't need these? remove them
289
+ ```
290
+
291
+ **Tweak a rule** — edit the `.md` file directly:
292
+
293
+ ```bash
294
+ # Override testing conventions for your team
295
+ vim rules/common/testing.md
296
+
297
+ # Override for a specific language
298
+ vim rules/typescript/testing.md
299
+ ```
300
+
301
+ **Add a new topic** — create a new `.md` in the appropriate layer:
302
+
303
+ ```bash
304
+ # Common topic
305
+ vim rules/common/api-design.md
306
+
307
+ # Language-specific override
308
+ vim rules/python/api-design.md
309
+ ```
310
+
311
+ The `10-rules` skill will pick up any `.md` file in `rules/` — no configuration needed. If a language directory exists, it's available for loading. If it's gone, it's simply never loaded.
312
+
207
313
  ---
208
314
 
209
- ## Design Philosophy
315
+ ## Design Philosophy & Acknowledgements
210
316
 
211
317
  **80% planning and review, 20% execution.**
212
318
 
213
319
  The goal isn't making AI write code faster — it's making AI think before writing, review after writing, and compound learnings after reviewing. Speed comes from fewer rewrites, not from skipping steps.
214
320
 
215
- **The best ideas from four projects, reimplemented natively for Pi:**
321
+ The following projects directly inspired this work:
216
322
 
217
- - **Compound Engineering** (Every Inc.) → The five-step loop + knowledge compounding backbone
218
- - **Superpowers** (Jesse Vincent) → Strict TDD gates + design checklists + review discipline
219
- - **Everything Claude Code** (140K+ stars) → Parallel subagent orchestration + checkpoint resume + continuous learning
220
- - **gstack** (Garry Tan / YC) → YC-style forcing questions + CEO Review cognitive frameworks + browser QA
323
+ - **[everything-claude-code](https://github.com/affaan-m/everything-claude-code)** (162K★) → Parallel subagent orchestration, checkpoint resume, continuous learning
324
+ - **[superpowers](https://github.com/obra/superpowers)** (161K★) → Strict TDD gates, design checklists, review discipline
325
+ - **[gstack](https://github.com/garrytan/gstack)** (78K★) → YC-style forcing questions, CEO Review frameworks, browser QA
326
+ - **[compound-engineering-plugin](https://github.com/EveryInc/compound-engineering-plugin)** (14K★) → Five-step loop, knowledge compounding backbone
221
327
 
222
- Not a fork. Not a wrapper. The methodologies are extracted and rebuilt with Pi's native tool + skill system.
328
+ Not a fork. Not a wrapper. Methodologies extracted and rebuilt with Pi's native tool + skill system.
223
329
 
224
330
  ---
225
331
 
@@ -238,6 +344,13 @@ Not a fork. Not a wrapper. The methodologies are extracted and rebuilt with Pi's
238
344
 
239
345
  ## Changelog
240
346
 
347
+ ### 0.18.0 — Progressive rules
348
+ - Built-in `rules/` directory with 13 language layers + common + web (78 Markdown files)
349
+ - New `10-rules` skill: progressive on-demand loading, zero waste
350
+ - `02-plan`, `03-work`, `04-review` auto-trigger rule loading at entry points
351
+ - Users can add/remove languages and edit rules freely — plain Markdown, no config
352
+ - 10 skills, 15 tools, 162 tests passing
353
+
241
354
  ### 0.17.0 — Subagent safety
242
355
  - Recursion depth guard (`PI_SUBAGENT_DEPTH` / `PI_SUBAGENT_MAX_DEPTH`) prevents runaway nesting
243
356
  - Async mutex for `process.env` concurrency safety during parallel subagent execution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -24,6 +24,7 @@
24
24
  "files": [
25
25
  "skills",
26
26
  "extensions",
27
+ "rules",
27
28
  "README.md",
28
29
  "package.json"
29
30
  ],
@@ -0,0 +1,111 @@
1
+ # Rules
2
+ ## Structure
3
+
4
+ Rules are organized into a **common** layer plus **language-specific** directories:
5
+
6
+ ```
7
+ rules/
8
+ ├── common/ # Language-agnostic principles (always install)
9
+ │ ├── coding-style.md
10
+ │ ├── git-workflow.md
11
+ │ ├── testing.md
12
+ │ ├── performance.md
13
+ │ ├── patterns.md
14
+ │ ├── hooks.md
15
+ │ ├── agents.md
16
+ │ └── security.md
17
+ ├── typescript/ # TypeScript/JavaScript specific
18
+ ├── python/ # Python specific
19
+ ├── golang/ # Go specific
20
+ ├── web/ # Web and frontend specific
21
+ ├── swift/ # Swift specific
22
+ └── php/ # PHP specific
23
+ ```
24
+
25
+ - **common/** contains universal principles — no language-specific code examples.
26
+ - **Language directories** extend the common rules with framework-specific patterns, tools, and code examples. Each file references its common counterpart.
27
+
28
+ ## Installation
29
+
30
+ ### Option 1: Install Script (Recommended)
31
+
32
+ ```bash
33
+ # Install common + one or more language-specific rule sets
34
+ ./install.sh typescript
35
+ ./install.sh python
36
+ ./install.sh golang
37
+ ./install.sh web
38
+ ./install.sh swift
39
+ ./install.sh php
40
+
41
+ # Install multiple languages at once
42
+ ./install.sh typescript python
43
+ ```
44
+
45
+ ### Option 2: Manual Installation
46
+
47
+ > **Important:** Copy entire directories — do NOT flatten with `/*`.
48
+ > Common and language-specific directories contain files with the same names.
49
+ > Flattening them into one directory causes language-specific files to overwrite
50
+ > common rules, and breaks the relative `../common/` references used by
51
+ > language-specific files.
52
+
53
+ ```bash
54
+ # Install common rules (required for all projects)
55
+ cp -r rules/common ~/.claude/rules/common
56
+
57
+ # Install language-specific rules based on your project's tech stack
58
+ cp -r rules/typescript ~/.claude/rules/typescript
59
+ cp -r rules/python ~/.claude/rules/python
60
+ cp -r rules/golang ~/.claude/rules/golang
61
+ cp -r rules/web ~/.claude/rules/web
62
+ cp -r rules/swift ~/.claude/rules/swift
63
+ cp -r rules/php ~/.claude/rules/php
64
+
65
+ # Attention ! ! ! Configure according to your actual project requirements; the configuration here is for reference only.
66
+ ```
67
+
68
+ ## Rules vs Skills
69
+
70
+ - **Rules** define standards, conventions, and checklists that apply broadly (e.g., "80% test coverage", "no hardcoded secrets").
71
+ - **Skills** (`skills/` directory) provide deep, actionable reference material for specific tasks (e.g., `python-patterns`, `golang-testing`).
72
+
73
+ Language-specific rule files reference relevant skills where appropriate. Rules tell you *what* to do; skills tell you *how* to do it.
74
+
75
+ ## Adding a New Language
76
+
77
+ To add support for a new language (e.g., `rust/`):
78
+
79
+ 1. Create a `rules/rust/` directory
80
+ 2. Add files that extend the common rules:
81
+ - `coding-style.md` — formatting tools, idioms, error handling patterns
82
+ - `testing.md` — test framework, coverage tools, test organization
83
+ - `patterns.md` — language-specific design patterns
84
+ - `hooks.md` — PostToolUse hooks for formatters, linters, type checkers
85
+ - `security.md` — secret management, security scanning tools
86
+ 3. Each file should start with:
87
+ ```
88
+ > This file extends [common/xxx.md](../common/xxx.md) with <Language> specific content.
89
+ ```
90
+ 4. Reference existing skills if available, or create new ones under `skills/`.
91
+
92
+ For non-language domains like `web/`, follow the same layered pattern when there is enough reusable domain-specific guidance to justify a standalone ruleset.
93
+
94
+ ## Rule Priority
95
+
96
+ When language-specific rules and common rules conflict, **language-specific rules take precedence** (specific overrides general). This follows the standard layered configuration pattern (similar to CSS specificity or `.gitignore` precedence).
97
+
98
+ - `rules/common/` defines universal defaults applicable to all projects.
99
+ - `rules/golang/`, `rules/python/`, `rules/swift/`, `rules/php/`, `rules/typescript/`, etc. override those defaults where language idioms differ.
100
+
101
+ ### Example
102
+
103
+ `common/coding-style.md` recommends immutability as a default principle. A language-specific `golang/coding-style.md` can override this:
104
+
105
+ > Idiomatic Go uses pointer receivers for struct mutation — see [common/coding-style.md](../common/coding-style.md) for the general principle, but Go-idiomatic mutation is preferred here.
106
+
107
+ ### Common rules with override notes
108
+
109
+ Rules in `rules/common/` that may be overridden by language-specific files are marked with:
110
+
111
+ > **Language note**: This rule may be overridden by language-specific rules for languages where this pattern is not idiomatic.
@@ -0,0 +1,50 @@
1
+ # Agent Orchestration
2
+
3
+ ## Available Agents
4
+
5
+ Located in `~/.claude/agents/`:
6
+
7
+ | Agent | Purpose | When to Use |
8
+ |-------|---------|-------------|
9
+ | planner | Implementation planning | Complex features, refactoring |
10
+ | architect | System design | Architectural decisions |
11
+ | tdd-guide | Test-driven development | New features, bug fixes |
12
+ | code-reviewer | Code review | After writing code |
13
+ | security-reviewer | Security analysis | Before commits |
14
+ | build-error-resolver | Fix build errors | When build fails |
15
+ | e2e-runner | E2E testing | Critical user flows |
16
+ | refactor-cleaner | Dead code cleanup | Code maintenance |
17
+ | doc-updater | Documentation | Updating docs |
18
+ | rust-reviewer | Rust code review | Rust projects |
19
+
20
+ ## Immediate Agent Usage
21
+
22
+ No user prompt needed:
23
+ 1. Complex feature requests - Use **planner** agent
24
+ 2. Code just written/modified - Use **code-reviewer** agent
25
+ 3. Bug fix or new feature - Use **tdd-guide** agent
26
+ 4. Architectural decision - Use **architect** agent
27
+
28
+ ## Parallel Task Execution
29
+
30
+ ALWAYS use parallel Task execution for independent operations:
31
+
32
+ ```markdown
33
+ # GOOD: Parallel execution
34
+ Launch 3 agents in parallel:
35
+ 1. Agent 1: Security analysis of auth module
36
+ 2. Agent 2: Performance review of cache system
37
+ 3. Agent 3: Type checking of utilities
38
+
39
+ # BAD: Sequential when unnecessary
40
+ First agent 1, then agent 2, then agent 3
41
+ ```
42
+
43
+ ## Multi-Perspective Analysis
44
+
45
+ For complex problems, use split role sub-agents:
46
+ - Factual reviewer
47
+ - Senior engineer
48
+ - Security expert
49
+ - Consistency reviewer
50
+ - Redundancy checker
@@ -0,0 +1,124 @@
1
+ # Code Review Standards
2
+
3
+ ## Purpose
4
+
5
+ Code review ensures quality, security, and maintainability before code is merged. This rule defines when and how to conduct code reviews.
6
+
7
+ ## When to Review
8
+
9
+ **MANDATORY review triggers:**
10
+
11
+ - After writing or modifying code
12
+ - Before any commit to shared branches
13
+ - When security-sensitive code is changed (auth, payments, user data)
14
+ - When architectural changes are made
15
+ - Before merging pull requests
16
+
17
+ **Pre-Review Requirements:**
18
+
19
+ Before requesting review, ensure:
20
+
21
+ - All automated checks (CI/CD) are passing
22
+ - Merge conflicts are resolved
23
+ - Branch is up to date with target branch
24
+
25
+ ## Review Checklist
26
+
27
+ Before marking code complete:
28
+
29
+ - [ ] Code is readable and well-named
30
+ - [ ] Functions are focused (<50 lines)
31
+ - [ ] Files are cohesive (<800 lines)
32
+ - [ ] No deep nesting (>4 levels)
33
+ - [ ] Errors are handled explicitly
34
+ - [ ] No hardcoded secrets or credentials
35
+ - [ ] No console.log or debug statements
36
+ - [ ] Tests exist for new functionality
37
+ - [ ] Test coverage meets 80% minimum
38
+
39
+ ## Security Review Triggers
40
+
41
+ **STOP and use security-reviewer agent when:**
42
+
43
+ - Authentication or authorization code
44
+ - User input handling
45
+ - Database queries
46
+ - File system operations
47
+ - External API calls
48
+ - Cryptographic operations
49
+ - Payment or financial code
50
+
51
+ ## Review Severity Levels
52
+
53
+ | Level | Meaning | Action |
54
+ |-------|---------|--------|
55
+ | CRITICAL | Security vulnerability or data loss risk | **BLOCK** - Must fix before merge |
56
+ | HIGH | Bug or significant quality issue | **WARN** - Should fix before merge |
57
+ | MEDIUM | Maintainability concern | **INFO** - Consider fixing |
58
+ | LOW | Style or minor suggestion | **NOTE** - Optional |
59
+
60
+ ## Agent Usage
61
+
62
+ Use these agents for code review:
63
+
64
+ | Agent | Purpose |
65
+ |-------|---------|
66
+ | **code-reviewer** | General code quality, patterns, best practices |
67
+ | **security-reviewer** | Security vulnerabilities, OWASP Top 10 |
68
+ | **typescript-reviewer** | TypeScript/JavaScript specific issues |
69
+ | **python-reviewer** | Python specific issues |
70
+ | **go-reviewer** | Go specific issues |
71
+ | **rust-reviewer** | Rust specific issues |
72
+
73
+ ## Review Workflow
74
+
75
+ ```
76
+ 1. Run git diff to understand changes
77
+ 2. Check security checklist first
78
+ 3. Review code quality checklist
79
+ 4. Run relevant tests
80
+ 5. Verify coverage >= 80%
81
+ 6. Use appropriate agent for detailed review
82
+ ```
83
+
84
+ ## Common Issues to Catch
85
+
86
+ ### Security
87
+
88
+ - Hardcoded credentials (API keys, passwords, tokens)
89
+ - SQL injection (string concatenation in queries)
90
+ - XSS vulnerabilities (unescaped user input)
91
+ - Path traversal (unsanitized file paths)
92
+ - CSRF protection missing
93
+ - Authentication bypasses
94
+
95
+ ### Code Quality
96
+
97
+ - Large functions (>50 lines) - split into smaller
98
+ - Large files (>800 lines) - extract modules
99
+ - Deep nesting (>4 levels) - use early returns
100
+ - Missing error handling - handle explicitly
101
+ - Mutation patterns - prefer immutable operations
102
+ - Missing tests - add test coverage
103
+
104
+ ### Performance
105
+
106
+ - N+1 queries - use JOINs or batching
107
+ - Missing pagination - add LIMIT to queries
108
+ - Unbounded queries - add constraints
109
+ - Missing caching - cache expensive operations
110
+
111
+ ## Approval Criteria
112
+
113
+ - **Approve**: No CRITICAL or HIGH issues
114
+ - **Warning**: Only HIGH issues (merge with caution)
115
+ - **Block**: CRITICAL issues found
116
+
117
+ ## Integration with Other Rules
118
+
119
+ This rule works with:
120
+
121
+ - [testing.md](testing.md) - Test coverage requirements
122
+ - [security.md](security.md) - Security checklist
123
+ - [git-workflow.md](git-workflow.md) - Commit standards
124
+ - [agents.md](agents.md) - Agent delegation
@@ -0,0 +1,90 @@
1
+ # Coding Style
2
+
3
+ ## Immutability (CRITICAL)
4
+
5
+ ALWAYS create new objects, NEVER mutate existing ones:
6
+
7
+ ```
8
+ // Pseudocode
9
+ WRONG: modify(original, field, value) → changes original in-place
10
+ CORRECT: update(original, field, value) → returns new copy with change
11
+ ```
12
+
13
+ Rationale: Immutable data prevents hidden side effects, makes debugging easier, and enables safe concurrency.
14
+
15
+ ## Core Principles
16
+
17
+ ### KISS (Keep It Simple)
18
+
19
+ - Prefer the simplest solution that actually works
20
+ - Avoid premature optimization
21
+ - Optimize for clarity over cleverness
22
+
23
+ ### DRY (Don't Repeat Yourself)
24
+
25
+ - Extract repeated logic into shared functions or utilities
26
+ - Avoid copy-paste implementation drift
27
+ - Introduce abstractions when repetition is real, not speculative
28
+
29
+ ### YAGNI (You Aren't Gonna Need It)
30
+
31
+ - Do not build features or abstractions before they are needed
32
+ - Avoid speculative generality
33
+ - Start simple, then refactor when the pressure is real
34
+
35
+ ## File Organization
36
+
37
+ MANY SMALL FILES > FEW LARGE FILES:
38
+ - High cohesion, low coupling
39
+ - 200-400 lines typical, 800 max
40
+ - Extract utilities from large modules
41
+ - Organize by feature/domain, not by type
42
+
43
+ ## Error Handling
44
+
45
+ ALWAYS handle errors comprehensively:
46
+ - Handle errors explicitly at every level
47
+ - Provide user-friendly error messages in UI-facing code
48
+ - Log detailed error context on the server side
49
+ - Never silently swallow errors
50
+
51
+ ## Input Validation
52
+
53
+ ALWAYS validate at system boundaries:
54
+ - Validate all user input before processing
55
+ - Use schema-based validation where available
56
+ - Fail fast with clear error messages
57
+ - Never trust external data (API responses, user input, file content)
58
+
59
+ ## Naming Conventions
60
+
61
+ - Variables and functions: `camelCase` with descriptive names
62
+ - Booleans: prefer `is`, `has`, `should`, or `can` prefixes
63
+ - Interfaces, types, and components: `PascalCase`
64
+ - Constants: `UPPER_SNAKE_CASE`
65
+ - Custom hooks: `camelCase` with a `use` prefix
66
+
67
+ ## Code Smells to Avoid
68
+
69
+ ### Deep Nesting
70
+
71
+ Prefer early returns over nested conditionals once the logic starts stacking.
72
+
73
+ ### Magic Numbers
74
+
75
+ Use named constants for meaningful thresholds, delays, and limits.
76
+
77
+ ### Long Functions
78
+
79
+ Split large functions into focused pieces with clear responsibilities.
80
+
81
+ ## Code Quality Checklist
82
+
83
+ Before marking work complete:
84
+ - [ ] Code is readable and well-named
85
+ - [ ] Functions are small (<50 lines)
86
+ - [ ] Files are focused (<800 lines)
87
+ - [ ] No deep nesting (>4 levels)
88
+ - [ ] Proper error handling
89
+ - [ ] No hardcoded values (use constants or config)
90
+ - [ ] No mutation (immutable patterns used)
@@ -0,0 +1,44 @@
1
+ # Development Workflow
2
+
3
+ > This file extends [common/git-workflow.md](./git-workflow.md) with the full feature development process that happens before git operations.
4
+
5
+ The Feature Implementation Workflow describes the development pipeline: research, planning, TDD, code review, and then committing to git.
6
+
7
+ ## Feature Implementation Workflow
8
+
9
+ 0. **Research & Reuse** _(mandatory before any new implementation)_
10
+ - **GitHub code search first:** Run `gh search repos` and `gh search code` to find existing implementations, templates, and patterns before writing anything new.
11
+ - **Library docs second:** Use Context7 or primary vendor docs to confirm API behavior, package usage, and version-specific details before implementing.
12
+ - **Exa only when the first two are insufficient:** Use Exa for broader web research or discovery after GitHub search and primary docs.
13
+ - **Check package registries:** Search npm, PyPI, crates.io, and other registries before writing utility code. Prefer battle-tested libraries over hand-rolled solutions.
14
+ - **Search for adaptable implementations:** Look for open-source projects that solve 80%+ of the problem and can be forked, ported, or wrapped.
15
+ - Prefer adopting or porting a proven approach over writing net-new code when it meets the requirement.
16
+
17
+ 1. **Plan First**
18
+ - Use **planner** agent to create implementation plan
19
+ - Generate planning docs before coding: PRD, architecture, system_design, tech_doc, task_list
20
+ - Identify dependencies and risks
21
+ - Break down into phases
22
+
23
+ 2. **TDD Approach**
24
+ - Use **tdd-guide** agent
25
+ - Write tests first (RED)
26
+ - Implement to pass tests (GREEN)
27
+ - Refactor (IMPROVE)
28
+ - Verify 80%+ coverage
29
+
30
+ 3. **Code Review**
31
+ - Use **code-reviewer** agent immediately after writing code
32
+ - Address CRITICAL and HIGH issues
33
+ - Fix MEDIUM issues when possible
34
+
35
+ 4. **Commit & Push**
36
+ - Detailed commit messages
37
+ - Follow conventional commits format
38
+ - See [git-workflow.md](./git-workflow.md) for commit message format and PR process
39
+
40
+ 5. **Pre-Review Checks**
41
+ - Verify all automated checks (CI/CD) are passing
42
+ - Resolve any merge conflicts
43
+ - Ensure branch is up to date with target branch
44
+ - Only request review after these checks pass
@@ -0,0 +1,24 @@
1
+ # Git Workflow
2
+
3
+ ## Commit Message Format
4
+ ```
5
+ <type>: <description>
6
+
7
+ <optional body>
8
+ ```
9
+
10
+ Types: feat, fix, refactor, docs, test, chore, perf, ci
11
+
12
+ Note: Attribution disabled globally via ~/.claude/settings.json.
13
+
14
+ ## Pull Request Workflow
15
+
16
+ When creating PRs:
17
+ 1. Analyze full commit history (not just latest commit)
18
+ 2. Use `git diff [base-branch]...HEAD` to see all changes
19
+ 3. Draft comprehensive PR summary
20
+ 4. Include test plan with TODOs
21
+ 5. Push with `-u` flag if new branch
22
+
23
+ > For the full development process (planning, TDD, code review) before git operations,
24
+ > see [development-workflow.md](./development-workflow.md).
@@ -0,0 +1,30 @@
1
+ # Hooks System
2
+
3
+ ## Hook Types
4
+
5
+ - **PreToolUse**: Before tool execution (validation, parameter modification)
6
+ - **PostToolUse**: After tool execution (auto-format, checks)
7
+ - **Stop**: When session ends (final verification)
8
+
9
+ ## Auto-Accept Permissions
10
+
11
+ Use with caution:
12
+ - Enable for trusted, well-defined plans
13
+ - Disable for exploratory work
14
+ - Never use dangerously-skip-permissions flag
15
+ - Configure `allowedTools` in `~/.claude.json` instead
16
+
17
+ ## TodoWrite Best Practices
18
+
19
+ Use TodoWrite tool to:
20
+ - Track progress on multi-step tasks
21
+ - Verify understanding of instructions
22
+ - Enable real-time steering
23
+ - Show granular implementation steps
24
+
25
+ Todo list reveals:
26
+ - Out of order steps
27
+ - Missing items
28
+ - Extra unnecessary items
29
+ - Wrong granularity
30
+ - Misinterpreted requirements