class-ai-agent 1.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 (93) hide show
  1. package/.claude/CLAUDE.md +155 -0
  2. package/.claude/agents/backend.md +395 -0
  3. package/.claude/agents/code-reviewer.md +110 -0
  4. package/.claude/agents/copywriter-seo.md +236 -0
  5. package/.claude/agents/frontend.md +384 -0
  6. package/.claude/agents/project-manager.md +201 -0
  7. package/.claude/agents/qa.md +221 -0
  8. package/.claude/agents/security-auditor.md +143 -0
  9. package/.claude/agents/systems-architect.md +211 -0
  10. package/.claude/agents/test-engineer.md +123 -0
  11. package/.claude/agents/ui-ux-designer.md +210 -0
  12. package/.claude/commands/build.md +132 -0
  13. package/.claude/commands/debug.md +242 -0
  14. package/.claude/commands/deploy.md +40 -0
  15. package/.claude/commands/fix-issue.md +42 -0
  16. package/.claude/commands/plan.md +125 -0
  17. package/.claude/commands/review.md +50 -0
  18. package/.claude/commands/simplify.md +222 -0
  19. package/.claude/commands/spec.md +95 -0
  20. package/.claude/commands/test.md +214 -0
  21. package/.claude/references/accessibility-checklist.md +174 -0
  22. package/.claude/references/performance-checklist.md +150 -0
  23. package/.claude/references/security-checklist.md +94 -0
  24. package/.claude/references/testing-patterns.md +183 -0
  25. package/.claude/rules/api-conventions.md +79 -0
  26. package/.claude/rules/clean-code.md +205 -0
  27. package/.claude/rules/code-style.md +86 -0
  28. package/.claude/rules/database.md +60 -0
  29. package/.claude/rules/error-handling.md +92 -0
  30. package/.claude/rules/git-workflow.md +77 -0
  31. package/.claude/rules/monitoring.md +311 -0
  32. package/.claude/rules/naming-conventions.md +260 -0
  33. package/.claude/rules/project-structure.md +65 -0
  34. package/.claude/rules/security.md +90 -0
  35. package/.claude/rules/system-design.md +162 -0
  36. package/.claude/rules/tech-stack.md +456 -0
  37. package/.claude/rules/testing.md +104 -0
  38. package/.claude/settings.json +14 -0
  39. package/.claude/skills/code-review/SKILL.md +208 -0
  40. package/.claude/skills/deploy/SKILL.md +68 -0
  41. package/.claude/skills/deploy/deploy.md +735 -0
  42. package/.claude/skills/incremental-implementation/SKILL.md +210 -0
  43. package/.claude/skills/security-review/SKILL.md +71 -0
  44. package/.claude/skills/tdd/SKILL.md +217 -0
  45. package/.cursor/CURSOR.md +112 -0
  46. package/.cursor/agents/backend.md +395 -0
  47. package/.cursor/agents/code-reviewer.md +110 -0
  48. package/.cursor/agents/copywriter-seo.md +236 -0
  49. package/.cursor/agents/frontend.md +384 -0
  50. package/.cursor/agents/project-manager.md +201 -0
  51. package/.cursor/agents/qa.md +221 -0
  52. package/.cursor/agents/security-auditor.md +143 -0
  53. package/.cursor/agents/systems-architect.md +211 -0
  54. package/.cursor/agents/test-engineer.md +123 -0
  55. package/.cursor/agents/ui-ux-designer.md +210 -0
  56. package/.cursor/commands/build.md +132 -0
  57. package/.cursor/commands/debug.md +242 -0
  58. package/.cursor/commands/deploy.md +40 -0
  59. package/.cursor/commands/fix-issue.md +42 -0
  60. package/.cursor/commands/plan.md +125 -0
  61. package/.cursor/commands/review.md +50 -0
  62. package/.cursor/commands/simplify.md +222 -0
  63. package/.cursor/commands/spec.md +95 -0
  64. package/.cursor/commands/test.md +214 -0
  65. package/.cursor/references/accessibility-checklist.md +174 -0
  66. package/.cursor/references/performance-checklist.md +150 -0
  67. package/.cursor/references/security-checklist.md +94 -0
  68. package/.cursor/references/testing-patterns.md +183 -0
  69. package/.cursor/rules/api-conventions.mdc +85 -0
  70. package/.cursor/rules/clean-code.mdc +211 -0
  71. package/.cursor/rules/code-style.mdc +92 -0
  72. package/.cursor/rules/cursor-overview.mdc +35 -0
  73. package/.cursor/rules/database.mdc +66 -0
  74. package/.cursor/rules/error-handling.mdc +98 -0
  75. package/.cursor/rules/git-workflow.mdc +83 -0
  76. package/.cursor/rules/monitoring.mdc +317 -0
  77. package/.cursor/rules/naming-conventions.mdc +266 -0
  78. package/.cursor/rules/project-structure.mdc +71 -0
  79. package/.cursor/rules/security.mdc +95 -0
  80. package/.cursor/rules/system-design.mdc +168 -0
  81. package/.cursor/rules/tech-stack.mdc +462 -0
  82. package/.cursor/rules/testing.mdc +110 -0
  83. package/.cursor/settings.json +8 -0
  84. package/.cursor/skills/code-review/SKILL.md +208 -0
  85. package/.cursor/skills/deploy/SKILL.md +68 -0
  86. package/.cursor/skills/deploy/deploy.md +735 -0
  87. package/.cursor/skills/incremental-implementation/SKILL.md +210 -0
  88. package/.cursor/skills/security-review/SKILL.md +71 -0
  89. package/.cursor/skills/tdd/SKILL.md +217 -0
  90. package/AGENTS.md +11 -0
  91. package/README.md +405 -0
  92. package/bin/class-ai-agent.cjs +176 -0
  93. package/package.json +38 -0
package/README.md ADDED
@@ -0,0 +1,405 @@
1
+ # AI Agent Project — Production-Grade Configuration
2
+
3
+ <div align="center">
4
+ <img src="https://res.cloudinary.com/ecommerce2021/image/upload/v1768626951/dev_efjbzw.jpg" alt="Code Web Khong Kho" width="120" style="border-radius: 50%"/>
5
+
6
+ <h3>Production-ready AI Agent configuration for Claude Code &amp; Cursor</h3>
7
+ <p>Structured workflows, specialized agents, mandatory rules, and best practices</p>
8
+
9
+ ![Version](https://img.shields.io/badge/version-1.2.0-blue?style=flat-square)
10
+ [![Facebook](https://img.shields.io/badge/Facebook-Code%20Web%20Khong%20Kho-1877F2?logo=facebook)](https://www.facebook.com/codewebkhongkho)
11
+ [![TikTok](https://img.shields.io/badge/TikTok-@code.web.khng.kh-000000?logo=tiktok)](https://www.tiktok.com/@code.web.khng.kh)
12
+ [![Website](https://img.shields.io/badge/Website-codewebkhongkho.com-FF6B35?logo=google-chrome)](https://codewebkhongkho.com/portfolios)
13
+
14
+ <sub>Inspired by <a href="https://github.com/addyosmani/agent-skills">addyosmani/agent-skills</a></sub>
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## Overview
20
+
21
+ This repository provides a **production-grade configuration** for AI-assisted development. It includes **two parallel layouts**:
22
+
23
+ | Layout | Tool | Purpose |
24
+ |--------|------|---------|
25
+ | **`.claude/`** | [Claude Code](https://code.claude.com/docs) | Slash commands, `CLAUDE.md`, rules as `.md` |
26
+ | **`.cursor/`** | [Cursor](https://cursor.com) | Same workflows; rules as **`.mdc`** (Cursor project rules); hub doc **`CURSOR.md`** |
27
+
28
+ Shared contents:
29
+
30
+ - **Structured development workflow** (Spec → Plan → Build → Test → Review → Ship)
31
+ - **10 specialized agents** for different development roles
32
+ - **13 mandatory topic rules** (same content in `.claude/rules/` and `.cursor/rules/`), plus **`cursor-overview.mdc`** in `.cursor/rules/` for Cursor workflow entry
33
+ - **9 workflow prompts** (slash-style command markdown files)
34
+ - **4 reference checklists** for security, testing, performance, and accessibility
35
+
36
+ Root **`AGENTS.md`** points agents at **`.cursor/CURSOR.md`** for Cursor-oriented entry.
37
+
38
+ The same files can be installed with **`npx`** (see [Quick Start](#quick-start)).
39
+
40
+ ---
41
+
42
+ ## Development Workflow
43
+
44
+ ```
45
+ ┌──────────────────────────────────────────────────────────────────┐
46
+ │ │
47
+ │ /spec → /plan → /build → /test → /review → /deploy │
48
+ │ │
49
+ │ Define Plan Build Verify Review Ship │
50
+ │ │
51
+ └──────────────────────────────────────────────────────────────────┘
52
+ ```
53
+
54
+ | Phase | Command | Description |
55
+ |-------|---------|-------------|
56
+ | **Define** | `/spec` | Create PRD with objectives, scope, and boundaries |
57
+ | **Plan** | `/plan` | Decompose into vertical slices with acceptance criteria |
58
+ | **Build** | `/build` | Implement incrementally using TDD |
59
+ | **Verify** | `/test` | Write tests with RED-GREEN-REFACTOR |
60
+ | **Review** | `/review` | Five-axis code review |
61
+ | **Ship** | `/deploy` | Build, test, and deploy |
62
+
63
+ ### Supporting Commands
64
+
65
+ | Command | Description |
66
+ |---------|-------------|
67
+ | `/debug` | Systematic error diagnosis |
68
+ | `/simplify` | Reduce code complexity |
69
+ | `/fix-issue` | Analyze and fix issues |
70
+
71
+ ---
72
+
73
+ ## Project Structure
74
+
75
+ ### Claude Code — `.claude/`
76
+
77
+ ```
78
+ .claude/
79
+ ├── CLAUDE.md # Main AI configuration
80
+
81
+ ├── commands/ # Workflow prompts (9 files)
82
+ │ ├── spec.md # /spec — PRD creation
83
+ │ ├── plan.md # /plan — Task breakdown
84
+ │ ├── build.md # /build — Incremental implementation
85
+ │ ├── test.md # /test — TDD workflow
86
+ │ ├── review.md # /review — Code review
87
+ │ ├── deploy.md # /deploy — Deployment
88
+ │ ├── debug.md # /debug — Error diagnosis
89
+ │ ├── simplify.md # /simplify — Code simplification
90
+ │ └── fix-issue.md # /fix-issue — Issue resolution
91
+
92
+ ├── agents/ # Specialized agents (10 total)
93
+ │ ├── frontend.md # Frontend Developer
94
+ │ ├── backend.md # Backend Developer
95
+ │ ├── systems-architect.md # Systems Architect
96
+ │ ├── code-reviewer.md # Code Reviewer
97
+ │ ├── test-engineer.md # Test Engineer
98
+ │ ├── security-auditor.md # Security Auditor
99
+ │ ├── qa.md # QA Engineer
100
+ │ ├── project-manager.md # Project Manager
101
+ │ ├── ui-ux-designer.md # UI/UX Designer
102
+ │ └── copywriter-seo.md # Copywriter/SEO
103
+
104
+ ├── rules/ # Mandatory rules (13 total)
105
+ │ ├── clean-code.md # Clean Code principles
106
+ │ ├── code-style.md # Formatting & naming
107
+ │ ├── error-handling.md # Error patterns
108
+ │ ├── tech-stack.md # Approved technologies
109
+ │ ├── system-design.md # System design patterns
110
+ │ ├── project-structure.md # Folder organization
111
+ │ ├── api-conventions.md # REST API standards
112
+ │ ├── naming-conventions.md # Naming patterns
113
+ │ ├── database.md # Database patterns
114
+ │ ├── security.md # Security requirements
115
+ │ ├── monitoring.md # Observability
116
+ │ ├── testing.md # Test standards
117
+ │ └── git-workflow.md # Git conventions
118
+
119
+ ├── skills/ # Advanced skills
120
+ │ ├── tdd/SKILL.md # Test-Driven Development
121
+ │ ├── code-review/SKILL.md # Five-axis review
122
+ │ ├── incremental-implementation/SKILL.md
123
+ │ ├── deploy/SKILL.md
124
+ │ └── security-review/SKILL.md
125
+
126
+ ├── references/ # Quick checklists
127
+ │ ├── security-checklist.md
128
+ │ ├── testing-patterns.md
129
+ │ ├── performance-checklist.md
130
+ │ └── accessibility-checklist.md
131
+
132
+ └── settings.json # Project settings (paths & dirs)
133
+ ```
134
+
135
+ ### Cursor — `.cursor/`
136
+
137
+ Mirrors `.claude/` for agents, commands, skills, and references. Differences:
138
+
139
+ | Item | Notes |
140
+ |------|--------|
141
+ | **`CURSOR.md`** | Hub doc (same workflow story as `CLAUDE.md`, Cursor-specific usage) |
142
+ | **`rules/*.mdc`** | Cursor project rules with YAML frontmatter; **`security.mdc`** is always applied; **`cursor-overview.mdc`** explains workflow and paths |
143
+ | **`settings.json`** | Directory map (parallel to `.claude/settings.json`) |
144
+ | **`AGENTS.md` (repo root)** | Short pointer to `.cursor/CURSOR.md` for Cursor |
145
+
146
+ ```
147
+ .cursor/
148
+ ├── CURSOR.md
149
+ ├── settings.json
150
+ ├── commands/ # Same 9 prompts — open or @-include in Chat/Composer
151
+ ├── agents/ # Same 10 personas — @-mention files when needed
152
+ ├── rules/ # 14 × .mdc (13 topics + cursor-overview)
153
+ ├── skills/
154
+ ├── references/
155
+ ```
156
+
157
+ Keep **`.claude/`** and **`.cursor/`** aligned when you change standards or workflows.
158
+
159
+ ---
160
+
161
+ ## Specialized Agents
162
+
163
+ ### Development Agents
164
+
165
+ | Agent | Role | Invoke When |
166
+ |-------|------|-------------|
167
+ | **Frontend Developer** | Next.js, React, TypeScript, UI | Components, pages, state |
168
+ | **Backend Developer** | Express, Prisma, Redis, BullMQ | APIs, services, jobs |
169
+ | **Systems Architect** | Architecture, ADRs, scaling | System design decisions |
170
+
171
+ ### Quality Agents
172
+
173
+ | Agent | Role | Invoke When |
174
+ |-------|------|-------------|
175
+ | **Code Reviewer** | Five-axis code review | PR reviews, quality checks |
176
+ | **Test Engineer** | TDD, coverage, test strategy | Writing and reviewing tests |
177
+ | **Security Auditor** | Vulnerability, threat modeling | Security reviews |
178
+ | **QA Engineer** | Test plans, E2E, bug reports | Quality assurance |
179
+
180
+ ### Product Agents
181
+
182
+ | Agent | Role | Invoke When |
183
+ |-------|------|-------------|
184
+ | **Project Manager** | Stories, sprints, planning | Project planning |
185
+ | **UI/UX Designer** | Design system, accessibility | UX decisions |
186
+ | **Copywriter/SEO** | Copy, meta tags, SEO | Content creation |
187
+
188
+ ---
189
+
190
+ ## Approved Tech Stack
191
+
192
+ | Layer | Technology |
193
+ |-------|-----------|
194
+ | **Frontend (SEO)** | Next.js 14 (App Router) |
195
+ | **Frontend (Admin)** | React + Vite |
196
+ | **Styling** | Tailwind CSS + shadcn/ui |
197
+ | **State** | Zustand + TanStack Query |
198
+ | **Backend** | Express.js + TypeScript |
199
+ | **ORM** | Prisma |
200
+ | **Database** | PostgreSQL |
201
+ | **Cache** | Redis (ioredis) |
202
+ | **Queue** | BullMQ (simple) / RabbitMQ (enterprise) |
203
+ | **Auth** | NextAuth.js / JWT + bcrypt |
204
+ | **Testing** | Vitest + Playwright |
205
+ | **Monitoring** | Prometheus + Grafana + Pino |
206
+ | **CI/CD** | GitHub Actions |
207
+ | **Deploy** | Vercel + Railway/Fly.io |
208
+
209
+ ---
210
+
211
+ ## Mandatory Rules
212
+
213
+ Follow the rules in **`.claude/rules/`** (Markdown) when using Claude Code, and **`.cursor/rules/`** (`.mdc`) when using Cursor. Content matches; Cursor loads `.mdc` frontmatter automatically.
214
+
215
+ ### Code Quality
216
+ - **clean-code.md** — Variables, functions, SOLID, async/await
217
+ - **code-style.md** — 2-space indent, single quotes, semicolons
218
+ - **error-handling.md** — AppError class, centralized handler
219
+
220
+ ### Architecture
221
+ - **tech-stack.md** — Approved technologies only
222
+ - **system-design.md** — CAP, caching, scaling patterns
223
+ - **project-structure.md** — Layered architecture
224
+ - **api-conventions.md** — REST standards, response envelopes
225
+
226
+ ### Data & Naming
227
+ - **naming-conventions.md** — Cache keys, DB, queues, env vars
228
+ - **database.md** — Prisma patterns, N+1 prevention
229
+
230
+ ### Operations
231
+ - **security.md** — **CRITICAL** — Never violate
232
+ - **monitoring.md** — Prometheus, Grafana, alerting
233
+ - **testing.md** — 80% coverage minimum
234
+ - **git-workflow.md** — Conventional commits
235
+
236
+ ---
237
+
238
+ ## Quick Start
239
+
240
+ ### Install with `npx` (recommended)
241
+
242
+ Requires [Node.js](https://nodejs.org/) **16.7+**. After you publish this repository to the npm registry (`npm publish`; package name **`class-ai-agent`** in `package.json`):
243
+
244
+ ```bash
245
+ # Install into the current directory (.claude/, .cursor/, AGENTS.md)
246
+ npx class-ai-agent
247
+
248
+ # Install into another folder
249
+ npx class-ai-agent --dir /path/to/your/project
250
+
251
+ # Only Claude Code files
252
+ npx class-ai-agent --claude
253
+
254
+ # Only Cursor files + AGENTS.md
255
+ npx class-ai-agent --cursor
256
+
257
+ # Overwrite an existing install
258
+ npx class-ai-agent --force
259
+ ```
260
+
261
+ Run **`npx class-ai-agent --help`** for all options.
262
+
263
+ #### Publishing to npm (fix `E403` / 2FA)
264
+
265
+ If **`npm publish`** fails with **`403 Forbidden`** and a message about **two-factor authentication**, npm is blocking the upload until your account meets its publish policy:
266
+
267
+ 1. Sign in at [npmjs.com](https://www.npmjs.com/) → **Account** → enable **Two-Factor Authentication** (use **Auth and writes** so publishing is covered).
268
+ 2. In the terminal, refresh the session if needed: **`npm logout`** then **`npm login`**.
269
+ 3. Run **`npm publish --access public`** again and enter your **one-time password** when npm asks for it.
270
+
271
+ For **CI or tokens only**: create a [granular access token](https://docs.npmjs.com/about-access-tokens) with permission to publish this package, using type **Automation** (or a token that can bypass 2FA where npm allows it), set **`NPM_TOKEN`** in the environment, and use an **`.npmrc`** that references `${NPM_TOKEN}` per npm’s docs.
272
+
273
+ **From a git clone** (before publishing, or for development):
274
+
275
+ ```bash
276
+ cd class-ai-agent
277
+ npm exec -- class-ai-agent --dir /path/to/your/project
278
+ # or: node bin/class-ai-agent.cjs --dir /path/to/your/project
279
+ ```
280
+
281
+ ### Manual copy
282
+
283
+ ```bash
284
+ git clone https://github.com/khoantd/class-ai-agent.git
285
+ cd class-ai-agent
286
+
287
+ cp -r .claude/ /path/to/your/project/
288
+ cp -r .cursor/ /path/to/your/project/
289
+ cp AGENTS.md /path/to/your/project/
290
+ ```
291
+
292
+ ### Using workflow prompts (commands)
293
+
294
+ **Claude Code** — use slash commands in the CLI:
295
+
296
+ ```text
297
+ /spec "User authentication feature"
298
+ /plan
299
+ /build
300
+ /test
301
+ /review
302
+ /deploy
303
+ ```
304
+
305
+ **Cursor** — the same prompts live as markdown under **`.cursor/commands/`**. Open the file, copy the section you need, or **@ mention** it (e.g. `@.cursor/commands/spec.md`) in Chat or Composer.
306
+
307
+ ### Using Agents
308
+
309
+ Natural-language instructions still work. In **Cursor**, you can also **@ mention** an agent file (e.g. `@.cursor/agents/frontend.md`) to load that persona.
310
+
311
+ ```text
312
+ "Act as the Frontend Developer and build the login page"
313
+ "As Systems Architect, design the notification system"
314
+ "Code Reviewer: review this PR for security issues"
315
+ "Test Engineer: write tests for the payment flow"
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Key Concepts
321
+
322
+ ### Five-Axis Code Review
323
+
324
+ Every code review evaluates:
325
+
326
+ 1. **Correctness** — Does it work? Edge cases?
327
+ 2. **Readability** — Can others understand it?
328
+ 3. **Architecture** — Follows patterns? Appropriate abstractions?
329
+ 4. **Security** — Input validation? Auth? No secrets?
330
+ 5. **Performance** — N+1? Pagination? Async?
331
+
332
+ ### Test-Driven Development
333
+
334
+ ```
335
+ RED → Write failing test
336
+ GREEN → Write minimal code to pass
337
+ REFACTOR → Improve while green
338
+ ```
339
+
340
+ ### Vertical Slicing
341
+
342
+ Build features end-to-end, not layer-by-layer:
343
+
344
+ ```
345
+ ✅ Task 1: User can create task (DB + API + UI)
346
+ ✅ Task 2: User can view tasks (DB + API + UI)
347
+
348
+ ❌ Task 1: Create all DB models
349
+ ❌ Task 2: Create all API routes
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Security
355
+
356
+ **Never commit:**
357
+ - `.env` files
358
+ - API keys, secrets, passwords
359
+ - `.claude/settings.local.json` (and any local-only Cursor overrides if you add them)
360
+
361
+ **Always:**
362
+ - Use environment variables
363
+ - Validate all inputs
364
+ - Hash passwords (bcrypt >= 12 rounds)
365
+ - Parameterize queries
366
+
367
+ ---
368
+
369
+ ## Contributing
370
+
371
+ 1. Follow the development workflow (`/spec` → `/plan` → `/build`, or the same prompts under `.cursor/commands/`)
372
+ 2. Ensure all tests pass
373
+ 3. Run `/review` before submitting PR
374
+ 4. Follow conventional commit format
375
+ 5. When changing rules or workflows, update **both** `.claude/` and `.cursor/` so they stay aligned
376
+
377
+ ---
378
+
379
+ ## Credits
380
+
381
+ - Workflow inspired by [addyosmani/agent-skills](https://github.com/addyosmani/agent-skills)
382
+ - Best practices from *Software Engineering at Google*
383
+ - Clean Code principles from Robert C. Martin
384
+
385
+ ---
386
+
387
+ ## Author
388
+
389
+ <div align="center">
390
+ <img src="https://res.cloudinary.com/ecommerce2021/image/upload/v1768626951/dev_efjbzw.jpg" alt="Code Web Khong Kho" width="80" style="border-radius: 50%"/>
391
+
392
+ **Code Web Khong Kho**
393
+
394
+ | Platform | Link |
395
+ |----------|------|
396
+ | Facebook | [facebook.com/codewebkhongkho](https://www.facebook.com/codewebkhongkho) |
397
+ | TikTok | [@code.web.khng.kh](https://www.tiktok.com/@code.web.khng.kh) |
398
+ | Website | [codewebkhongkho.com](https://codewebkhongkho.com/portfolios) |
399
+ </div>
400
+
401
+ ---
402
+
403
+ <div align="center">
404
+ <sub>Made with care by <a href="https://www.facebook.com/codewebkhongkho">Code Web Khong Kho</a></sub>
405
+ </div>
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const PKG_ROOT = path.resolve(__dirname, '..');
8
+
9
+ function readPkg() {
10
+ const p = path.join(PKG_ROOT, 'package.json');
11
+ return JSON.parse(fs.readFileSync(p, 'utf8'));
12
+ }
13
+
14
+ function printHelp() {
15
+ console.log(`class-ai-agent — Install Claude Code & Cursor AI agent scaffolding
16
+
17
+ Usage:
18
+ npx class-ai-agent [init] [options]
19
+
20
+ Options:
21
+ -d, --dir <path> Target directory (default: current working directory)
22
+ --claude Install only .claude/
23
+ --cursor Install only .cursor/ and AGENTS.md
24
+ -f, --force Overwrite existing files or directories
25
+ -h, --help Show help
26
+ -v, --version Print version
27
+
28
+ Examples:
29
+ npx class-ai-agent
30
+ npx class-ai-agent --dir ./my-app
31
+ npx class-ai-agent --cursor --force
32
+ `);
33
+ }
34
+
35
+ function parseArgs(argv) {
36
+ const opts = {
37
+ command: 'init',
38
+ dir: process.cwd(),
39
+ claudeOnly: false,
40
+ cursorOnly: false,
41
+ force: false,
42
+ help: false,
43
+ version: false,
44
+ };
45
+
46
+ let i = 0;
47
+ if (argv[0] === 'init') {
48
+ i = 1;
49
+ }
50
+
51
+ for (; i < argv.length; i++) {
52
+ const a = argv[i];
53
+ if (a === '-h' || a === '--help') {
54
+ opts.help = true;
55
+ continue;
56
+ }
57
+ if (a === '-v' || a === '--version') {
58
+ opts.version = true;
59
+ continue;
60
+ }
61
+ if (a === '-f' || a === '--force') {
62
+ opts.force = true;
63
+ continue;
64
+ }
65
+ if (a === '--claude') {
66
+ opts.claudeOnly = true;
67
+ continue;
68
+ }
69
+ if (a === '--cursor') {
70
+ opts.cursorOnly = true;
71
+ continue;
72
+ }
73
+ if (a === '-d' || a === '--dir') {
74
+ const v = argv[++i];
75
+ if (!v) {
76
+ console.error('Error: missing value for --dir');
77
+ process.exit(1);
78
+ }
79
+ opts.dir = path.resolve(v);
80
+ continue;
81
+ }
82
+ console.error(`Unknown argument: ${a}`);
83
+ process.exit(1);
84
+ }
85
+
86
+ return opts;
87
+ }
88
+
89
+ function ensureParentDir(filePath) {
90
+ const d = path.dirname(filePath);
91
+ fs.mkdirSync(d, { recursive: true });
92
+ }
93
+
94
+ function copyDir(src, dest, { force }) {
95
+ if (!fs.existsSync(src)) {
96
+ console.error(`Error: template missing from package: ${src}`);
97
+ process.exit(1);
98
+ }
99
+ if (fs.existsSync(dest)) {
100
+ if (!force) {
101
+ console.error(`Error: already exists (use --force to overwrite): ${dest}`);
102
+ process.exit(1);
103
+ }
104
+ fs.rmSync(dest, { recursive: true, force: true });
105
+ }
106
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
107
+ fs.cpSync(src, dest, { recursive: true });
108
+ }
109
+
110
+ function copyFile(src, dest, { force }) {
111
+ if (!fs.existsSync(src)) {
112
+ console.error(`Error: template missing from package: ${src}`);
113
+ process.exit(1);
114
+ }
115
+ if (fs.existsSync(dest) && !force) {
116
+ console.error(`Error: already exists (use --force to overwrite): ${dest}`);
117
+ process.exit(1);
118
+ }
119
+ ensureParentDir(dest);
120
+ fs.copyFileSync(src, dest);
121
+ }
122
+
123
+ function run(opts) {
124
+ const full =
125
+ (!opts.claudeOnly && !opts.cursorOnly) ||
126
+ (opts.claudeOnly && opts.cursorOnly);
127
+
128
+ const installClaude = full || (opts.claudeOnly && !opts.cursorOnly);
129
+ const installCursor = full || (opts.cursorOnly && !opts.claudeOnly);
130
+ const installAgents = full || opts.cursorOnly;
131
+
132
+ fs.mkdirSync(opts.dir, { recursive: true });
133
+
134
+ const copyOpts = { force: opts.force };
135
+
136
+ if (installClaude) {
137
+ const src = path.join(PKG_ROOT, '.claude');
138
+ const dest = path.join(opts.dir, '.claude');
139
+ copyDir(src, dest, copyOpts);
140
+ console.log(`Installed: ${dest}`);
141
+ }
142
+
143
+ if (installCursor) {
144
+ const src = path.join(PKG_ROOT, '.cursor');
145
+ const dest = path.join(opts.dir, '.cursor');
146
+ copyDir(src, dest, copyOpts);
147
+ console.log(`Installed: ${dest}`);
148
+ }
149
+
150
+ if (installAgents) {
151
+ const src = path.join(PKG_ROOT, 'AGENTS.md');
152
+ const dest = path.join(opts.dir, 'AGENTS.md');
153
+ copyFile(src, dest, copyOpts);
154
+ console.log(`Installed: ${dest}`);
155
+ }
156
+
157
+ const hints = [];
158
+ if (installClaude) hints.push('.claude/CLAUDE.md');
159
+ if (installCursor) hints.push('.cursor/CURSOR.md');
160
+ console.log(`\nDone. Next steps: read ${hints.join(' and ')}.`);
161
+ }
162
+
163
+ const argv = process.argv.slice(2);
164
+ const opts = parseArgs(argv);
165
+
166
+ if (opts.help) {
167
+ printHelp();
168
+ process.exit(0);
169
+ }
170
+
171
+ if (opts.version) {
172
+ console.log(readPkg().version);
173
+ process.exit(0);
174
+ }
175
+
176
+ run(opts);
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "class-ai-agent",
3
+ "version": "1.2.0",
4
+ "description": "Production-grade AI agent configuration for Claude Code & Cursor",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/khoantd/class-ai-agent.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/khoantd/class-ai-agent/issues"
12
+ },
13
+ "homepage": "https://github.com/khoantd/class-ai-agent#readme",
14
+ "keywords": [
15
+ "claude",
16
+ "claude-code",
17
+ "cursor",
18
+ "ai",
19
+ "agent",
20
+ "scaffold"
21
+ ],
22
+ "engines": {
23
+ "node": ">=16.7.0"
24
+ },
25
+ "bin": {
26
+ "class-ai-agent": "bin/class-ai-agent.cjs"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ ".claude",
31
+ ".cursor",
32
+ "AGENTS.md"
33
+ ],
34
+ "scripts": {
35
+ "prepack": "node -e \"const fs=require('fs');['.claude','.cursor','AGENTS.md'].forEach(p=>{if(!fs.existsSync(p))process.exit(1)})\"",
36
+ "test:cli": "node bin/class-ai-agent.cjs --help && node bin/class-ai-agent.cjs --version"
37
+ }
38
+ }