class-ai-agent 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.agent/README.md +10 -5
  2. package/.agent/rules/agent-continuity.md +44 -0
  3. package/.agent/rules/antigravity-overview.md +38 -0
  4. package/.agent/rules/api-conventions.md +85 -0
  5. package/.agent/rules/clean-code.md +211 -0
  6. package/.agent/rules/code-style.md +92 -0
  7. package/.agent/rules/codegraph.md +47 -0
  8. package/.agent/rules/database.md +66 -0
  9. package/.agent/rules/error-handling.md +98 -0
  10. package/.agent/rules/git-workflow.md +83 -0
  11. package/.agent/rules/monitoring.md +317 -0
  12. package/.agent/rules/naming-conventions.md +266 -0
  13. package/.agent/rules/project-structure.md +71 -0
  14. package/.agent/rules/security.md +95 -0
  15. package/.agent/rules/system-design.md +168 -0
  16. package/.agent/rules/tech-stack.md +463 -0
  17. package/.agent/rules/testing.md +110 -0
  18. package/.agents/agents/backend.md +395 -0
  19. package/.agents/agents/business-analyst.md +380 -0
  20. package/.agents/agents/code-reviewer.md +110 -0
  21. package/.agents/agents/copywriter-seo.md +236 -0
  22. package/.agents/agents/frontend.md +384 -0
  23. package/.agents/agents/project-manager.md +201 -0
  24. package/.agents/agents/qa.md +221 -0
  25. package/.agents/agents/security-auditor.md +143 -0
  26. package/.agents/agents/systems-architect.md +211 -0
  27. package/.agents/agents/test-engineer.md +123 -0
  28. package/.agents/agents/ui-ux-designer.md +210 -0
  29. package/.agents/references/accessibility-checklist.md +174 -0
  30. package/.agents/references/agent-continuity.md +42 -0
  31. package/.agents/references/codegraph.md +90 -0
  32. package/.agents/references/mcp-antigravity.md +71 -0
  33. package/.agents/references/performance-checklist.md +150 -0
  34. package/.agents/references/security-checklist.md +94 -0
  35. package/.agents/references/supabase.md +55 -0
  36. package/.agents/references/testing-patterns.md +183 -0
  37. package/.agents/skills/agent-continuity/SKILL.md +70 -0
  38. package/.agents/skills/code-review/SKILL.md +208 -0
  39. package/.agents/skills/deploy/SKILL.md +68 -0
  40. package/.agents/skills/deploy/deploy.md +735 -0
  41. package/.agents/skills/incremental-implementation/SKILL.md +210 -0
  42. package/.agents/skills/security-review/SKILL.md +71 -0
  43. package/.agents/skills/supabase/SKILL.md +135 -0
  44. package/.agents/skills/supabase/UPSTREAM.md +16 -0
  45. package/.agents/skills/supabase/assets/feedback-issue-template.md +17 -0
  46. package/.agents/skills/supabase/references/skill-feedback.md +17 -0
  47. package/.agents/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  48. package/.agents/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
  49. package/.agents/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  50. package/.agents/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  51. package/.agents/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  52. package/.agents/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  53. package/.agents/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  54. package/.agents/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  55. package/.agents/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  56. package/.agents/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  57. package/.agents/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  58. package/.agents/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  59. package/.agents/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  60. package/.agents/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  61. package/.agents/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  62. package/.agents/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  63. package/.agents/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  64. package/.agents/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  65. package/.agents/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  66. package/.agents/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  67. package/.agents/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  68. package/.agents/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  69. package/.agents/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  70. package/.agents/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  71. package/.agents/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  72. package/.agents/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  73. package/.agents/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  74. package/.agents/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  75. package/.agents/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  76. package/.agents/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  77. package/.agents/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  78. package/.agents/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  79. package/.agents/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  80. package/.agents/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  81. package/.agents/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  82. package/.agents/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
  83. package/.agents/skills/tdd/SKILL.md +217 -0
  84. package/.agents/skills/ui-ux-pro-max/SKILL.md +288 -0
  85. package/.agents/skills/ui-ux-pro-max/data/charts.csv +26 -0
  86. package/.agents/skills/ui-ux-pro-max/data/colors.csv +97 -0
  87. package/.agents/skills/ui-ux-pro-max/data/icons.csv +101 -0
  88. package/.agents/skills/ui-ux-pro-max/data/landing.csv +31 -0
  89. package/.agents/skills/ui-ux-pro-max/data/products.csv +97 -0
  90. package/.agents/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  91. package/.agents/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  92. package/.agents/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  93. package/.agents/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  94. package/.agents/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  95. package/.agents/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  96. package/.agents/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  97. package/.agents/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  98. package/.agents/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  99. package/.agents/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  100. package/.agents/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  101. package/.agents/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  102. package/.agents/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  103. package/.agents/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  104. package/.agents/skills/ui-ux-pro-max/data/styles.csv +68 -0
  105. package/.agents/skills/ui-ux-pro-max/data/typography.csv +58 -0
  106. package/.agents/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  107. package/.agents/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  108. package/.agents/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  109. package/.agents/skills/ui-ux-pro-max/scripts/core.py +253 -0
  110. package/.agents/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  111. package/.agents/skills/ui-ux-pro-max/scripts/search.py +114 -0
  112. package/.agents/workflows/build.md +132 -0
  113. package/.agents/workflows/debug.md +242 -0
  114. package/.agents/workflows/deploy.md +43 -0
  115. package/.agents/workflows/fix-issue.md +45 -0
  116. package/.agents/workflows/handoff.md +93 -0
  117. package/.agents/workflows/plan.md +125 -0
  118. package/.agents/workflows/publish-npm.md +122 -0
  119. package/.agents/workflows/resume.md +106 -0
  120. package/.agents/workflows/review.md +53 -0
  121. package/.agents/workflows/simplify.md +221 -0
  122. package/.agents/workflows/spec.md +95 -0
  123. package/.agents/workflows/test.md +213 -0
  124. package/.cursor/rules/cursor-overview.mdc +3 -2
  125. package/.kiro/steering/kiro-overview.md +2 -2
  126. package/AGENTS.md +4 -1
  127. package/GEMINI.md +152 -0
  128. package/README.md +58 -15
  129. package/bin/class-ai-agent.cjs +85 -9
  130. package/package.json +9 -4
package/.agent/README.md CHANGED
@@ -1,19 +1,20 @@
1
- # Agent continuity (`.agent/`)
1
+ # Agent continuity and Antigravity rules (`.agent/`)
2
2
 
3
- Committed handoff state so **Cursor**, **Claude Code**, and **Kiro** agents can continue the same work without re-discovering context.
3
+ Committed handoff state so **Cursor**, **Claude Code**, **Kiro**, and **Antigravity** agents can continue the same work without re-discovering context.
4
4
 
5
5
  ## Files
6
6
 
7
- | File | Purpose |
8
- |------|---------|
7
+ | File / folder | Purpose |
8
+ |---------------|---------|
9
9
  | **`SESSION.md`** | Live handoff — read at session start, update at session end |
10
10
  | **`SESSION.template.md`** | Schema reference (do not edit for handoff; copy to `SESSION.md` on fresh install) |
11
+ | **`rules/`** | Antigravity supplement rules (synced from `.cursor/rules/`; see `GEMINI.md`) |
11
12
  | **`history/`** | _(optional)_ milestone snapshots, e.g. `2025-06-02-feature-x.md` |
12
13
 
13
14
  ## Workflow
14
15
 
15
16
  1. **Start** — Run `/resume` (or read `SESSION.md` first). Then `tasks/todo.md`, then linked `SPEC.md`.
16
- 2. **Work** — Follow `.cursor/`, `.claude/`, or `.kiro/` workflow (`/build`, etc.).
17
+ 2. **Work** — Follow your tool's hub (`.cursor/`, `.claude/`, `.kiro/`, or `GEMINI.md` / `/build`, etc.).
17
18
  3. **End** — Run `/handoff` to refresh `SESSION.md` before closing the chat or switching tools.
18
19
 
19
20
  ## What to put in `SESSION.md`
@@ -31,3 +32,7 @@ Committed handoff state so **Cursor**, **Claude Code**, and **Kiro** agents can
31
32
  ## Commit to git
32
33
 
33
34
  `SESSION.md` is meant to be **committed** so the whole team and any IDE can resume. Keep it concise and current.
35
+
36
+ ## Antigravity note
37
+
38
+ Antigravity also reads **`.agent/rules/*.md`** as supplement rules (after `AGENTS.md` and `GEMINI.md`). Workflows and skills live in **`.agents/`** — see **`GEMINI.md`**.
@@ -0,0 +1,44 @@
1
+ ---
2
+ trigger: always_on
3
+ description: "Agent session continuity — cross-tool handoff via .agent/SESSION.md"
4
+ ---
5
+
6
+ # Agent continuity
7
+
8
+ Cross-tool handoff lives in **`.agent/SESSION.md`** (committed). Cursor, Claude Code, and Kiro agents share this file.
9
+
10
+ ## Session start
11
+
12
+ 1. If **`.agent/SESSION.md`** exists, read it **before** planning or editing code.
13
+ 2. When the user says **continue**, **resume**, or **pick up**, use **`.agents/workflows/resume.md`** (or equivalent in `.agents/` / `.agents/`).
14
+ 3. Then read **`tasks/todo.md`** and linked **SPEC** paths from SESSION **Pointers**.
15
+
16
+ **Do not** call `codegraph_context` with `query` / `limit` for session resume — that tool requires **`task`** and is for code symbols, not handoff state. For continuity, **Read** `.agent/SESSION.md` (and `tasks/todo.md`); use `codegraph_context` only when you need structural code context for the work described in SESSION.
17
+
18
+ ## Session end and phase changes
19
+
20
+ 1. Update **`.agent/SESSION.md`** before ending a session or switching tools — use **`.agents/workflows/handoff.md`** when possible.
21
+ 2. Keep **Done**, **In progress**, and **Next** accurate; do not leave stale **In progress** items.
22
+ 3. Sync **`tasks/todo.md`** checkboxes when tasks change.
23
+
24
+ ## Security (SESSION.md)
25
+
26
+ **Never** store in `.agent/SESSION.md`:
27
+
28
+ - API keys, passwords, tokens, credentials
29
+ - PII or customer data
30
+
31
+ Use issue links, commit SHAs, and file paths instead.
32
+
33
+ ## Workflow integration
34
+
35
+ | Phase | SESSION `phase` value |
36
+ |-------|------------------------|
37
+ | Spec | `spec` |
38
+ | Plan | `plan` |
39
+ | Build | `build` |
40
+ | Test | `test` |
41
+ | Review | `review` |
42
+ | Debug | `debug` |
43
+
44
+ Set **Meta → Tool** to `cursor`, `claude`, or `kiro` as appropriate.
@@ -0,0 +1,38 @@
1
+ ---
2
+ trigger: always_on
3
+ description: "Antigravity agent workflow, principles, and where project guidance lives"
4
+ ---
5
+
6
+ # Antigravity agent — project workflow
7
+
8
+ This repo mirrors Cursor's `.cursor/` layout into Antigravity-native paths: **`.agents/`** (workflows, skills, agents) and **`.agent/rules/`** (supplement rules).
9
+
10
+ ## Development workflow
11
+
12
+ Use the same phase order as in `GEMINI.md`:
13
+
14
+ 1. **Define** — `/spec` workflow (`.agents/workflows/spec.md`)
15
+ 2. **Plan** — `/plan` workflow
16
+ 3. **Build** — `/build` workflow (TDD: `.agents/skills/tdd/`)
17
+ 4. **Verify** — `/test` workflow
18
+ 5. **Review** — `/review` workflow (five-axis: `.agents/skills/code-review/`)
19
+ 6. **Ship** — `/deploy` workflow
20
+
21
+ Supporting workflows: `debug`, `simplify`, `fix-issue`, `handoff`, `resume` in `.agents/workflows/`. Maintainers: `publish-npm` (say **push to npm repo** to draft README release notes and publish).
22
+
23
+ **Agent continuity:** committed **`.agent/SESSION.md`** — read at session start (`/resume`), update at end (`/handoff`). See **`.agent/rules/agent-continuity.md`**.
24
+
25
+ ## Mandatory standards
26
+
27
+ - Follow **`.agent/rules/`** (`*.md` with YAML frontmatter). **`security.md`**, **`codegraph.md`**, and **`agent-continuity.md`** use `trigger: always_on`; others often use `trigger: glob`.
28
+ - Prefer **tests first** and **small vertical slices** (see `.agents/skills/incremental-implementation/`).
29
+ - Use **`.agents/references/`** for checklists (security, testing, performance, accessibility).
30
+ - For **structural** code questions, prefer **CodeGraph** MCP tools per **`.agent/rules/codegraph.md`**.
31
+
32
+ ## Agents (personas)
33
+
34
+ Specialized instructions live in **`.agents/agents/`**. Reference files in chat (paste or attach).
35
+
36
+ ## Relation to `.cursor/`, `.claude/`, and `.kiro/`
37
+
38
+ Keep all four trees aligned when you change workflows or standards. After editing `.cursor/`, run `npm run sync:all`.
@@ -0,0 +1,85 @@
1
+ ---
2
+ trigger: glob
3
+ globs: {ts,tsx,js,jsx,mjs,cjs,json,md,prisma,yml,yaml}
4
+ description: "API Conventions"
5
+ ---
6
+
7
+ # API Conventions
8
+
9
+ ## REST API Design Standards
10
+
11
+ ### URL Structure
12
+ - Use **kebab-case** for URL paths: `/api/user-profiles`
13
+ - Use **plural nouns** for resource collections: `/api/users`, `/api/products`
14
+ - Nest related resources: `/api/users/:id/orders`
15
+ - API version prefix: `/api/v1/...`
16
+
17
+ ### HTTP Methods
18
+ | Method | Usage |
19
+ |--------|-------|
20
+ | GET | Read resources (idempotent) |
21
+ | POST | Create new resource |
22
+ | PUT | Replace entire resource |
23
+ | PATCH | Partial update |
24
+ | DELETE | Remove resource |
25
+
26
+ ### HTTP Status Codes
27
+ | Code | Meaning |
28
+ |------|---------|
29
+ | 200 | OK — Successful GET/PUT/PATCH |
30
+ | 201 | Created — Successful POST |
31
+ | 204 | No Content — Successful DELETE |
32
+ | 400 | Bad Request — Invalid input |
33
+ | 401 | Unauthorized — Not authenticated |
34
+ | 403 | Forbidden — No permission |
35
+ | 404 | Not Found |
36
+ | 409 | Conflict |
37
+ | 422 | Unprocessable Entity — Validation failed |
38
+ | 500 | Internal Server Error |
39
+
40
+ ### Request/Response Format
41
+ ```json
42
+ // Success response
43
+ {
44
+ "success": true,
45
+ "data": { ... },
46
+ "message": "Optional message"
47
+ }
48
+
49
+ // Error response
50
+ {
51
+ "success": false,
52
+ "error": {
53
+ "code": "VALIDATION_ERROR",
54
+ "message": "Human readable message",
55
+ "details": [ ... ]
56
+ }
57
+ }
58
+
59
+ // Paginated list response
60
+ {
61
+ "success": true,
62
+ "data": [ ... ],
63
+ "pagination": {
64
+ "page": 1,
65
+ "limit": 20,
66
+ "total": 100,
67
+ "totalPages": 5
68
+ }
69
+ }
70
+ ```
71
+
72
+ ### Naming Conventions
73
+ - Request/response body fields: **camelCase**
74
+ - Query parameters: **camelCase**
75
+ - Always return consistent field names
76
+
77
+ ### Filtering & Pagination
78
+ ```
79
+ GET /api/users?page=1&limit=20&sortBy=createdAt&order=desc
80
+ GET /api/products?category=electronics&minPrice=100
81
+ ```
82
+
83
+ ### Documentation
84
+ - Every endpoint MUST have JSDoc/Swagger annotations
85
+ - Include request body schema, response schema, and error codes
@@ -0,0 +1,211 @@
1
+ ---
2
+ trigger: glob
3
+ globs: {ts,tsx,js,jsx,mjs,cjs,json,md,prisma,yml,yaml}
4
+ description: "Clean Code — JavaScript Rules"
5
+ ---
6
+
7
+ # Clean Code — JavaScript Rules
8
+ > Source: [clean-code-javascript](https://github.com/ryanmcdermott/clean-code-javascript) by Ryan McDermott
9
+
10
+ ## 📦 Variables
11
+
12
+ ### ✅ Use meaningful, pronounceable names
13
+ ```js
14
+ // ❌ Bad
15
+ const yyyymmdstr = moment().format('YYYY/MM/DD');
16
+
17
+ // ✅ Good
18
+ const currentDate = moment().format('YYYY/MM/DD');
19
+ ```
20
+
21
+ ### ✅ Same vocabulary for same type
22
+ ```js
23
+ // ❌ getUserInfo(), getClientData(), getCustomerRecord()
24
+ // ✅ getUser()
25
+ ```
26
+
27
+ ### ✅ Use searchable names (no magic numbers)
28
+ ```js
29
+ // ❌ setTimeout(blastOff, 86400000);
30
+ const MILLISECONDS_PER_DAY = 60 * 60 * 24 * 1000;
31
+ setTimeout(blastOff, MILLISECONDS_PER_DAY); // ✅
32
+ ```
33
+
34
+ ### ✅ Use explanatory variables
35
+ ```js
36
+ // ❌ Bad
37
+ saveCityZipCode(address.match(regex)[1], address.match(regex)[2]);
38
+
39
+ // ✅ Good
40
+ const [_, city, zipCode] = address.match(cityZipCodeRegex) || [];
41
+ saveCityZipCode(city, zipCode);
42
+ ```
43
+
44
+ ### ✅ Avoid mental mapping — be explicit
45
+ ```js
46
+ // ❌ locations.forEach(l => { dispatch(l); });
47
+ // ✅ locations.forEach(location => { dispatch(location); });
48
+ ```
49
+
50
+ ### ✅ Don't add redundant context
51
+ ```js
52
+ // ❌ const Car = { carMake, carModel, carColor }
53
+ // ✅ const Car = { make, model, color }
54
+ ```
55
+
56
+ ### ✅ Use default parameters
57
+ ```js
58
+ // ❌ const name = name || 'Default';
59
+ // ✅ function create(name = 'Default') {}
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 🔧 Functions
65
+
66
+ ### ✅ 2 arguments or fewer — use object destructuring for more
67
+ ```js
68
+ // ❌ function createMenu(title, body, buttonText, cancellable) {}
69
+ // ✅ function createMenu({ title, body, buttonText, cancellable }) {}
70
+ ```
71
+
72
+ ### ✅ Functions should do ONE thing
73
+ ```js
74
+ // ❌ emailClients() — fetches DB + checks active + sends email
75
+ // ✅ emailActiveClients() calls isActiveClient() separately
76
+ ```
77
+
78
+ ### ✅ Function names should say what they do
79
+ ```js
80
+ // ❌ addToDate(date, 1) → unclear what is added
81
+ // ✅ addMonthToDate(1, date) → crystal clear
82
+ ```
83
+
84
+ ### ✅ One level of abstraction per function
85
+ ```js
86
+ // ❌ parseBetterJSAlternative() — tokenizes + parses + AST walks in one function
87
+ // ✅ parseBetterJSAlternative() → calls tokenize() → calls parse()
88
+ ```
89
+
90
+ ### ✅ Remove duplicate code — extract shared logic
91
+ ### ✅ No flag parameters — split into separate functions
92
+ ```js
93
+ // ❌ function createFile(name, isTemp) { if (isTemp) ... }
94
+ // ✅ function createFile(name) {}
95
+ // function createTempFile(name) {}
96
+ ```
97
+
98
+ ### ✅ Avoid Side Effects
99
+ - Don't mutate global state
100
+ - Don't mutate function arguments (use copies)
101
+ ```js
102
+ // ✅ Return new array instead of mutating
103
+ function addItemToCart(cart, item) {
104
+ return [...cart, { item, date: Date.now() }];
105
+ }
106
+ ```
107
+
108
+ ### ✅ Favor functional programming
109
+ ```js
110
+ // ❌ for loop with mutations
111
+ // ✅ filter(), map(), reduce()
112
+ const totalOutput = programmerOutput
113
+ .filter(p => p.linesOfCode > 0)
114
+ .reduce((acc, p) => acc + p.linesOfCode, 0);
115
+ ```
116
+
117
+ ### ✅ Encapsulate conditionals
118
+ ```js
119
+ // ❌ if (fsm.state === 'fetching' && isEmpty(listNode)) {}
120
+ // ✅ if (shouldShowSpinner(fsmInstance, listNodeInstance)) {}
121
+ ```
122
+
123
+ ### ✅ Avoid negative conditionals
124
+ ```js
125
+ // ❌ if (!isNotDOMNodePresent(node)) {}
126
+ // ✅ if (isDOMNodePresent(node)) {}
127
+ ```
128
+
129
+ ### ✅ Remove dead code immediately
130
+
131
+ ---
132
+
133
+ ## 🏛️ Classes
134
+
135
+ ### ✅ Prefer ES6 classes
136
+ ### ✅ Use method chaining (builder pattern)
137
+ ```js
138
+ class QueryBuilder {
139
+ select(fields) { this.fields = fields; return this; }
140
+ from(table) { this.table = table; return this; }
141
+ build() { return `SELECT ${this.fields} FROM ${this.table}`; }
142
+ }
143
+ new QueryBuilder().select('*').from('users').build();
144
+ ```
145
+
146
+ ### ✅ Prefer composition over inheritance
147
+ > "Favor has-a over is-a"
148
+
149
+ ---
150
+
151
+ ## 🧱 SOLID Principles
152
+
153
+ | Principle | Rule |
154
+ |-----------|------|
155
+ | **S** — Single Responsibility | One class = one job. Never combine unrelated concerns |
156
+ | **O** — Open/Closed | Open for extension, closed for modification |
157
+ | **L** — Liskov Substitution | Subclasses must be substitutable for their base class |
158
+ | **I** — Interface Segregation | Clients shouldn't depend on interfaces they don't use |
159
+ | **D** — Dependency Inversion | Depend on abstractions, not concretions |
160
+
161
+ ```js
162
+ // ✅ D — Dependency Inversion
163
+ class InventoryService {
164
+ constructor(inventoryRequester) { // inject the dependency
165
+ this.inventoryRequester = inventoryRequester;
166
+ }
167
+ requestItems(customer) {
168
+ return this.inventoryRequester.requestItem(customer.purchaseHistory);
169
+ }
170
+ }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## ⚡ Concurrency
176
+
177
+ ### ✅ Use Promises over callbacks
178
+ ### ✅ Use async/await over Promises
179
+ ```js
180
+ // ✅ Clearest form
181
+ async function getCleanCodeArticle() {
182
+ try {
183
+ const response = await request.get(cleanCodeUrl);
184
+ await fs.writeFile('article.html', response);
185
+ } catch (err) {
186
+ console.error(err);
187
+ }
188
+ }
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 🗒️ Comments
194
+
195
+ ### ✅ Only comment business logic complexity
196
+ ### ❌ Never leave commented-out code
197
+ ### ❌ No journal comments (use git log instead)
198
+ ### ❌ No positional markers (`/////`)
199
+ ```js
200
+ // ✅ Good comment — explains WHY
201
+ // We retry 3x because OAuth2 tokens can have clock skew
202
+ const MAX_RETRIES = 3;
203
+ ```
204
+
205
+ ---
206
+
207
+ ## 📐 Formatting
208
+
209
+ - Use consistent capitalization (camelCase for vars/fns, PascalCase for classes, UPPER_SNAKE for constants)
210
+ - Keep callers and callees close in the file
211
+ - Related code should appear together
@@ -0,0 +1,92 @@
1
+ ---
2
+ trigger: glob
3
+ globs: {ts,tsx,js,jsx,mjs,cjs,json,md,prisma,yml,yaml}
4
+ description: "Code Style Guide"
5
+ ---
6
+
7
+ # Code Style Guide
8
+
9
+ ## General Principles
10
+ - **Clarity over cleverness** — Write code that is easy to read and understand
11
+ - **Consistency** — Follow existing patterns in the codebase
12
+ - **DRY** — Don't Repeat Yourself, but don't over-abstract
13
+
14
+ ## JavaScript / TypeScript
15
+
16
+ ### Formatting
17
+ - Indentation: **2 spaces** (no tabs)
18
+ - Max line length: **100 characters**
19
+ - Use **single quotes** for strings
20
+ - Always use **semicolons**
21
+ - Trailing commas in multi-line structures
22
+
23
+ ### Naming
24
+ ```js
25
+ // Variables and functions: camelCase
26
+ const userProfile = {};
27
+ function getUserById(id) {}
28
+
29
+ // Classes and interfaces: PascalCase
30
+ class UserService {}
31
+ interface UserRepository {}
32
+
33
+ // Constants: UPPER_SNAKE_CASE
34
+ const MAX_RETRY_COUNT = 3;
35
+ const API_BASE_URL = 'https://api.example.com';
36
+
37
+ // Files: kebab-case
38
+ // user-service.js, auth-middleware.js
39
+ ```
40
+
41
+ ### Functions
42
+ ```js
43
+ // ✅ Good — Arrow functions for simple operations
44
+ const double = (x) => x * 2;
45
+
46
+ // ✅ Good — Named functions for complex logic
47
+ function processUserData(user) {
48
+ // ...
49
+ }
50
+
51
+ // ❌ Avoid — Functions longer than 30 lines (extract helpers)
52
+ ```
53
+
54
+ ### Async/Await
55
+ ```js
56
+ // ✅ Always use async/await over raw promises
57
+ async function fetchUser(id) {
58
+ try {
59
+ const user = await userRepository.findById(id);
60
+ return user;
61
+ } catch (error) {
62
+ throw new AppError('User not found', 404);
63
+ }
64
+ }
65
+
66
+ // ❌ Avoid promise chains
67
+ fetchUser(id).then(...).catch(...);
68
+ ```
69
+
70
+ ### Imports
71
+ ```js
72
+ // Order: 1. Node built-ins, 2. External deps, 3. Internal modules
73
+ import path from 'path';
74
+ import express from 'express';
75
+ import { UserService } from './user-service.js';
76
+ ```
77
+
78
+ ## Comments
79
+ ```js
80
+ // ✅ Explain WHY, not WHAT
81
+ // We retry 3 times because the external API has transient failures
82
+ const MAX_RETRIES = 3;
83
+
84
+ // ❌ Avoid obvious comments
85
+ // Set x to 5
86
+ const x = 5;
87
+ ```
88
+
89
+ ## File Organization
90
+ - One class/service per file
91
+ - Group related files in feature folders
92
+ - Index files for clean imports
@@ -0,0 +1,47 @@
1
+ ---
2
+ trigger: always_on
3
+ description: "CodeGraph MCP usage guide — when to use which tool"
4
+ ---
5
+
6
+ ## CodeGraph
7
+
8
+ This project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.
9
+
10
+ ### When to prefer codegraph over native search
11
+
12
+ Use codegraph for **structural** questions — what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.
13
+
14
+ | Question | Tool |
15
+ |---|---|
16
+ | "Where is X defined?" / "Find symbol named X" | `codegraph_search` |
17
+ | "What calls function Y?" | `codegraph_callers` |
18
+ | "What does Y call?" | `codegraph_callees` |
19
+ | "How does X reach/become Y? / trace the flow from X to Y" | `codegraph_trace` (one call = the whole path, incl. callback/React/JSX dynamic hops) |
20
+ | "What would break if I changed Z?" | `codegraph_impact` |
21
+ | "Show me Y's signature / source / docstring" | `codegraph_node` |
22
+ | "Give me focused context for a task/area" | `codegraph_context` |
23
+ | "See several related symbols' source at once" | `codegraph_explore` |
24
+ | "What files exist under path/" | `codegraph_files` |
25
+ | "Is the index healthy?" | `codegraph_status` |
26
+
27
+ ### Tool parameters (do not mix)
28
+
29
+ | Tool | Required arg | Optional cap | Wrong args → error |
30
+ |------|--------------|--------------|-------------------|
31
+ | `codegraph_search` | **`query`** (symbol name) | `limit` (default 10) | — |
32
+ | `codegraph_context` | **`task`** (feature/bug description) | `maxNodes` (default 20) | `query` / `limit` → **`task must be a non-empty string`** |
33
+
34
+ `codegraph_context` is for **code structure** around a task — not for loading **`.agent/SESSION.md`** or `/resume` handoff (use **Read** + `.agents/workflows/resume.md`).
35
+
36
+ ### Rules of thumb
37
+
38
+ - **Answer directly — don't delegate exploration.** For "how does X work" / architecture questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. For a specific **flow** ("how does X reach Y") start with `codegraph_trace` from→to — one call returns the whole path with dynamic hops bridged — then ONE `codegraph_explore` for the bodies; don't rebuild the path with `codegraph_search` + `codegraph_callers`. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent — or running a grep + read loop — repeats work codegraph already did and costs more for the same answer.
39
+ - **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep — that's slower, less accurate, and wastes context.
40
+ - **Don't grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.
41
+ - **Don't chain `codegraph_search` + `codegraph_node`** when you just want context — `codegraph_context` is one call.
42
+ - **Don't loop `codegraph_node` over many symbols** — one `codegraph_explore` call returns several symbols' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.
43
+ - **Index lag — check the staleness banner, don't guess a wait.** When a codegraph response starts with "⚠️ Some files referenced below were edited since the last index sync…", the listed files are pending re-index — Read those specific files for accurate content. Files NOT in that banner are fresh and codegraph is authoritative for them. `codegraph_status` also lists pending files under "Pending sync".
44
+
45
+ ### If `.codegraph/` doesn't exist
46
+
47
+ The MCP server returns "not initialized." Ask the user: *"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*
@@ -0,0 +1,66 @@
1
+ ---
2
+ trigger: glob
3
+ globs: {ts,tsx,js,jsx,mjs,cjs,json,md,prisma,yml,yaml}
4
+ description: "Database Rules"
5
+ ---
6
+
7
+ # Database Rules
8
+
9
+ ## General Rules
10
+ - **Never** write raw SQL strings directly in business logic
11
+ - Always use an ORM (Prisma/Sequelize/TypeORM) or query builder
12
+ - All database calls must be inside try/catch blocks
13
+ - Use **transactions** for multi-step operations
14
+
15
+ ## Connection Management
16
+ ```js
17
+ // ✅ Use connection pooling
18
+ const pool = new Pool({ max: 10, idleTimeoutMillis: 30000 });
19
+
20
+ // ❌ Never create a new connection per request
21
+ ```
22
+
23
+ ## Query Best Practices
24
+ ```js
25
+ // ✅ Select only needed fields
26
+ const user = await db.user.findUnique({
27
+ where: { id },
28
+ select: { id: true, email: true, name: true }
29
+ });
30
+
31
+ // ❌ Avoid SELECT *
32
+ const user = await db.user.findUnique({ where: { id } });
33
+
34
+ // ✅ Use pagination for lists
35
+ const users = await db.user.findMany({
36
+ take: limit,
37
+ skip: (page - 1) * limit,
38
+ orderBy: { createdAt: 'desc' }
39
+ });
40
+ ```
41
+
42
+ ## Transactions
43
+ ```js
44
+ // ✅ Use transactions for atomic operations
45
+ await db.$transaction(async (tx) => {
46
+ const order = await tx.order.create({ data: orderData });
47
+ await tx.inventory.update({ where: { id: productId }, data: { stock: { decrement: 1 } } });
48
+ return order;
49
+ });
50
+ ```
51
+
52
+ ## Migrations
53
+ - Always use migration files, never modify the database schema directly
54
+ - Migration files are version-controlled and immutable
55
+ - Run migrations in CI/CD before deploying
56
+
57
+ ## Naming Conventions
58
+ - Tables: **snake_case** plural (`user_profiles`, `order_items`)
59
+ - Columns: **snake_case** (`created_at`, `user_id`)
60
+ - Indexes: `idx_[table]_[column]`
61
+ - Foreign keys: `fk_[table]_[referenced_table]`
62
+
63
+ ## Security
64
+ - Never log query results containing sensitive data (passwords, tokens)
65
+ - Use parameterized queries — never string concatenation
66
+ - Apply row-level security where applicable