codeninja 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -251
- package/agent/global-agent.md +8 -0
- package/cli.js +248 -223
- package/commands/debug.workflow.md +94 -0
- package/commands/explain.workflow.md +59 -0
- package/commands/optimize.workflow.md +124 -0
- package/commands/review.workflow.md +85 -0
- package/ide/antigravity/.agents/personas/database-architect.md +249 -0
- package/ide/antigravity/.agents/personas/global-orchestrator.md +125 -0
- package/ide/antigravity/.agents/personas/nodejs-backend.md +250 -0
- package/ide/antigravity/.agents/personas/reactjs-frontend.md +179 -0
- package/ide/antigravity/.agents/skills/api-builder/SKILL.md +179 -0
- package/ide/antigravity/.agents/skills/code-intelligence/SKILL.md +184 -0
- package/ide/antigravity/.agents/skills/database/SKILL.md +165 -0
- package/ide/antigravity/.agents/skills/mcp-and-context/SKILL.md +111 -0
- package/ide/antigravity/.agents/skills/reactjs/SKILL.md +211 -0
- package/ide/antigravity/.agents/workflows/codeninja-api.md +28 -0
- package/ide/antigravity/.agents/workflows/codeninja-audit.md +23 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-create.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-index.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +10 -0
- package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +12 -0
- package/ide/antigravity/.agents/workflows/codeninja-debug.md +12 -0
- package/ide/antigravity/.agents/workflows/codeninja-design.md +21 -0
- package/ide/antigravity/.agents/workflows/codeninja-explain.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-init.md +29 -0
- package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-modularize.md +11 -0
- package/ide/antigravity/.agents/workflows/codeninja-optimize.md +13 -0
- package/ide/antigravity/.agents/workflows/codeninja-refactor.md +23 -0
- package/ide/antigravity/.agents/workflows/codeninja-review.md +12 -0
- package/ide/antigravity/.agents/workflows/codeninja-sync.md +23 -0
- package/ide/antigravity/.agents/workflows/codeninja-test.md +19 -0
- package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +11 -0
- package/ide/cursor/.cursor/mcp.json +8 -0
- package/ide/cursor/.cursor/rules/01-global-orchestrator.mdc +60 -0
- package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +38 -0
- package/ide/cursor/.cursor/rules/03-api-builder.mdc +74 -0
- package/ide/cursor/.cursor/rules/04-database.mdc +87 -0
- package/ide/cursor/.cursor/rules/05-reactjs.mdc +83 -0
- package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +112 -0
- package/ide/vscode/.github/copilot-instructions.md +285 -0
- package/ide/vscode/.vscode/mcp.json +9 -0
- package/package.json +24 -23
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
skill: reactjs
|
|
3
|
+
scope: reactjs-commands
|
|
4
|
+
loaded-for:
|
|
5
|
+
- /codeninja:init (reactjs type)
|
|
6
|
+
- @modularize
|
|
7
|
+
- @validate-page
|
|
8
|
+
- @integrate-api
|
|
9
|
+
description: >
|
|
10
|
+
All technical standards for ReactJS frontend development — file structure,
|
|
11
|
+
apiClient/apiHandler patterns, encryption inheritance, routing standards,
|
|
12
|
+
and component conventions. The reactjs-frontend persona uses this skill.
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Skill: ReactJS Frontend
|
|
16
|
+
|
|
17
|
+
Technical standards for every ReactJS file in this project.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Backend Linking (enforced before any generation)
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
context.current_init.linked_service → backend service name
|
|
25
|
+
context.services[linked].port → REACT_APP_BASE_URL port
|
|
26
|
+
context.services[linked].encryption_key → REACT_APP_KEY
|
|
27
|
+
context.services[linked].encryption_iv → REACT_APP_IV
|
|
28
|
+
context.services[linked].api_key → REACT_APP_API_KEY
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
These 4 values are inherited — NEVER ask the user for them.
|
|
32
|
+
NEVER hardcode any key, IV, or API key value.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## apiClient.js — Exact Specification
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// src/api/apiClient.js
|
|
40
|
+
// Axios instance — all cross-cutting concerns live here
|
|
41
|
+
|
|
42
|
+
import axios from 'axios';
|
|
43
|
+
import CryptoJS from 'crypto-js';
|
|
44
|
+
import { logOutRedirectCall, showErrorMessage } from '../pages/common/Utils';
|
|
45
|
+
|
|
46
|
+
const KEY = CryptoJS.enc.Hex.parse(process.env.REACT_APP_KEY);
|
|
47
|
+
const IV = CryptoJS.enc.Hex.parse(process.env.REACT_APP_IV);
|
|
48
|
+
|
|
49
|
+
const axiosClient = axios.create({
|
|
50
|
+
baseURL: process.env.REACT_APP_BASE_URL,
|
|
51
|
+
headers: {
|
|
52
|
+
'api-key': process.env.REACT_APP_API_KEY,
|
|
53
|
+
'Content-Type': 'text/plain',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Request interceptor: encrypt body, attach token
|
|
58
|
+
axiosClient.interceptors.request.use((config) => {
|
|
59
|
+
const token = localStorage.getItem('wa_token');
|
|
60
|
+
if (token) {
|
|
61
|
+
config.headers['token'] = CryptoJS.AES.encrypt(token, KEY, { iv: IV }).toString();
|
|
62
|
+
}
|
|
63
|
+
if (config.data) {
|
|
64
|
+
config.data = CryptoJS.AES.encrypt(JSON.stringify(config.data), KEY, { iv: IV }).toString();
|
|
65
|
+
}
|
|
66
|
+
return config;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Response interceptor: decrypt body
|
|
70
|
+
axiosClient.interceptors.response.use(
|
|
71
|
+
(response) => {
|
|
72
|
+
try {
|
|
73
|
+
const bytes = CryptoJS.AES.decrypt(response.data, KEY, { iv: IV });
|
|
74
|
+
const parsed = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
|
75
|
+
if (parsed.status === -1) { logOutRedirectCall(); }
|
|
76
|
+
return { ...response, data: parsed };
|
|
77
|
+
} catch {
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
(error) => {
|
|
82
|
+
if (!error.response || error.response.status === 401) {
|
|
83
|
+
logOutRedirectCall();
|
|
84
|
+
showErrorMessage('Session expired. Please log in again.');
|
|
85
|
+
}
|
|
86
|
+
return Promise.reject(error);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export default axiosClient;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## apiHandler.js — Pattern
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
// src/api/apiHandler.js
|
|
99
|
+
import axiosClient from './apiClient';
|
|
100
|
+
import { saveWebSession } from '../pages/common/Utils';
|
|
101
|
+
|
|
102
|
+
// POST /login — authenticate user
|
|
103
|
+
export const webLogin = async ({ email, password }) => {
|
|
104
|
+
const payload = { email, password, device_type: 'web', device_token: '' };
|
|
105
|
+
const res = await axiosClient.post('/login', payload);
|
|
106
|
+
if (res.data.status === 1) saveWebSession(res.data.data);
|
|
107
|
+
return res.data;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// POST /<path> — description
|
|
111
|
+
export const <functionName> = async (data) => {
|
|
112
|
+
const res = await axiosClient.post('/<path>', data);
|
|
113
|
+
return res.data;
|
|
114
|
+
};
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Rules:
|
|
118
|
+
- One function per endpoint
|
|
119
|
+
- No try/catch here — interceptors handle errors
|
|
120
|
+
- No decryption here — interceptors handle it
|
|
121
|
+
- Session saving happens in the handler, not in UI components
|
|
122
|
+
- Generate handlers matching `context.api_routes` for the linked service
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Component Standards
|
|
127
|
+
|
|
128
|
+
- Functional components only — no class components
|
|
129
|
+
- JSDoc above every exported function and component
|
|
130
|
+
- No inline styles — `.module.css` per page, `global.css` for shared
|
|
131
|
+
- No `console.log` — use `showMessage` / `showErrorMessage`
|
|
132
|
+
- No hardcoded API paths — all calls through `apiHandler.js`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Welcome Page Standard
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
// src/pages/Welcome/index.jsx
|
|
140
|
+
import React from 'react';
|
|
141
|
+
import styles from './Welcome.module.css';
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Default landing page displayed after app initialisation.
|
|
145
|
+
* @returns {JSX.Element} Welcome screen with project name.
|
|
146
|
+
*/
|
|
147
|
+
const Welcome = () => (
|
|
148
|
+
<div className={styles.container}>
|
|
149
|
+
<h1>{process.env.REACT_APP_PROJECT_NAME || '<project_name>'}</h1>
|
|
150
|
+
<p>Welcome. Your application is ready.</p>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
export default Welcome;
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## App.jsx Standard
|
|
160
|
+
|
|
161
|
+
```jsx
|
|
162
|
+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
163
|
+
import Welcome from './pages/Welcome';
|
|
164
|
+
|
|
165
|
+
function App() {
|
|
166
|
+
return (
|
|
167
|
+
<BrowserRouter>
|
|
168
|
+
<Routes>
|
|
169
|
+
<Route path="/" element={<Welcome />} />
|
|
170
|
+
{/* Additional routes added as project grows */}
|
|
171
|
+
</Routes>
|
|
172
|
+
</BrowserRouter>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export default App;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## @modularize Workflow
|
|
182
|
+
|
|
183
|
+
1. Scan all pages in `src/pages/`
|
|
184
|
+
2. Identify repeated layout blocks (header, footer, sidebar, nav)
|
|
185
|
+
3. Show user: "Found repeated blocks in X pages. Extract to components?"
|
|
186
|
+
4. For each block → create `src/components/<BlockName>/index.jsx` + `.module.css`
|
|
187
|
+
5. Rewrite each page to import and use the component
|
|
188
|
+
6. Never change the page's data-fetching logic or state — layout only
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## @validate-page Workflow
|
|
193
|
+
|
|
194
|
+
1. Ask: which page to add validation to
|
|
195
|
+
2. Read the page file
|
|
196
|
+
3. Ask: preferred validation library (validatorjs / Yup / custom)
|
|
197
|
+
4. Add validation on form submit — check required fields, types, formats
|
|
198
|
+
5. Display error messages per field below the input
|
|
199
|
+
6. Never add validation that requires a backend call — client-side only
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## @integrate-api Workflow
|
|
204
|
+
|
|
205
|
+
1. Ask: which page to wire up
|
|
206
|
+
2. Read the page file and `src/api/apiHandler.js`
|
|
207
|
+
3. Identify buttons/forms in the page that need API calls
|
|
208
|
+
4. Add the appropriate handler function in `apiHandler.js` if not present
|
|
209
|
+
5. Wire form submit and button clicks to handler functions
|
|
210
|
+
6. Add loading state (boolean), error state (string), success state
|
|
211
|
+
7. Show loading spinner during API call, error message on failure, success feedback on completion
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:api
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder]
|
|
5
|
+
description: Add a new API endpoint to an existing NodeJS service using the 5-step SOP
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:api
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/create-api.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_check_stale`
|
|
14
|
+
2. Call `context_read` — load `context.services` and `context.db.schema`
|
|
15
|
+
3. Read 1–2 existing modules in the target service to understand current patterns
|
|
16
|
+
|
|
17
|
+
## Execution
|
|
18
|
+
Read and execute `create-api.workflow.md` step by step.
|
|
19
|
+
ONE confirmation after showing module details, then generate all files silently:
|
|
20
|
+
- `route.js` → task: generate-route
|
|
21
|
+
- `<module>_model.js` → task: generate-model
|
|
22
|
+
- Append to `route_manager.js` → `file_insert_after` MCP tool (NEVER rewrite)
|
|
23
|
+
- Patch `swagger_doc.json` → `file_insert_after` MCP tool (add new path only)
|
|
24
|
+
|
|
25
|
+
## After Running
|
|
26
|
+
Call `context_write` — append to `context.api_routes`, update `context.services[<n>].modules`.
|
|
27
|
+
Call `context_clear_scratchpad` for `current_api`.
|
|
28
|
+
Show `show-final-summary` task output.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:audit
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder, code-intelligence]
|
|
5
|
+
description: Security and quality review of a NodeJS service
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:audit
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/audit.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_read`
|
|
14
|
+
2. Ask: "Which service do you want to audit?" — list from `context.services`
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
Read and execute `audit.workflow.md`.
|
|
18
|
+
Use MCP tools: `analyze_middleware_order`, `analyze_encryption_library`,
|
|
19
|
+
`analyze_language_keys`, `analyze_dependencies`, `analyze_env_file`.
|
|
20
|
+
|
|
21
|
+
## Output
|
|
22
|
+
Severity-ranked report: CRITICAL → WARNING → SUGGESTION.
|
|
23
|
+
Offer to auto-fix SUGGESTION items. Fix WARNING/CRITICAL one at a time with confirmation.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:create
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Design and generate a new table with migration file
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:create
|
|
8
|
+
Delegates to: `.codeninja/commands/db-create-table.workflow.md`
|
|
9
|
+
Before: `context_read` (load context.db fully), `context_check_stale`, `migration_next_number`.
|
|
10
|
+
One question at a time. Never invent names — all from context.db.schema.
|
|
11
|
+
After: `context_write` updated schema, `context_clear_scratchpad` for current_table.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:drop
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Drop a table with a DROP migration file
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:drop
|
|
8
|
+
Delegates to: `.codeninja/commands/db-drop-table.workflow.md`
|
|
9
|
+
Before: `context_read`, `migration_next_number`.
|
|
10
|
+
WARN user: "This is destructive. Confirm you want to DROP [table]?"
|
|
11
|
+
After: `context_write` — remove table from context.db.schema.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:index
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Add a new index to an existing table with migration file
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:index
|
|
8
|
+
Delegates to: `.codeninja/commands/db-add-index.workflow.md`
|
|
9
|
+
Before: `context_read`, `migration_next_number`.
|
|
10
|
+
Show existing indexes from context.db.schema before suggesting new ones.
|
|
11
|
+
After: `context_write` with updated index list.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:modify
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Add, rename, or drop a column via ALTER migration
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:modify
|
|
8
|
+
Delegates to: `.codeninja/commands/db-modify-table.workflow.md`
|
|
9
|
+
Before: `context_read`, `migration_next_number`.
|
|
10
|
+
Show existing columns from context.db.schema before asking which to change.
|
|
11
|
+
After: `context_write` with updated column list.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:seed
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Add or update seed data for a table
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:seed
|
|
8
|
+
Delegates to: `.codeninja/commands/db-seed.workflow.md`
|
|
9
|
+
Before: `context_read` — load context.db.schema for real column names.
|
|
10
|
+
After: `context_write` to record seed file location.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:db:sync
|
|
3
|
+
personas: [global-orchestrator, database-architect]
|
|
4
|
+
skills: [mcp-and-context, database]
|
|
5
|
+
description: Scan migration files and rebuild context.db.schema
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:db:sync
|
|
8
|
+
Delegates to: `.codeninja/commands/db-sync.workflow.md`
|
|
9
|
+
Before: `context_read`, `fs_list` all migration files.
|
|
10
|
+
Compare files on disk vs context.db.schema — surface all gaps.
|
|
11
|
+
User approves before context is updated.
|
|
12
|
+
After: `context_write` with fully rebuilt context.db.schema.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:debug
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder, code-intelligence]
|
|
5
|
+
description: Diagnose and fix a bug by tracing the actual request code path
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:debug
|
|
8
|
+
Delegates to: `.codeninja/commands/debug.workflow.md`
|
|
9
|
+
Before: `context_read`. Gather: error + stack, endpoint, expected vs actual, recent changes.
|
|
10
|
+
Trace full request lifecycle. Find exact failure step.
|
|
11
|
+
Output: root cause + before/after fix. Confirm before applying.
|
|
12
|
+
Suggest one guard to prevent recurrence.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:design
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend OR database-architect]
|
|
4
|
+
skills: [mcp-and-context, api-builder OR database]
|
|
5
|
+
description: Plan a feature, API contract, or DB change before writing any code
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:design
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/design.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_read` — load full project context
|
|
14
|
+
2. Determine if this is an API design (nodejs-backend + api-builder) or DB design (database-architect + database)
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
Read and execute `design.workflow.md` step by step.
|
|
18
|
+
Produce a written plan before any code is generated. User approves plan before execution begins.
|
|
19
|
+
|
|
20
|
+
## After Running
|
|
21
|
+
Call `context_write` with design notes stored in `context.current_design`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:explain
|
|
3
|
+
personas: [global-orchestrator, context-aware]
|
|
4
|
+
skills: [mcp-and-context, code-intelligence]
|
|
5
|
+
description: Explain any file, function, pattern, or concept with full project context
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:explain
|
|
8
|
+
Delegates to: `.codeninja/commands/explain.workflow.md`
|
|
9
|
+
Before: call `context_read`, `fs_read` on target.
|
|
10
|
+
Structure: What it is → How it works → Why this way → Where it connects.
|
|
11
|
+
Use real names from context. End with offer to explain further.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:init
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend OR reactjs-frontend OR database-architect]
|
|
4
|
+
skills: [mcp-and-context, api-builder OR reactjs OR database]
|
|
5
|
+
description: Bootstrap a new NodeJS service, ReactJS app, or database
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:init
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/initialize-project.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_check_stale` — resolve stale operations first
|
|
14
|
+
2. Call `context_read` — if context_version > 0, warn: "Already initialized. Use /codeninja:sync to update."
|
|
15
|
+
3. Determine project type → route to correct specialist persona and load matching skill
|
|
16
|
+
|
|
17
|
+
## Specialist Routing
|
|
18
|
+
- NodeJS service → `nodejs-backend` persona + `api-builder` skill
|
|
19
|
+
- ReactJS app → `reactjs-frontend` persona + `reactjs` skill (requires linked NodeJS service)
|
|
20
|
+
- Database → `database-architect` persona + `database` skill
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
Read and execute `initialize-project.workflow.md` step by step. One question at a time.
|
|
24
|
+
ONE confirmation at `show-init-summary`, then generate all files silently.
|
|
25
|
+
|
|
26
|
+
## After Running
|
|
27
|
+
Call `context_write` with all project information.
|
|
28
|
+
Call `context_clear_scratchpad` for `current_init`.
|
|
29
|
+
Show `show-init-summary` task output.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: @integrate-api
|
|
3
|
+
personas: [global-orchestrator, reactjs-frontend]
|
|
4
|
+
skills: [mcp-and-context, reactjs]
|
|
5
|
+
description: Wire forms and action buttons to API handler functions
|
|
6
|
+
---
|
|
7
|
+
# @integrate-api
|
|
8
|
+
Delegates to: `.codeninja/commands/integrate-api.workflow.md`
|
|
9
|
+
Before: `context_read`. Read target page and apiHandler.js.
|
|
10
|
+
Add handler functions in apiHandler.js if missing.
|
|
11
|
+
Wire buttons/forms to handlers. Add loading, error, success states.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: @modularize
|
|
3
|
+
personas: [global-orchestrator, reactjs-frontend]
|
|
4
|
+
skills: [mcp-and-context, reactjs]
|
|
5
|
+
description: Extract repeated layout blocks into reusable React components
|
|
6
|
+
---
|
|
7
|
+
# @modularize
|
|
8
|
+
Delegates to: `.codeninja/commands/modularize.workflow.md`
|
|
9
|
+
Before: `context_read`. Confirm linked NodeJS service exists.
|
|
10
|
+
Scan all pages, identify repeated layout blocks.
|
|
11
|
+
Show user what will be extracted and confirm before changes.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:optimize
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend, database-architect]
|
|
4
|
+
skills: [mcp-and-context, api-builder, database, code-intelligence]
|
|
5
|
+
description: Find and fix performance bottlenecks with concrete impact estimates
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:optimize
|
|
8
|
+
Delegates to: `.codeninja/commands/optimize.workflow.md`
|
|
9
|
+
Before: `context_read` for `context.db.schema` and `context.services`.
|
|
10
|
+
Ask: slow endpoint / heavy query / startup / describe it.
|
|
11
|
+
Cross-reference existing indexes. Generate migration via `migration_next_number`.
|
|
12
|
+
Output: [HIGH|MED|LOW] ranked. Confirm before applying.
|
|
13
|
+
`context_write` after index additions.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:refactor
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder]
|
|
5
|
+
description: Rename or restructure code with full context tracking
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:refactor
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/refactor.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_read`
|
|
14
|
+
2. Ask: "What are you refactoring?" — field rename, file restructure, module rename?
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
Read and execute `refactor.workflow.md`.
|
|
18
|
+
Show full list of affected files before making any change.
|
|
19
|
+
ONE confirmation, then apply all changes.
|
|
20
|
+
Update `context.change_log` with before/after record.
|
|
21
|
+
|
|
22
|
+
## After Running
|
|
23
|
+
Call `context_write` with updated service/module names if renamed.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:review
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder, code-intelligence]
|
|
5
|
+
description: Code review — severity-ranked findings with exact before/after fixes
|
|
6
|
+
---
|
|
7
|
+
# /codeninja:review
|
|
8
|
+
Delegates to: `.codeninja/commands/review.workflow.md`
|
|
9
|
+
Before: `context_read`, `fs_read` target, read 1–2 sibling modules.
|
|
10
|
+
Run full checklist: Security → Architecture → Code Quality → Database.
|
|
11
|
+
Output: [CRITICAL|WARNING|SUGGESTION] with before/after code.
|
|
12
|
+
Offer to apply fixes. Confirm each before writing.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:sync
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context]
|
|
5
|
+
description: Scan the entire repo and rebuild context.json from disk
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:sync
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/sync.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_read` — load current state
|
|
14
|
+
2. Call `service_scan` — discover all services on disk
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
Read and execute `sync.workflow.md`.
|
|
18
|
+
Use `run_drift_check` MCP tool to compare context vs disk.
|
|
19
|
+
Surface all detected drifts before writing anything.
|
|
20
|
+
User approves the sync before context is updated.
|
|
21
|
+
|
|
22
|
+
## After Running
|
|
23
|
+
Call `context_write` with fully rebuilt context.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: /codeninja:test
|
|
3
|
+
personas: [global-orchestrator, nodejs-backend]
|
|
4
|
+
skills: [mcp-and-context, api-builder]
|
|
5
|
+
description: Generate Jest + Supertest test files for a module
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /codeninja:test
|
|
9
|
+
|
|
10
|
+
Delegates to: `.codeninja/commands/test.workflow.md`
|
|
11
|
+
|
|
12
|
+
## Before Running
|
|
13
|
+
1. Call `context_read`
|
|
14
|
+
2. Ask: "Which module and service?" — list from `context.services[<n>].modules`
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
Read and execute `test.workflow.md`.
|
|
18
|
+
Generate `tests/v1/<ModuleName>.test.js`.
|
|
19
|
+
Tests cover: happy path, each validation failure, auth failure, edge cases.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
slash_command: @validate-page
|
|
3
|
+
personas: [global-orchestrator, reactjs-frontend]
|
|
4
|
+
skills: [mcp-and-context, reactjs]
|
|
5
|
+
description: Add client-side form validation to a specific React page
|
|
6
|
+
---
|
|
7
|
+
# @validate-page
|
|
8
|
+
Delegates to: `.codeninja/commands/validate-page.workflow.md`
|
|
9
|
+
Before: `context_read`. Ask which page. Ask preferred validation library.
|
|
10
|
+
Add per-field validation on submit. Display error messages below inputs.
|
|
11
|
+
Client-side only — no backend calls.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: codeninja global orchestrator — routing, context, activation. Always applied.
|
|
3
|
+
globs: ["**/*"]
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# codeninja — Global Orchestrator
|
|
8
|
+
|
|
9
|
+
You are a Senior Software Architect managing this project via the codeninja agent system.
|
|
10
|
+
|
|
11
|
+
## Activation Sequence (every session)
|
|
12
|
+
1. Call `context_check_stale` — resolve stale operations first
|
|
13
|
+
2. Call `context_read` — load full context
|
|
14
|
+
3. Call `service_scan` — compare with `context.services`; if drift detected, suggest `/codeninja:sync`
|
|
15
|
+
4. Load `context.project_info` for all suggestions
|
|
16
|
+
|
|
17
|
+
## Routing
|
|
18
|
+
| Keyword | Specialist |
|
|
19
|
+
|---------|-----------|
|
|
20
|
+
| express, node, api, service, encryption | nodejs-backend rules |
|
|
21
|
+
| react, frontend, ui, component | reactjs-frontend rules |
|
|
22
|
+
| postgres, mysql, db, schema, migration, table | database-architect rules |
|
|
23
|
+
| /codeninja:db:* | always database-architect |
|
|
24
|
+
|
|
25
|
+
## Context Rules
|
|
26
|
+
- NEVER read/write context.json directly — always use `context_read` / `context_write`
|
|
27
|
+
- `context_write` deep-merges — never overwrites
|
|
28
|
+
- `change_log` append-only
|
|
29
|
+
|
|
30
|
+
## Batch Generation Rule
|
|
31
|
+
ONE confirmation per operation. After user confirms → generate all files silently.
|
|
32
|
+
|
|
33
|
+
## Response Style
|
|
34
|
+
- One question at a time
|
|
35
|
+
- Confirm before creating or modifying files
|
|
36
|
+
- `database/` folder ALWAYS at repository root — never inside a service
|
|
37
|
+
|
|
38
|
+
## Slash Commands
|
|
39
|
+
| Command | Description |
|
|
40
|
+
|---------|-------------|
|
|
41
|
+
| `/codeninja:init` | Bootstrap NodeJS service, ReactJS app, or database |
|
|
42
|
+
| `/codeninja:api` | Add API endpoint (5-step SOP) |
|
|
43
|
+
| `/codeninja:design` | Plan feature before coding |
|
|
44
|
+
| `/codeninja:audit` | Security and quality review |
|
|
45
|
+
| `/codeninja:test` | Generate Jest tests |
|
|
46
|
+
| `/codeninja:refactor` | Rename with context tracking |
|
|
47
|
+
| `/codeninja:sync` | Rebuild context from repo |
|
|
48
|
+
| `/codeninja:explain` | Explain any file or pattern |
|
|
49
|
+
| `/codeninja:review` | Code review with findings |
|
|
50
|
+
| `/codeninja:debug` | Debug with code path trace |
|
|
51
|
+
| `/codeninja:optimize` | Performance improvements |
|
|
52
|
+
| `/codeninja:db:create` | New table + migration |
|
|
53
|
+
| `/codeninja:db:modify` | Alter column |
|
|
54
|
+
| `/codeninja:db:index` | Add index |
|
|
55
|
+
| `/codeninja:db:drop` | Drop table |
|
|
56
|
+
| `/codeninja:db:seed` | Add seed data |
|
|
57
|
+
| `/codeninja:db:sync` | Rebuild DB schema |
|
|
58
|
+
| `@modularize` | Extract React layout components |
|
|
59
|
+
| `@validate-page` | Add form validation |
|
|
60
|
+
| `@integrate-api` | Wire forms to API handlers |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: codeninja MCP tools and context management — always applied
|
|
3
|
+
globs: ["**/*"]
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# codeninja — MCP and Context
|
|
8
|
+
|
|
9
|
+
## MCP Tools Reference
|
|
10
|
+
| Tool | Use |
|
|
11
|
+
|------|-----|
|
|
12
|
+
| `context_read` | Load project context — FIRST on every activation |
|
|
13
|
+
| `context_write` | Persist changes — deep-merge, never overwrite |
|
|
14
|
+
| `context_clear_scratchpad` | Clear current_* key after operation |
|
|
15
|
+
| `context_check_stale` | Detect unresolved operations — Step 0 |
|
|
16
|
+
| `service_scan` | Discover services on disk |
|
|
17
|
+
| `migration_next_number` | Before any migration file creation |
|
|
18
|
+
| `fs_read` | Read file before modifying |
|
|
19
|
+
| `fs_list` | List directory contents |
|
|
20
|
+
| `fs_exists` | Check existence before conditional ops |
|
|
21
|
+
| `file_insert_after` | Surgical append (route_manager, swagger) |
|
|
22
|
+
| `file_contains` | Check before appending to avoid duplicates |
|
|
23
|
+
| `run_drift_check` | Context vs disk comparison during @sync |
|
|
24
|
+
| `lint_file` | Lint after generating JS/SQL |
|
|
25
|
+
| `analyze_middleware_order` | Check middleware chain during @audit |
|
|
26
|
+
| `analyze_encryption_library` | Verify encryption during @audit |
|
|
27
|
+
| `analyze_language_keys` | Check i18n during @audit |
|
|
28
|
+
| `analyze_dependencies` | Scan package.json during @audit |
|
|
29
|
+
| `analyze_env_file` | Check .env completeness during @audit |
|
|
30
|
+
| `validate_redis_connection` | Test Redis during init |
|
|
31
|
+
| `validate_postgres_connection` | Test DB during init |
|
|
32
|
+
|
|
33
|
+
## Absolute Rules
|
|
34
|
+
- NEVER read context.json with fs_read — always `context_read`
|
|
35
|
+
- NEVER write context.json directly — always `context_write`
|
|
36
|
+
- `change_log` is append-only — never delete entries
|
|
37
|
+
- Always call `context_check_stale` before starting any workflow
|
|
38
|
+
- Always call `context_clear_scratchpad` after completing a workflow
|