codeninja 3.2.0 → 4.0.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/README.md +13 -1
- package/agent/database-agent.md +24 -1
- package/agent/nodejs-agent.md +79 -0
- package/cli.js +27 -7
- package/commands/audit.workflow.md +4 -1
- package/commands/db-create-table.workflow.md +1 -1
- package/commands/initialize-project.workflow.md +21 -0
- package/ide/antigravity/.agents/personas/database-architect.md +431 -153
- package/ide/antigravity/.agents/personas/global-orchestrator.md +202 -85
- package/ide/antigravity/.agents/personas/nodejs-backend.md +368 -133
- package/ide/antigravity/.agents/personas/reactjs-frontend.md +182 -101
- package/ide/antigravity/.agents/skills/api-builder/SKILL.md +58 -0
- package/ide/antigravity/.agents/skills/code-intelligence/SKILL.md +22 -0
- package/ide/antigravity/.agents/skills/database/SKILL.md +32 -0
- package/ide/antigravity/.agents/skills/mcp-and-context/SKILL.md +76 -82
- package/ide/antigravity/.agents/skills/reactjs/SKILL.md +36 -0
- package/ide/antigravity/.agents/workflows/codeninja-api.md +76 -83
- package/ide/antigravity/.agents/workflows/codeninja-audit.md +82 -44
- package/ide/antigravity/.agents/workflows/codeninja-db-create.md +107 -94
- package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +89 -67
- package/ide/antigravity/.agents/workflows/codeninja-db-index.md +86 -54
- package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +126 -68
- package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +87 -59
- package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +77 -41
- package/ide/antigravity/.agents/workflows/codeninja-debug.md +35 -21
- package/ide/antigravity/.agents/workflows/codeninja-design.md +49 -35
- package/ide/antigravity/.agents/workflows/codeninja-explain.md +41 -20
- package/ide/antigravity/.agents/workflows/codeninja-init.md +479 -289
- package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +253 -136
- package/ide/antigravity/.agents/workflows/codeninja-modularize.md +250 -132
- package/ide/antigravity/.agents/workflows/codeninja-optimize.md +71 -29
- package/ide/antigravity/.agents/workflows/codeninja-refactor.md +50 -42
- package/ide/antigravity/.agents/workflows/codeninja-review.md +38 -21
- package/ide/antigravity/.agents/workflows/codeninja-sync.md +922 -141
- package/ide/antigravity/.agents/workflows/codeninja-test.md +34 -49
- package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +449 -151
- package/ide/claude-code/.claude/CLAUDE.md +99 -0
- package/ide/claude-code/.claude/agents/database-agent.md +535 -0
- package/ide/claude-code/.claude/agents/nodejs-agent.md +493 -0
- package/ide/claude-code/.claude/agents/reactjs-agent.md +267 -0
- package/ide/claude-code/.claude/commands/codeninja-api.md +104 -0
- package/ide/claude-code/.claude/commands/codeninja-audit.md +119 -0
- package/ide/claude-code/.claude/commands/codeninja-db-create.md +138 -0
- package/ide/claude-code/.claude/commands/codeninja-db-drop.md +109 -0
- package/ide/claude-code/.claude/commands/codeninja-db-index.md +103 -0
- package/ide/claude-code/.claude/commands/codeninja-db-modify.md +165 -0
- package/ide/claude-code/.claude/commands/codeninja-db-seed.md +104 -0
- package/ide/claude-code/.claude/commands/codeninja-db-sync.md +106 -0
- package/ide/claude-code/.claude/commands/codeninja-debug.md +99 -0
- package/ide/claude-code/.claude/commands/codeninja-design.md +68 -0
- package/ide/claude-code/.claude/commands/codeninja-explain.md +61 -0
- package/ide/claude-code/.claude/commands/codeninja-init.md +529 -0
- package/ide/claude-code/.claude/commands/codeninja-integrate-api.md +453 -0
- package/ide/claude-code/.claude/commands/codeninja-modularize.md +334 -0
- package/ide/claude-code/.claude/commands/codeninja-optimize.md +129 -0
- package/ide/claude-code/.claude/commands/codeninja-refactor.md +76 -0
- package/ide/claude-code/.claude/commands/codeninja-review.md +87 -0
- package/ide/claude-code/.claude/commands/codeninja-sync.md +964 -0
- package/ide/claude-code/.claude/commands/codeninja-test.md +45 -0
- package/ide/claude-code/.claude/commands/codeninja-validate-page.md +548 -0
- package/ide/cursor/.cursor/rules/01-global-orchestrator.mdc +12 -13
- package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +47 -31
- package/ide/cursor/.cursor/rules/03-api-builder.mdc +32 -110
- package/ide/cursor/.cursor/rules/04-nodejs-generation.mdc +58 -0
- package/ide/cursor/.cursor/rules/05-database.mdc +54 -0
- package/ide/cursor/.cursor/rules/06-reactjs.mdc +36 -0
- package/ide/cursor/.cursor/rules/07-reactjs-generation.mdc +49 -0
- package/ide/cursor/.cursor/rules/08-code-intelligence.mdc +56 -0
- package/ide/cursor/.cursor/rules/09-workflow-steps.mdc +53 -0
- package/ide/vscode/.github/copilot-instructions.md +67 -382
- package/ide/vscode/.vscode/instructions/code-intelligence.instructions.md +58 -0
- package/ide/vscode/.vscode/instructions/database.instructions.md +55 -0
- package/ide/vscode/.vscode/instructions/nodejs.instructions.md +77 -0
- package/ide/vscode/.vscode/instructions/reactjs.instructions.md +42 -0
- package/package.json +2 -2
- package/tasks/ask-hashing-library.task.md +31 -0
- package/tasks/ask-language-type.task.md +26 -0
- package/tasks/ask-new-module-name.task.md +13 -0
- package/tasks/ask-new-service-name.task.md +13 -0
- package/tasks/ask-old-module-name.task.md +15 -0
- package/tasks/ask-old-service-name.task.md +13 -0
- package/tasks/ask-orm-type.task.md +26 -0
- package/tasks/collect-seed-data.task.md +19 -0
- package/tasks/generate-app.task.md +42 -0
- package/tasks/generate-common.task.md +13 -0
- package/tasks/generate-constants.task.md +13 -0
- package/tasks/generate-database.task.md +32 -0
- package/tasks/generate-encryption.task.md +28 -0
- package/tasks/generate-fast-defaults.task.md +7 -0
- package/tasks/generate-hashing.task.md +180 -0
- package/tasks/generate-headerValidator.task.md +13 -0
- package/tasks/generate-ioRedis.task.md +20 -0
- package/tasks/generate-language-en.task.md +12 -0
- package/tasks/generate-logging.task.md +12 -0
- package/tasks/generate-model.task.md +74 -6
- package/tasks/generate-notification.task.md +12 -0
- package/tasks/generate-package-json.task.md +69 -0
- package/tasks/generate-prisma-client.task.md +56 -0
- package/tasks/generate-prisma-schema.task.md +71 -0
- package/tasks/generate-rateLimiter.task.md +20 -0
- package/tasks/generate-readme.task.md +24 -0
- package/tasks/generate-response.task.md +27 -0
- package/tasks/generate-route-manager.task.md +32 -0
- package/tasks/generate-route.task.md +37 -0
- package/tasks/generate-swagger.task.md +8 -0
- package/tasks/generate-template.task.md +12 -0
- package/tasks/generate-tsconfig.task.md +38 -0
- package/tasks/generate-validator.task.md +31 -0
- package/ide/cursor/.cursor/rules/04-database.mdc +0 -90
- package/ide/cursor/.cursor/rules/05-reactjs.mdc +0 -147
- package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +0 -112
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: codeninja Database Architect — table design, migrations, indexes, seeds
|
|
3
|
-
globs: ["**/database/**", "**/*.sql", "**/migrations/**"]
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# codeninja — Database Architect
|
|
8
|
-
|
|
9
|
-
## Critical Rule
|
|
10
|
-
`database/` folder is ALWAYS at the repository root — NEVER inside a service folder.
|
|
11
|
-
All services share the same database directory.
|
|
12
|
-
|
|
13
|
-
## /codeninja:db:create — New Table
|
|
14
|
-
|
|
15
|
-
1. Ask: table purpose (used for column suggestions)
|
|
16
|
-
2. Ask: table name (must start with `tbl_`, snake_case, lowercase)
|
|
17
|
-
3. Ask: migration file number (agent reads migrations/ and suggests next via `migration_next_number`)
|
|
18
|
-
4. Ask: needs `status` + `is_deleted` columns? (suggest YES for entity tables, NO for log tables)
|
|
19
|
-
5. Ask: needs soft delete `is_deleted`? (auto-suggest YES if needs_status)
|
|
20
|
-
6. Column collection loop (repeat until "done"):
|
|
21
|
-
- Ask column name (snake_case) + type (show suggestion by name pattern):
|
|
22
|
-
- `*_id` → BIGINT NOT NULL DEFAULT 0 (also check FK — ask if references another table)
|
|
23
|
-
- `is_*` → BOOLEAN NOT NULL DEFAULT FALSE
|
|
24
|
-
- `*_at` → TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
25
|
-
- `status` → INTEGER NOT NULL DEFAULT 0 CHECK (status IN (0,1))
|
|
26
|
-
- `email` → VARCHAR(132) NOT NULL DEFAULT ''
|
|
27
|
-
- `phone` → VARCHAR(16) NOT NULL DEFAULT ''
|
|
28
|
-
- `password` → TEXT NOT NULL DEFAULT ''
|
|
29
|
-
- `*_image`, `*_url` → VARCHAR(255) NOT NULL DEFAULT ''
|
|
30
|
-
- `payload`, `metadata` → JSON NOT NULL DEFAULT '{}'
|
|
31
|
-
- Ask: is this an enum column? If yes → collect allowed values → CHECK constraint + COMMENT
|
|
32
|
-
7. Index suggestions: auto-suggest for every FK column, status+is_deleted compound, created_at DESC for logs
|
|
33
|
-
8. Ask: seed data needed? (YES only for reference/master tables)
|
|
34
|
-
9. Show complete table summary — ask: "Generate? (yes / no / change)"
|
|
35
|
-
10. Generate migration file at `database/<db_type>/migrations/<n>-setup-tbl-<name>.sql`
|
|
36
|
-
11. Update `create-schema.sql` with `\i` entry in numeric order
|
|
37
|
-
12. Call `context_write` — append to context.db.schema.tables and change_log
|
|
38
|
-
|
|
39
|
-
## /codeninja:db:modify — Alter Table
|
|
40
|
-
- Always generate an ALTER file — NEVER edit the original setup file
|
|
41
|
-
- Operations: add column, rename column, drop column, change type, add CHECK constraint, add index
|
|
42
|
-
- For "add index" → route to /codeninja:db:index instead
|
|
43
|
-
- Generated file: `<n>-alter-tbl-<name>-<description>.sql`
|
|
44
|
-
- Wrap in `BEGIN; ... COMMIT;`
|
|
45
|
-
|
|
46
|
-
## /codeninja:db:index — Add Index
|
|
47
|
-
- Ask: table, column(s), sort order (DESC?), standard vs partial (WHERE clause?)
|
|
48
|
-
- Ask: table's own file vs `111-setup-database-indexes.sql` (auto-suggest shared file for existing tables)
|
|
49
|
-
- Index naming: `idx_<table_without_tbl_prefix>_<columns>` (table file) or `idx_tbl_<name>_<columns>` (shared)
|
|
50
|
-
- Always show generated name and confirm before writing
|
|
51
|
-
|
|
52
|
-
## /codeninja:db:drop — Drop Table
|
|
53
|
-
- NEVER delete original setup file — generate new drop migration
|
|
54
|
-
- Show impact analysis: routes referencing table, FK dependencies
|
|
55
|
-
- Require user to type table name exactly to confirm
|
|
56
|
-
- Generated file: `<n>-drop-tbl-<name>.sql` with `DROP TABLE IF EXISTS ... CASCADE`
|
|
57
|
-
- Keep original `\i <setup_file>` in create-schema.sql — add drop file AFTER it
|
|
58
|
-
- Save full column snapshot to change_log before removing from active tables
|
|
59
|
-
|
|
60
|
-
## /codeninja:db:seed — Add Seed Data
|
|
61
|
-
- Determine: append to setup file (reference/master data) OR standalone seeds/ file (dev data)
|
|
62
|
-
- NEVER store plaintext passwords — warn user to provide encrypted value
|
|
63
|
-
- Multi-row INSERT only (single INSERT with multiple value tuples)
|
|
64
|
-
- File: `database/<db_type>/seeds/<table_name>_seed.sql`
|
|
65
|
-
|
|
66
|
-
## /codeninja:db:sync — Rebuild Schema from Files
|
|
67
|
-
- Parse all migration files in numeric order: setup → alter → drop → indexes
|
|
68
|
-
- Rebuild context.db.schema from actual file contents
|
|
69
|
-
- Rewrite create-schema.sql to match actual files on disk
|
|
70
|
-
- Report stale entries (in create-schema.sql but not on disk) and missing entries
|
|
71
|
-
|
|
72
|
-
## SQL Standards
|
|
73
|
-
```sql
|
|
74
|
-
-- Standard table structure
|
|
75
|
-
CREATE TABLE public.tbl_<name> (
|
|
76
|
-
id BIGSERIAL PRIMARY KEY,
|
|
77
|
-
-- ... columns ...
|
|
78
|
-
status INTEGER NOT NULL DEFAULT 0 CHECK (status IN (0,1)),
|
|
79
|
-
is_deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
|
80
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
COMMENT ON COLUMN public.tbl_<name>.<col> IS 'Values: 0=<label>, 1=<label>';
|
|
84
|
-
|
|
85
|
-
CREATE INDEX idx_<name>_<col> ON public.tbl_<name> (<col>);
|
|
86
|
-
|
|
87
|
-
GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_<name> TO <db_user>;
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
All ALTER and DROP migrations wrapped in `BEGIN; ... COMMIT;`.
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: codeninja ReactJS Frontend — scaffolding, modularize, validate-page, integrate-api
|
|
3
|
-
globs: ["**/src/**/*.jsx", "**/src/**/*.js", "**/public/**", "**/.htaccess"]
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# codeninja — ReactJS Frontend
|
|
8
|
-
|
|
9
|
-
## Backend Linking Rule (enforced)
|
|
10
|
-
ReactJS service CANNOT initialize without a linked NodeJS service.
|
|
11
|
-
Security values (KEY, IV, API_KEY) are ALWAYS inherited from the linked backend — never asked from user.
|
|
12
|
-
|
|
13
|
-
## /codeninja:init — ReactJS App Scaffolding
|
|
14
|
-
|
|
15
|
-
### Phase 1 — Linking
|
|
16
|
-
- List available NodeJS services from context.services
|
|
17
|
-
- Ask: which NodeJS service to link to?
|
|
18
|
-
- Auto-inherit: encryption_key, encryption_iv, api_key from linked service
|
|
19
|
-
- Ask: service name, description
|
|
20
|
-
|
|
21
|
-
### Phase 2 — Single Confirmation, Then Generate ALL Files
|
|
22
|
-
|
|
23
|
-
**Wave 1:** package.json, .env (inherited values), .env.example, .gitignore, README.md,
|
|
24
|
-
public/index.html, public/assets/css/style.css (empty reset), public/robots.txt,
|
|
25
|
-
public/favicon.ico (placeholder), .htaccess (root), public/.htaccess
|
|
26
|
-
|
|
27
|
-
**Wave 2:** src/api/apiClient.js, src/api/apiHandler.js
|
|
28
|
-
|
|
29
|
-
**Wave 3:** src/pages/Welcome/index.jsx, src/pages/Welcome/Welcome.module.css,
|
|
30
|
-
src/App.jsx, src/index.jsx, src/components/.gitkeep
|
|
31
|
-
|
|
32
|
-
**Wave 4:** Dockerfile, nginx.conf, .dockerignore
|
|
33
|
-
|
|
34
|
-
Completion gate — verify before proceeding:
|
|
35
|
-
- public/index.html, src/api/apiClient.js, src/api/apiHandler.js, src/App.jsx, src/index.jsx, .env
|
|
36
|
-
|
|
37
|
-
### apiClient.js — 4 Responsibilities
|
|
38
|
-
1. Static headers: `api-key` (from REACT_APP_API_KEY), `Accept-Language`, `Content-Type: text/plain`
|
|
39
|
-
2. Request interceptor: encrypt body; attach AES-encrypted `token` from localStorage (`wa_token`) if present
|
|
40
|
-
3. Response interceptor (success): decrypt body; parse JSON; code -1 → logout redirect
|
|
41
|
-
4. Response interceptor (error): ERR_NETWORK / 401 → logout redirect + error message
|
|
42
|
-
|
|
43
|
-
### apiHandler.js Standard
|
|
44
|
-
- One async function per API endpoint
|
|
45
|
-
- Each calls `axiosClient.post/get/put/patch/delete(path, payload)` and returns directly
|
|
46
|
-
- No try/catch, no decryption, no response shaping in this file
|
|
47
|
-
- Only place in frontend where API endpoint paths are written
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## /codeninja:modularize — Extract Layout Components
|
|
52
|
-
|
|
53
|
-
**Rule:** Layout structure only — NEVER touch business logic, state, API calls, event handlers.
|
|
54
|
-
NEVER create a component that already exists — reuse it.
|
|
55
|
-
|
|
56
|
-
1. Ask: which ReactJS service
|
|
57
|
-
2. Ask: all pages OR specific page
|
|
58
|
-
3. Inventory existing `src/components/` — record name, path, structural role, props
|
|
59
|
-
4. Scan target pages — identify repeated layout blocks (header, nav, footer, sidebar, etc.)
|
|
60
|
-
5. Cross-check: if block matches existing component → mark "reuse", else "new component needed"
|
|
61
|
-
6. Group blocks by similarity across pages — only extract if appears in 2+ pages
|
|
62
|
-
7. Show extraction plan with component names, props, files to create, pages to update
|
|
63
|
-
8. Ask: "Apply? (yes / no / adjust)"
|
|
64
|
-
9. Generate each new component:
|
|
65
|
-
- `src/components/<ComponentName>/index.jsx` — props for varying values
|
|
66
|
-
- `src/components/<ComponentName>/<ComponentName>.module.css`
|
|
67
|
-
10. Update each page: add import, replace extracted JSX with `<ComponentName prop={value} />`,
|
|
68
|
-
remove now-unused imports, remove moved CSS classes
|
|
69
|
-
11. Call `context_write` — append to context.services[<n>].components
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## /codeninja:validate-page — Add Form Validation
|
|
74
|
-
|
|
75
|
-
**Rule:** ONE page per run. NEVER modify API calls or business logic. NEVER overwrite existing validation.
|
|
76
|
-
|
|
77
|
-
1. Ask: which ReactJS service, which page path
|
|
78
|
-
2. Ask: validation library (Yup | React Hook Form | Parsley | Validator.js | Custom)
|
|
79
|
-
3. Scan page: find all `<form>`, `<input>`, `<select>`, `<textarea>`, `<button type="submit">`
|
|
80
|
-
4. For each field: record type, name, id, placeholder, label text, existing validation
|
|
81
|
-
5. Detect existing validation patterns — skip already-validated fields
|
|
82
|
-
6. Infer semantic type from label/name/placeholder → assign standard error messages:
|
|
83
|
-
- email: "Please enter a valid email address."
|
|
84
|
-
- password: "Password must be at least 8 characters."
|
|
85
|
-
- confirmPassword: "Password and confirm password do not match."
|
|
86
|
-
- phone: "Please enter a valid phone number."
|
|
87
|
-
- required generic: "This field is required."
|
|
88
|
-
7. Assign missing `name` and `id` attributes (camelCase from label text)
|
|
89
|
-
8. Show validation plan — ask: "Apply? (yes / no / adjust)"
|
|
90
|
-
9. Apply by library:
|
|
91
|
-
- **Yup:** validationSchema above component, validateForm async function, `{errors.field && <span>...}`
|
|
92
|
-
- **RHF:** useForm hook, `{...register('field', rules)}`, `{errors.field && <span>...}`
|
|
93
|
-
- **Parsley:** CDN scripts in index.html, data-parsley-* attributes, useEffect init
|
|
94
|
-
- **Validator.js:** import validator, validateForm function with validator.isEmail() etc.
|
|
95
|
-
- **Custom:** plain JS validateForm — no imports
|
|
96
|
-
10. Add `.errorMsg` class to page's `.module.css`
|
|
97
|
-
11. Add package to package.json if needed (yup/react-hook-form/validator)
|
|
98
|
-
12. Call `context_write` — append to context.services[<n>].validated_pages
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## /codeninja:integrate-api — Wire Forms to Backend
|
|
103
|
-
|
|
104
|
-
**Rule:** ONE page per run. NEVER modify layout, CSS, or validation. ALWAYS use apiHandler.js.
|
|
105
|
-
|
|
106
|
-
1. Ask: which ReactJS service, which page path
|
|
107
|
-
2. Ask: all forms/buttons OR specific form/button
|
|
108
|
-
3. Load: linked backend service, context.api_routes for that backend, page content, apiHandler.js
|
|
109
|
-
4. Scan page: identify all forms, action buttons, existing API calls
|
|
110
|
-
5. For each integration point, determine match type:
|
|
111
|
-
- existing handler → use as-is
|
|
112
|
-
- matching route in context.api_routes → add new handler to apiHandler.js
|
|
113
|
-
- no route exists → add TODO placeholder
|
|
114
|
-
6. Design state requirements (loading, error, data states) per form
|
|
115
|
-
7. Show integration plan with handler names, routes, match types, files to modify
|
|
116
|
-
8. Ask: "Apply? (yes / no / adjust)"
|
|
117
|
-
9. Apply:
|
|
118
|
-
- Append new functions to apiHandler.js (for new_handler and no_route matches)
|
|
119
|
-
- Add imports, state declarations, handler functions to page file (surgically — never rewrite)
|
|
120
|
-
- Wire form onSubmit / button onClick
|
|
121
|
-
- Add `disabled={loading}` and conditional button text
|
|
122
|
-
- Add `{error && <p className={styles.apiError}>{error}</p>}` above submit button
|
|
123
|
-
- Add `{successMsg && <p className={styles.successMsg}>{successMsg}</p>}` for non-nav actions
|
|
124
|
-
- Add useEffect for data-fetching handlers
|
|
125
|
-
- Add .apiError and .successMsg CSS classes to page's .module.css
|
|
126
|
-
10. Call `context_write` — append to context.services[<n>].integrated_pages
|
|
127
|
-
|
|
128
|
-
## File Structure
|
|
129
|
-
```
|
|
130
|
-
<service_name>/
|
|
131
|
-
public/
|
|
132
|
-
assets/css/style.css ← global styles
|
|
133
|
-
index.html ← single HTML shell
|
|
134
|
-
.htaccess ← SPA routing
|
|
135
|
-
src/
|
|
136
|
-
api/
|
|
137
|
-
apiClient.js ← Axios + encrypt/decrypt interceptors
|
|
138
|
-
apiHandler.js ← all API call functions
|
|
139
|
-
components/ ← shared reusable components
|
|
140
|
-
pages/<PageName>/ ← one directory per page
|
|
141
|
-
index.jsx
|
|
142
|
-
<PageName>.module.css
|
|
143
|
-
App.jsx ← React Router root
|
|
144
|
-
index.jsx ← ReactDOM.createRoot entry
|
|
145
|
-
.env ← REACT_APP_* (gitignored)
|
|
146
|
-
.env.example
|
|
147
|
-
```
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: codeninja code intelligence — loaded for explain, review, debug, optimize, audit commands
|
|
3
|
-
globs: ["**/*"]
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# codeninja — Code Intelligence
|
|
8
|
-
|
|
9
|
-
All analysis commands use real project context — real file names, real column names,
|
|
10
|
-
real service names from context.json. Never generic advice.
|
|
11
|
-
|
|
12
|
-
## Before Any Analysis
|
|
13
|
-
`context_read` → `fs_read` target → read 1–2 sibling files for pattern comparison.
|
|
14
|
-
|
|
15
|
-
## /codeninja:explain
|
|
16
|
-
```
|
|
17
|
-
What it is → 1–2 sentences, plain English
|
|
18
|
-
How it works → step-by-step key logic (skip boilerplate)
|
|
19
|
-
Why this way → architectural decision specific to this project
|
|
20
|
-
Where connects → related files, functions, context entries
|
|
21
|
-
```
|
|
22
|
-
Use real names throughout. End: "Want me to explain further or show how to modify it?"
|
|
23
|
-
|
|
24
|
-
## /codeninja:review — Checklist
|
|
25
|
-
|
|
26
|
-
| Category | Level if failing | Checks |
|
|
27
|
-
|----------|-----------------|--------|
|
|
28
|
-
| Security | CRITICAL | POST/PUT/PATCH has validatorjs; apiKey middleware present; JWT on protected routes; no hardcoded secrets; parameterized SQL only; errors don't leak internals |
|
|
29
|
-
| Architecture | WARNING | No SQL in route.js; no res.json() in _model.js; route_manager.js registered; swagger has entry; all strings in languages/en.js |
|
|
30
|
-
| Code Quality | SUGGESTION | JSDoc on every function; no unused imports; no console.log; try/catch on async; no SELECT * |
|
|
31
|
-
| Database | WARNING | Column names match context.db.schema; FK columns indexed; transactions on multi-write; LIMIT on unbounded queries |
|
|
32
|
-
|
|
33
|
-
Output per finding:
|
|
34
|
-
```
|
|
35
|
-
[CRITICAL|WARNING|SUGGESTION]
|
|
36
|
-
File: path (~line N)
|
|
37
|
-
Issue: one-line description
|
|
38
|
-
Before: current code
|
|
39
|
-
After: corrected code
|
|
40
|
-
Why: one sentence
|
|
41
|
-
```
|
|
42
|
-
End: `X critical · Y warnings · Z suggestions`
|
|
43
|
-
Offer to apply. Confirm each before writing.
|
|
44
|
-
|
|
45
|
-
## /codeninja:debug — Root Cause Process
|
|
46
|
-
|
|
47
|
-
Gather: error + stack trace, endpoint, expected vs actual, recent changes.
|
|
48
|
-
|
|
49
|
-
Request lifecycle trace order:
|
|
50
|
-
```
|
|
51
|
-
Language middleware → API key → JWT auth → Rate limit → Validation → Handler → Model → DB → Response
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Common root causes:
|
|
55
|
-
| Symptom | Check |
|
|
56
|
-
|---------|-------|
|
|
57
|
-
| `column does not exist` | context.db.schema vs code column names |
|
|
58
|
-
| `undefined is not a function` | wrong import or missing export |
|
|
59
|
-
| `Cannot read property` | missing null check after 0-row DB result |
|
|
60
|
-
| `401 Unauthorized` | middleware order, header name spelling |
|
|
61
|
-
| `500` | missing try/catch on async DB call |
|
|
62
|
-
| Wrong row count | RANK vs DENSE_RANK, missing WHERE, missing dedup |
|
|
63
|
-
| Migration not applied | table in code but not in DB — run migration |
|
|
64
|
-
|
|
65
|
-
Fix output:
|
|
66
|
-
```
|
|
67
|
-
Root cause: [precise one sentence]
|
|
68
|
-
File: path
|
|
69
|
-
Before: [buggy code]
|
|
70
|
-
After: [fixed code]
|
|
71
|
-
Why: [one sentence]
|
|
72
|
-
```
|
|
73
|
-
Confirm before applying. Suggest one prevention guard after fix.
|
|
74
|
-
|
|
75
|
-
## /codeninja:optimize — Analysis Checks
|
|
76
|
-
|
|
77
|
-
DB queries (cross-reference `context.db.schema.<table>.indexes`):
|
|
78
|
-
- Missing index on WHERE/JOIN/ORDER BY column → `CREATE INDEX CONCURRENTLY`
|
|
79
|
-
- `SELECT *` → explicit column list
|
|
80
|
-
- N+1 loop → JOIN or IN clause
|
|
81
|
-
- No `LIMIT` on list queries
|
|
82
|
-
- `RANK()` on leaderboards → `DENSE_RANK()` (no gaps after ties)
|
|
83
|
-
- `DATE(col)` in WHERE → range filter (preserves index use)
|
|
84
|
-
- Duplicate rows → `MIN(id) GROUP BY` dedup
|
|
85
|
-
- Sort spilling to disk → `SET work_mem = '64MB'` session-level
|
|
86
|
-
|
|
87
|
-
API routes:
|
|
88
|
-
- Repeated DB calls → Redis cache suggestion
|
|
89
|
-
- Missing pagination on list endpoints
|
|
90
|
-
|
|
91
|
-
Output:
|
|
92
|
-
```
|
|
93
|
-
[HIGH|MED|LOW]
|
|
94
|
-
Target: what is slow
|
|
95
|
-
Cause: why it is slow
|
|
96
|
-
Fix: exact SQL or code
|
|
97
|
-
Gain: concrete estimate
|
|
98
|
-
```
|
|
99
|
-
For index additions: `migration_next_number` → generate `.sql` migration.
|
|
100
|
-
`context_write` after applying index changes.
|
|
101
|
-
|
|
102
|
-
## /codeninja:audit — Full Service
|
|
103
|
-
|
|
104
|
-
Runs full review checklist PLUS:
|
|
105
|
-
- `analyze_middleware_order` MCP tool
|
|
106
|
-
- `analyze_encryption_library` MCP tool
|
|
107
|
-
- `analyze_language_keys` MCP tool
|
|
108
|
-
- `analyze_dependencies` MCP tool
|
|
109
|
-
- `analyze_env_file` MCP tool
|
|
110
|
-
- context.db.schema vs actual code column/table references
|
|
111
|
-
|
|
112
|
-
Output: severity-ranked report by category. Auto-fix SUGGESTION. Confirm WARNING/CRITICAL.
|