cfsa-antigravity 2.0.0 → 2.2.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 (116) hide show
  1. package/README.md +14 -0
  2. package/package.json +1 -1
  3. package/template/.agent/instructions/commands.md +8 -32
  4. package/template/.agent/instructions/example.md +21 -0
  5. package/template/.agent/instructions/patterns.md +3 -3
  6. package/template/.agent/instructions/tech-stack.md +71 -23
  7. package/template/.agent/instructions/workflow.md +12 -1
  8. package/template/.agent/rules/completion-checklist.md +6 -0
  9. package/template/.agent/rules/security-first.md +3 -3
  10. package/template/.agent/rules/vertical-slices.md +1 -1
  11. package/template/.agent/skill-library/MANIFEST.md +6 -0
  12. package/template/.agent/skill-library/stack/devops/git-advanced/SKILL.md +972 -0
  13. package/template/.agent/skill-library/stack/devops/git-workflow/SKILL.md +420 -0
  14. package/template/.agent/skills/api-versioning/SKILL.md +44 -298
  15. package/template/.agent/skills/api-versioning/references/typescript.md +157 -0
  16. package/template/.agent/skills/architecture-mapping/SKILL.md +13 -13
  17. package/template/.agent/skills/bootstrap-agents/SKILL.md +151 -152
  18. package/template/.agent/skills/clean-code/SKILL.md +64 -118
  19. package/template/.agent/skills/clean-code/references/typescript.md +126 -0
  20. package/template/.agent/skills/database-schema-design/SKILL.md +93 -317
  21. package/template/.agent/skills/database-schema-design/references/relational.md +228 -0
  22. package/template/.agent/skills/error-handling-patterns/SKILL.md +62 -557
  23. package/template/.agent/skills/error-handling-patterns/references/go.md +162 -0
  24. package/template/.agent/skills/error-handling-patterns/references/python.md +262 -0
  25. package/template/.agent/skills/error-handling-patterns/references/rust.md +112 -0
  26. package/template/.agent/skills/error-handling-patterns/references/typescript.md +178 -0
  27. package/template/.agent/skills/idea-extraction/SKILL.md +322 -224
  28. package/template/.agent/skills/logging-best-practices/SKILL.md +108 -767
  29. package/template/.agent/skills/logging-best-practices/references/go.md +49 -0
  30. package/template/.agent/skills/logging-best-practices/references/python.md +52 -0
  31. package/template/.agent/skills/logging-best-practices/references/typescript.md +215 -0
  32. package/template/.agent/skills/migration-management/SKILL.md +127 -311
  33. package/template/.agent/skills/migration-management/references/relational.md +214 -0
  34. package/template/.agent/skills/parallel-feature-development/SKILL.md +34 -43
  35. package/template/.agent/skills/pipeline-rubrics/references/be-rubric.md +1 -1
  36. package/template/.agent/skills/pipeline-rubrics/references/ia-rubric.md +2 -2
  37. package/template/.agent/skills/pipeline-rubrics/references/scoring.md +1 -1
  38. package/template/.agent/skills/pipeline-rubrics/references/vision-rubric.md +2 -1
  39. package/template/.agent/skills/prd-templates/SKILL.md +23 -6
  40. package/template/.agent/skills/prd-templates/references/be-spec-template.md +2 -2
  41. package/template/.agent/skills/prd-templates/references/decomposition-templates.md +2 -2
  42. package/template/.agent/skills/prd-templates/references/engineering-standards-template.md +2 -0
  43. package/template/.agent/skills/prd-templates/references/fe-spec-template.md +1 -1
  44. package/template/.agent/skills/prd-templates/references/fractal-cx-template.md +58 -0
  45. package/template/.agent/skills/prd-templates/references/fractal-feature-template.md +93 -0
  46. package/template/.agent/skills/prd-templates/references/fractal-node-index-template.md +55 -0
  47. package/template/.agent/skills/prd-templates/references/ideation-crosscut-template.md +26 -47
  48. package/template/.agent/skills/prd-templates/references/ideation-index-template.md +47 -31
  49. package/template/.agent/skills/prd-templates/references/operational-templates.md +1 -1
  50. package/template/.agent/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -21
  51. package/template/.agent/skills/prd-templates/references/skill-loading-protocol.md +32 -0
  52. package/template/.agent/skills/prd-templates/references/slice-completion-gates.md +29 -0
  53. package/template/.agent/skills/prd-templates/references/spec-coverage-sweep.md +3 -3
  54. package/template/.agent/skills/prd-templates/references/tdd-testing-policy.md +39 -0
  55. package/template/.agent/skills/prd-templates/references/vision-template.md +8 -8
  56. package/template/.agent/skills/regex-patterns/SKILL.md +122 -540
  57. package/template/.agent/skills/regex-patterns/references/go.md +44 -0
  58. package/template/.agent/skills/regex-patterns/references/javascript.md +63 -0
  59. package/template/.agent/skills/regex-patterns/references/python.md +77 -0
  60. package/template/.agent/skills/regex-patterns/references/rust.md +43 -0
  61. package/template/.agent/skills/resolve-ambiguity/SKILL.md +1 -1
  62. package/template/.agent/skills/session-continuity/SKILL.md +11 -9
  63. package/template/.agent/skills/session-continuity/protocols/02-progress-generation.md +2 -2
  64. package/template/.agent/skills/session-continuity/protocols/04-pattern-extraction.md +1 -1
  65. package/template/.agent/skills/session-continuity/protocols/05-session-close.md +1 -1
  66. package/template/.agent/skills/session-continuity/protocols/09-parallel-claim.md +1 -1
  67. package/template/.agent/skills/session-continuity/protocols/10-placeholder-verification-gate.md +57 -78
  68. package/template/.agent/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
  69. package/template/.agent/skills/spec-writing/SKILL.md +1 -1
  70. package/template/.agent/skills/tdd-workflow/SKILL.md +94 -317
  71. package/template/.agent/skills/tdd-workflow/references/typescript.md +231 -0
  72. package/template/.agent/skills/testing-strategist/SKILL.md +74 -687
  73. package/template/.agent/skills/testing-strategist/references/typescript.md +328 -0
  74. package/template/.agent/skills/workflow-automation/SKILL.md +62 -154
  75. package/template/.agent/skills/workflow-automation/references/inngest.md +88 -0
  76. package/template/.agent/skills/workflow-automation/references/temporal.md +64 -0
  77. package/template/.agent/workflows/bootstrap-agents-fill.md +85 -143
  78. package/template/.agent/workflows/bootstrap-agents-provision.md +90 -107
  79. package/template/.agent/workflows/create-prd-architecture.md +23 -16
  80. package/template/.agent/workflows/create-prd-compile.md +11 -12
  81. package/template/.agent/workflows/create-prd-design-system.md +1 -1
  82. package/template/.agent/workflows/create-prd-security.md +9 -11
  83. package/template/.agent/workflows/create-prd-stack.md +10 -4
  84. package/template/.agent/workflows/create-prd.md +9 -9
  85. package/template/.agent/workflows/decompose-architecture-structure.md +4 -6
  86. package/template/.agent/workflows/decompose-architecture-validate.md +18 -1
  87. package/template/.agent/workflows/decompose-architecture.md +18 -3
  88. package/template/.agent/workflows/evolve-contract.md +11 -11
  89. package/template/.agent/workflows/evolve-feature-classify.md +14 -6
  90. package/template/.agent/workflows/ideate-discover.md +72 -107
  91. package/template/.agent/workflows/ideate-extract.md +84 -63
  92. package/template/.agent/workflows/ideate-validate.md +26 -22
  93. package/template/.agent/workflows/ideate.md +9 -9
  94. package/template/.agent/workflows/implement-slice-setup.md +25 -23
  95. package/template/.agent/workflows/implement-slice-tdd.md +73 -89
  96. package/template/.agent/workflows/implement-slice.md +4 -4
  97. package/template/.agent/workflows/plan-phase-preflight.md +6 -2
  98. package/template/.agent/workflows/plan-phase-write.md +6 -8
  99. package/template/.agent/workflows/remediate-pipeline-assess.md +2 -1
  100. package/template/.agent/workflows/resolve-ambiguity.md +2 -2
  101. package/template/.agent/workflows/update-architecture-map.md +22 -5
  102. package/template/.agent/workflows/validate-phase-quality.md +155 -0
  103. package/template/.agent/workflows/validate-phase-readiness.md +167 -0
  104. package/template/.agent/workflows/validate-phase.md +19 -157
  105. package/template/.agent/workflows/verify-infrastructure.md +10 -10
  106. package/template/.agent/workflows/write-architecture-spec-design.md +23 -14
  107. package/template/.agent/workflows/write-be-spec-classify.md +25 -21
  108. package/template/.agent/workflows/write-be-spec.md +1 -1
  109. package/template/.agent/workflows/write-fe-spec-classify.md +6 -12
  110. package/template/.agent/workflows/write-fe-spec-write.md +1 -1
  111. package/template/AGENTS.md +6 -2
  112. package/template/GEMINI.md +5 -3
  113. package/template/docs/README.md +10 -10
  114. package/template/docs/kit-architecture.md +126 -33
  115. package/template/docs/plans/ideation/README.md +8 -3
  116. package/template/.agent/skills/prd-templates/references/ideation-domain-template.md +0 -55
@@ -2,9 +2,6 @@
2
2
  name: clean-code
3
3
  description: "Applies battle-tested clean code principles to writing, reviewing, and refactoring code. Covers naming, functions, comments, error handling, class design, and the critical difference between clever code and clear code."
4
4
  version: 2.0.0
5
- source: self
6
- date_added: "2026-02-27"
7
- date_rewritten: "2026-03-14"
8
5
  ---
9
6
 
10
7
  # Clean Code
@@ -18,6 +15,17 @@ Code is read 10x more than it's written. Every naming choice, every function bou
18
15
  - Refactoring existing code
19
16
  - When code "works but feels wrong"
20
17
 
18
+ ## Stack-Specific References
19
+
20
+ The principles below are language-agnostic. For idiomatic patterns and syntax, read the reference matching your surface's Languages column:
21
+
22
+ | Language | Reference |
23
+ |----------|-----------|
24
+ | TypeScript / JavaScript | `references/typescript.md` |
25
+ | Python | `references/python.md` |
26
+ | Go | `references/go.md` |
27
+ | Rust | `references/rust.md` |
28
+
21
29
  ## Core Principles
22
30
 
23
31
  ### 1. Names Are Documentation
@@ -36,7 +44,7 @@ Names should reveal intent. If a name requires a comment to explain it, the name
36
44
  | `Utils` | `StringFormatter` | Util for what? |
37
45
 
38
46
  **Rules:**
39
- - Classes → nouns (`UserRepository`, `PaymentGateway`)
47
+ - Classes/types → nouns (`UserRepository`, `PaymentGateway`)
40
48
  - Functions → verbs (`calculateTotal`, `sendNotification`)
41
49
  - Booleans → questions (`isActive`, `hasPermission`, `canEdit`)
42
50
  - Constants → screaming snake with context (`MAX_RETRY_ATTEMPTS`, not `MAX`)
@@ -48,46 +56,16 @@ A function that does one thing well is easy to name, test, and reuse. A function
48
56
 
49
57
  **The test:** Can you describe the function without using "and"? If not, split it.
50
58
 
51
- ```typescript
52
- // Does three things
53
- function processOrder(order: Order): void {
54
- // Validate
55
- if (!order.items.length) throw new Error("Empty order");
56
- if (!order.customer) throw new Error("No customer");
57
-
58
- // Calculate
59
- let total = 0;
60
- for (const item of order.items) {
61
- total += item.price * item.quantity;
62
- if (item.taxable) total += item.price * 0.08;
63
- }
64
-
65
- // Save
66
- db.orders.insert({ ...order, total, status: "pending" });
67
- emailService.send(order.customer.email, "Order confirmed");
68
- }
69
-
70
- // ✅ Each function does one thing
71
- function validateOrder(order: Order): void {
72
- if (!order.items.length) throw new InvalidOrderError("Empty order");
73
- if (!order.customer) throw new InvalidOrderError("No customer");
74
- }
75
-
76
- function calculateOrderTotal(items: OrderItem[]): number {
77
- return items.reduce((total, item) => {
78
- const subtotal = item.price * item.quantity;
79
- const tax = item.taxable ? item.price * TAX_RATE : 0;
80
- return total + subtotal + tax;
81
- }, 0);
82
- }
83
-
84
- function submitOrder(order: Order): OrderConfirmation {
85
- validateOrder(order);
86
- const total = calculateOrderTotal(order.items);
87
- const saved = db.orders.insert({ ...order, total, status: "pending" });
88
- emailService.send(order.customer.email, "Order confirmed");
89
- return { orderId: saved.id, total };
90
- }
59
+ ```
60
+ processOrder(order)
61
+ validates order
62
+ calculates total with tax
63
+ saves to database
64
+ sends confirmation email
65
+
66
+ validateOrder(order) → throws if invalid
67
+ calculateOrderTotal(items) returns numeric total
68
+ submitOrder(order) → orchestrates the above
91
69
  ```
92
70
 
93
71
  **Function size limits:**
@@ -100,111 +78,79 @@ function submitOrder(order: Order): OrderConfirmation {
100
78
 
101
79
  - **0-2 parameters**: ideal
102
80
  - **3 parameters**: acceptable with named/destructured args
103
- - **4+ parameters**: use an options object
81
+ - **4+ parameters**: use an options object/struct/dataclass
104
82
  - **Boolean parameters**: almost always a code smell — split into two functions
105
83
 
106
- ```typescript
107
- // Boolean flag parameter
108
- function createUser(name: string, isAdmin: boolean): User { ... }
109
-
110
- // Two clear functions
111
- function createUser(name: string): User { ... }
112
- function createAdmin(name: string): User { ... }
113
-
114
- // ❌ Too many positional args
115
- function sendEmail(to: string, from: string, subject: string, body: string, cc?: string): void { ... }
116
-
117
- // ✅ Options object
118
- interface SendEmailOptions {
119
- to: string;
120
- from: string;
121
- subject: string;
122
- body: string;
123
- cc?: string;
124
- }
125
- function sendEmail(options: SendEmailOptions): void { ... }
84
+ ```
85
+ createUser(name, isAdmin)
86
+ createUser(name) / createAdmin(name)
87
+
88
+ sendEmail(to, from, subject, body, cc)
89
+ sendEmail(options) options is a structured type
126
90
  ```
127
91
 
128
92
  ### 4. Comments: Why, Not What
129
93
 
130
94
  Good code doesn't need comments to explain WHAT it does. Comments should explain WHY — the non-obvious reasoning, business rules, or constraints.
131
95
 
132
- ```typescript
133
- // Comment explains what (redundant)
134
- // Increment counter by one
135
- counter += 1;
96
+ ```
97
+ // Increment counter by one
98
+ counter += 1
136
99
 
137
- // Comment explains obvious logic
138
- // Check if user is admin
139
- if (user.role === "admin") { ... }
100
+ // Check if user is admin
101
+ if user.role == "admin"
140
102
 
141
- // Comment explains WHY
142
- // Stripe requires amount in cents, not dollars
143
- const amountInCents = Math.round(price * 100);
103
+ // Stripe requires amount in cents, not dollars
104
+ amountInCents = round(price * 100)
144
105
 
145
- // Comment explains business rule
146
- // FDA regulation 21 CFR Part 11 requires audit trail for all changes
147
- await auditLog.record(changeEvent);
106
+ // FDA regulation 21 CFR Part 11 requires audit trail
107
+ auditLog.record(changeEvent)
148
108
 
149
- // Comment warns about non-obvious consequence
150
- // WARNING: This query locks the orders table — avoid running during peak hours
151
- await db.execute(batchUpdateQuery);
109
+ // WARNING: This query locks the orders table — avoid during peak hours
110
+ db.execute(batchUpdateQuery)
152
111
  ```
153
112
 
154
113
  **Delete these comments immediately:**
155
114
  - `// TODO: fix this later` — fix it now or create a tracked issue
156
115
  - `// This is a hack` — then don't commit the hack
157
116
  - `// I don't know why this works` — figure it out before shipping
158
- - Commented-out code — delete it; git has your history
117
+ - Commented-out code — delete it; version control has your history
159
118
 
160
119
  ### 5. Error Handling
161
120
 
162
121
  Errors are not edge cases — they're expected behavior. Handle them explicitly.
163
122
 
164
- ```typescript
165
- // Swallowing errors
166
- try {
167
- await saveOrder(order);
168
- } catch (e) {
169
- console.log("error"); // What error? What happens to the order?
170
- }
171
-
172
- // ❌ Generic catch-all
173
- try {
174
- await processPayment(order);
175
- } catch (e) {
176
- throw new Error("Something went wrong"); // Useless to the caller
177
- }
178
-
179
- // Specific, actionable error handling
180
- try {
181
- await processPayment(order);
182
- } catch (error) {
183
- if (error instanceof InsufficientFundsError) {
184
- return { success: false, code: "INSUFFICIENT_FUNDS", retry: false };
185
- }
186
- if (error instanceof PaymentGatewayError) {
187
- logger.error("Payment gateway failure", { orderId: order.id, error });
188
- return { success: false, code: "GATEWAY_ERROR", retry: true };
189
- }
190
- throw error; // Unknown errors bubble up
191
- }
123
+ ```
124
+ try { save(order) } catch { log("error") }
125
+ What error? What happens to the order?
126
+
127
+ ❌ try { processPayment(order) } catch { throw Error("Something went wrong") }
128
+ Useless to the caller
129
+
130
+ ✅ try {
131
+ processPayment(order)
132
+ } catch InsufficientFundsError:
133
+ return { success: false, code: "INSUFFICIENT_FUNDS", retry: false }
134
+ catch PaymentGatewayError:
135
+ logger.error("Payment gateway failure", { orderId: order.id })
136
+ return { success: false, code: "GATEWAY_ERROR", retry: true }
137
+ catch unknown:
138
+ rethrow → Unknown errors bubble up
192
139
  ```
193
140
 
194
141
  ### 6. Don't Repeat Yourself (DRY) — But Don't Over-Abstract
195
142
 
196
143
  **DRY violation** — same logic copy-pasted in 3+ places:
197
- ```typescript
198
- // If you change the tax rate, you need to find and update all copies
199
- const tax1 = price1 * 0.08;
200
- const tax2 = price2 * 0.08;
201
- const tax3 = price3 * 0.08;
144
+ ```
145
+ tax1 = price1 * 0.08
146
+ tax2 = price2 * 0.08
147
+ tax3 = price3 * 0.08
148
+ Extract: calculateTax(price)
202
149
  ```
203
150
 
204
151
  **Over-abstraction** — premature DRY that couples unrelated things:
205
- ```typescript
206
- // ❌ "Universal" handler that handles everything poorly
207
- function handleEntity(type: "user" | "order" | "product", action: "create" | "update" | "delete", data: unknown) { ... }
152
+ ```
153
+ handleEntity(type, action, data) → "universal" handler for everything
208
154
  ```
209
155
 
210
156
  **Rule of Three**: Duplicate once is acceptable. Duplicate twice means extract.
@@ -0,0 +1,126 @@
1
+ # TypeScript Clean Code Patterns
2
+
3
+ Language-specific patterns for the `clean-code` skill. Read `SKILL.md` first for universal principles.
4
+
5
+ ---
6
+
7
+ ## Single Responsibility
8
+
9
+ ```typescript
10
+ // ❌ Does three things
11
+ function processOrder(order: Order): void {
12
+ if (!order.items.length) throw new Error("Empty order");
13
+ if (!order.customer) throw new Error("No customer");
14
+
15
+ let total = 0;
16
+ for (const item of order.items) {
17
+ total += item.price * item.quantity;
18
+ if (item.taxable) total += item.price * 0.08;
19
+ }
20
+
21
+ db.orders.insert({ ...order, total, status: "pending" });
22
+ emailService.send(order.customer.email, "Order confirmed");
23
+ }
24
+
25
+ // ✅ Each function does one thing
26
+ function validateOrder(order: Order): void {
27
+ if (!order.items.length) throw new InvalidOrderError("Empty order");
28
+ if (!order.customer) throw new InvalidOrderError("No customer");
29
+ }
30
+
31
+ function calculateOrderTotal(items: OrderItem[]): number {
32
+ return items.reduce((total, item) => {
33
+ const subtotal = item.price * item.quantity;
34
+ const tax = item.taxable ? item.price * TAX_RATE : 0;
35
+ return total + subtotal + tax;
36
+ }, 0);
37
+ }
38
+
39
+ function submitOrder(order: Order): OrderConfirmation {
40
+ validateOrder(order);
41
+ const total = calculateOrderTotal(order.items);
42
+ const saved = db.orders.insert({ ...order, total, status: "pending" });
43
+ emailService.send(order.customer.email, "Order confirmed");
44
+ return { orderId: saved.id, total };
45
+ }
46
+ ```
47
+
48
+ ## Options Objects Over Positional Args
49
+
50
+ ```typescript
51
+ // ❌ Boolean flag parameter
52
+ function createUser(name: string, isAdmin: boolean): User { ... }
53
+
54
+ // ✅ Two clear functions
55
+ function createUser(name: string): User { ... }
56
+ function createAdmin(name: string): User { ... }
57
+
58
+ // ❌ Too many positional args
59
+ function sendEmail(to: string, from: string, subject: string, body: string, cc?: string): void { ... }
60
+
61
+ // ✅ Options object
62
+ interface SendEmailOptions {
63
+ to: string;
64
+ from: string;
65
+ subject: string;
66
+ body: string;
67
+ cc?: string;
68
+ }
69
+ function sendEmail(options: SendEmailOptions): void { ... }
70
+ ```
71
+
72
+ ## Error Handling
73
+
74
+ ```typescript
75
+ // ❌ Swallowing errors
76
+ try {
77
+ await saveOrder(order);
78
+ } catch (e) {
79
+ console.log("error");
80
+ }
81
+
82
+ // ❌ Generic catch-all
83
+ try {
84
+ await processPayment(order);
85
+ } catch (e) {
86
+ throw new Error("Something went wrong");
87
+ }
88
+
89
+ // ✅ Specific, actionable error handling
90
+ try {
91
+ await processPayment(order);
92
+ } catch (error) {
93
+ if (error instanceof InsufficientFundsError) {
94
+ return { success: false, code: "INSUFFICIENT_FUNDS", retry: false };
95
+ }
96
+ if (error instanceof PaymentGatewayError) {
97
+ logger.error("Payment gateway failure", { orderId: order.id, error });
98
+ return { success: false, code: "GATEWAY_ERROR", retry: true };
99
+ }
100
+ throw error; // Unknown errors bubble up
101
+ }
102
+ ```
103
+
104
+ ## Comments
105
+
106
+ ```typescript
107
+ // ❌ Redundant
108
+ // Increment counter by one
109
+ counter += 1;
110
+
111
+ // ❌ Obvious
112
+ // Check if user is admin
113
+ if (user.role === "admin") { ... }
114
+
115
+ // ✅ Explains WHY
116
+ // Stripe requires amount in cents, not dollars
117
+ const amountInCents = Math.round(price * 100);
118
+
119
+ // ✅ Business rule
120
+ // FDA regulation 21 CFR Part 11 requires audit trail for all changes
121
+ await auditLog.record(changeEvent);
122
+
123
+ // ✅ Non-obvious consequence
124
+ // WARNING: This query locks the orders table — avoid running during peak hours
125
+ await db.execute(batchUpdateQuery);
126
+ ```