cp-toolkit 2.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 +130 -0
- package/bin/cp-kit.js +72 -0
- package/package.json +46 -0
- package/src/commands/add.js +212 -0
- package/src/commands/doctor.js +149 -0
- package/src/commands/init.js +662 -0
- package/src/commands/list.js +128 -0
- package/src/index.js +13 -0
- package/templates/agents/backend-specialist.md +263 -0
- package/templates/agents/code-archaeologist.md +106 -0
- package/templates/agents/database-architect.md +226 -0
- package/templates/agents/debugger.md +225 -0
- package/templates/agents/devops-engineer.md +242 -0
- package/templates/agents/documentation-writer.md +104 -0
- package/templates/agents/explorer-agent.md +73 -0
- package/templates/agents/frontend-specialist.md +556 -0
- package/templates/agents/game-developer.md +162 -0
- package/templates/agents/mobile-developer.md +377 -0
- package/templates/agents/orchestrator.md +416 -0
- package/templates/agents/penetration-tester.md +188 -0
- package/templates/agents/performance-optimizer.md +187 -0
- package/templates/agents/product-manager.md +112 -0
- package/templates/agents/product-owner.md +95 -0
- package/templates/agents/project-planner.md +406 -0
- package/templates/agents/qa-automation-engineer.md +103 -0
- package/templates/agents/security-auditor.md +170 -0
- package/templates/agents/seo-specialist.md +111 -0
- package/templates/agents/test-engineer.md +158 -0
- package/templates/github/agents/backend-specialist.md +67 -0
- package/templates/github/agents/code-archaeologist.md +61 -0
- package/templates/github/agents/database-architect.md +73 -0
- package/templates/github/agents/debugger.md +71 -0
- package/templates/github/agents/devops-engineer.md +85 -0
- package/templates/github/agents/documentation-writer.md +107 -0
- package/templates/github/agents/explorer-agent.md +87 -0
- package/templates/github/agents/frontend-specialist.md +54 -0
- package/templates/github/agents/game-developer.md +94 -0
- package/templates/github/agents/mobile-developer.md +75 -0
- package/templates/github/agents/orchestrator.md +48 -0
- package/templates/github/agents/penetration-tester.md +87 -0
- package/templates/github/agents/performance-optimizer.md +70 -0
- package/templates/github/agents/product-manager.md +85 -0
- package/templates/github/agents/product-owner.md +77 -0
- package/templates/github/agents/project-planner.md +83 -0
- package/templates/github/agents/qa-automation-engineer.md +95 -0
- package/templates/github/agents/security-auditor.md +72 -0
- package/templates/github/agents/seo-specialist.md +78 -0
- package/templates/github/agents/test-engineer.md +79 -0
- package/templates/github/instructions/database.instructions.md +74 -0
- package/templates/github/instructions/python.instructions.md +76 -0
- package/templates/github/instructions/security.instructions.md +73 -0
- package/templates/github/instructions/typescript.instructions.md +50 -0
- package/templates/rules/GEMINI.md +273 -0
- package/templates/scripts/mcp-server.js +704 -0
- package/templates/skills/core/behavioral-modes/SKILL.md +242 -0
- package/templates/skills/core/brainstorming/SKILL.md +163 -0
- package/templates/skills/core/brainstorming/dynamic-questioning.md +350 -0
- package/templates/skills/core/clean-code/SKILL.md +201 -0
- package/templates/skills/core/intelligent-routing/SKILL.md +335 -0
- package/templates/skills/core/mcp-builder/SKILL.md +176 -0
- package/templates/skills/core/parallel-agents/SKILL.md +175 -0
- package/templates/skills/core/plan-writing/SKILL.md +152 -0
- package/templates/skills/optional/api-patterns/SKILL.md +81 -0
- package/templates/skills/optional/api-patterns/api-style.md +42 -0
- package/templates/skills/optional/api-patterns/auth.md +24 -0
- package/templates/skills/optional/api-patterns/documentation.md +26 -0
- package/templates/skills/optional/api-patterns/graphql.md +41 -0
- package/templates/skills/optional/api-patterns/rate-limiting.md +31 -0
- package/templates/skills/optional/api-patterns/response.md +37 -0
- package/templates/skills/optional/api-patterns/rest.md +40 -0
- package/templates/skills/optional/api-patterns/scripts/api_validator.py +211 -0
- package/templates/skills/optional/api-patterns/security-testing.md +122 -0
- package/templates/skills/optional/api-patterns/trpc.md +41 -0
- package/templates/skills/optional/api-patterns/versioning.md +22 -0
- package/templates/skills/optional/app-builder/SKILL.md +75 -0
- package/templates/skills/optional/app-builder/agent-coordination.md +71 -0
- package/templates/skills/optional/app-builder/feature-building.md +53 -0
- package/templates/skills/optional/app-builder/project-detection.md +34 -0
- package/templates/skills/optional/app-builder/scaffolding.md +118 -0
- package/templates/skills/optional/app-builder/tech-stack.md +40 -0
- package/templates/skills/optional/app-builder/templates/SKILL.md +39 -0
- package/templates/skills/optional/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/templates/skills/optional/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/templates/skills/optional/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/templates/skills/optional/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/templates/skills/optional/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/templates/skills/optional/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/templates/skills/optional/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/templates/skills/optional/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/templates/skills/optional/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/templates/skills/optional/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/templates/skills/optional/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/templates/skills/optional/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/templates/skills/optional/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/templates/skills/optional/architecture/SKILL.md +55 -0
- package/templates/skills/optional/architecture/context-discovery.md +43 -0
- package/templates/skills/optional/architecture/examples.md +94 -0
- package/templates/skills/optional/architecture/pattern-selection.md +68 -0
- package/templates/skills/optional/architecture/patterns-reference.md +50 -0
- package/templates/skills/optional/architecture/trade-off-analysis.md +77 -0
- package/templates/skills/optional/bash-linux/SKILL.md +199 -0
- package/templates/skills/optional/code-review-checklist/SKILL.md +109 -0
- package/templates/skills/optional/database-design/SKILL.md +52 -0
- package/templates/skills/optional/database-design/database-selection.md +43 -0
- package/templates/skills/optional/database-design/indexing.md +39 -0
- package/templates/skills/optional/database-design/migrations.md +48 -0
- package/templates/skills/optional/database-design/optimization.md +36 -0
- package/templates/skills/optional/database-design/orm-selection.md +30 -0
- package/templates/skills/optional/database-design/schema-design.md +56 -0
- package/templates/skills/optional/database-design/scripts/schema_validator.py +172 -0
- package/templates/skills/optional/deployment-procedures/SKILL.md +241 -0
- package/templates/skills/optional/documentation-templates/SKILL.md +194 -0
- package/templates/skills/optional/frontend-design/SKILL.md +418 -0
- package/templates/skills/optional/frontend-design/animation-guide.md +331 -0
- package/templates/skills/optional/frontend-design/color-system.md +311 -0
- package/templates/skills/optional/frontend-design/decision-trees.md +418 -0
- package/templates/skills/optional/frontend-design/motion-graphics.md +306 -0
- package/templates/skills/optional/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/skills/optional/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/skills/optional/frontend-design/typography-system.md +345 -0
- package/templates/skills/optional/frontend-design/ux-psychology.md +541 -0
- package/templates/skills/optional/frontend-design/visual-effects.md +383 -0
- package/templates/skills/optional/game-development/2d-games/SKILL.md +119 -0
- package/templates/skills/optional/game-development/3d-games/SKILL.md +135 -0
- package/templates/skills/optional/game-development/SKILL.md +167 -0
- package/templates/skills/optional/game-development/game-art/SKILL.md +185 -0
- package/templates/skills/optional/game-development/game-audio/SKILL.md +190 -0
- package/templates/skills/optional/game-development/game-design/SKILL.md +129 -0
- package/templates/skills/optional/game-development/mobile-games/SKILL.md +108 -0
- package/templates/skills/optional/game-development/multiplayer/SKILL.md +132 -0
- package/templates/skills/optional/game-development/pc-games/SKILL.md +144 -0
- package/templates/skills/optional/game-development/vr-ar/SKILL.md +123 -0
- package/templates/skills/optional/game-development/web-games/SKILL.md +150 -0
- package/templates/skills/optional/geo-fundamentals/SKILL.md +156 -0
- package/templates/skills/optional/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/skills/optional/i18n-localization/SKILL.md +154 -0
- package/templates/skills/optional/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/skills/optional/lint-and-validate/SKILL.md +45 -0
- package/templates/skills/optional/lint-and-validate/scripts/lint_runner.py +172 -0
- package/templates/skills/optional/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/skills/optional/mobile-design/SKILL.md +394 -0
- package/templates/skills/optional/mobile-design/decision-trees.md +516 -0
- package/templates/skills/optional/mobile-design/mobile-backend.md +491 -0
- package/templates/skills/optional/mobile-design/mobile-color-system.md +420 -0
- package/templates/skills/optional/mobile-design/mobile-debugging.md +122 -0
- package/templates/skills/optional/mobile-design/mobile-design-thinking.md +357 -0
- package/templates/skills/optional/mobile-design/mobile-navigation.md +458 -0
- package/templates/skills/optional/mobile-design/mobile-performance.md +767 -0
- package/templates/skills/optional/mobile-design/mobile-testing.md +356 -0
- package/templates/skills/optional/mobile-design/mobile-typography.md +433 -0
- package/templates/skills/optional/mobile-design/platform-android.md +666 -0
- package/templates/skills/optional/mobile-design/platform-ios.md +561 -0
- package/templates/skills/optional/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/skills/optional/mobile-design/touch-psychology.md +537 -0
- package/templates/skills/optional/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/templates/skills/optional/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/templates/skills/optional/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/templates/skills/optional/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/templates/skills/optional/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/templates/skills/optional/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/templates/skills/optional/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/templates/skills/optional/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/templates/skills/optional/nextjs-react-expert/SKILL.md +267 -0
- package/templates/skills/optional/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/templates/skills/optional/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/templates/skills/optional/nodejs-best-practices/SKILL.md +333 -0
- package/templates/skills/optional/performance-profiling/SKILL.md +143 -0
- package/templates/skills/optional/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/skills/optional/powershell-windows/SKILL.md +167 -0
- package/templates/skills/optional/python-patterns/SKILL.md +441 -0
- package/templates/skills/optional/red-team-tactics/SKILL.md +199 -0
- package/templates/skills/optional/seo-fundamentals/SKILL.md +129 -0
- package/templates/skills/optional/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/skills/optional/server-management/SKILL.md +161 -0
- package/templates/skills/optional/systematic-debugging/SKILL.md +109 -0
- package/templates/skills/optional/tailwind-patterns/SKILL.md +269 -0
- package/templates/skills/optional/tdd-workflow/SKILL.md +149 -0
- package/templates/skills/optional/testing-patterns/SKILL.md +178 -0
- package/templates/skills/optional/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/skills/optional/vulnerability-scanner/SKILL.md +276 -0
- package/templates/skills/optional/vulnerability-scanner/checklists.md +121 -0
- package/templates/skills/optional/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/skills/optional/web-design-guidelines/SKILL.md +57 -0
- package/templates/skills/optional/webapp-testing/SKILL.md +187 -0
- package/templates/skills/optional/webapp-testing/scripts/playwright_runner.py +173 -0
- package/templates/workflows/brainstorm.md +113 -0
- package/templates/workflows/create.md +59 -0
- package/templates/workflows/debug.md +103 -0
- package/templates/workflows/deploy.md +176 -0
- package/templates/workflows/enhance.md +63 -0
- package/templates/workflows/orchestrate.md +237 -0
- package/templates/workflows/plan.md +89 -0
- package/templates/workflows/preview.md +81 -0
- package/templates/workflows/status.md +86 -0
- package/templates/workflows/test.md +144 -0
- package/templates/workflows/ui-ux-pro-max.md +296 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Pattern Selection Guidelines
|
|
2
|
+
|
|
3
|
+
> Decision trees for choosing architectural patterns.
|
|
4
|
+
|
|
5
|
+
## Main Decision Tree
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
START: What's your MAIN concern?
|
|
9
|
+
|
|
10
|
+
┌─ Data Access Complexity?
|
|
11
|
+
│ ├─ HIGH (complex queries, testing needed)
|
|
12
|
+
│ │ → Repository Pattern + Unit of Work
|
|
13
|
+
│ │ VALIDATE: Will data source change frequently?
|
|
14
|
+
│ │ ├─ YES → Repository worth the indirection
|
|
15
|
+
│ │ └─ NO → Consider simpler ORM direct access
|
|
16
|
+
│ └─ LOW (simple CRUD, single database)
|
|
17
|
+
│ → ORM directly (Prisma, Drizzle)
|
|
18
|
+
│ Simpler = Better, Faster
|
|
19
|
+
│
|
|
20
|
+
├─ Business Rules Complexity?
|
|
21
|
+
│ ├─ HIGH (domain logic, rules vary by context)
|
|
22
|
+
│ │ → Domain-Driven Design
|
|
23
|
+
│ │ VALIDATE: Do you have domain experts on team?
|
|
24
|
+
│ │ ├─ YES → Full DDD (Aggregates, Value Objects)
|
|
25
|
+
│ │ └─ NO → Partial DDD (rich entities, clear boundaries)
|
|
26
|
+
│ └─ LOW (mostly CRUD, simple validation)
|
|
27
|
+
│ → Transaction Script pattern
|
|
28
|
+
│ Simpler = Better, Faster
|
|
29
|
+
│
|
|
30
|
+
├─ Independent Scaling Needed?
|
|
31
|
+
│ ├─ YES (different components scale differently)
|
|
32
|
+
│ │ → Microservices WORTH the complexity
|
|
33
|
+
│ │ REQUIREMENTS (ALL must be true):
|
|
34
|
+
│ │ - Clear domain boundaries
|
|
35
|
+
│ │ - Team > 10 developers
|
|
36
|
+
│ │ - Different scaling needs per service
|
|
37
|
+
│ │ IF NOT ALL MET → Modular Monolith instead
|
|
38
|
+
│ └─ NO (everything scales together)
|
|
39
|
+
│ → Modular Monolith
|
|
40
|
+
│ Can extract services later when proven needed
|
|
41
|
+
│
|
|
42
|
+
└─ Real-time Requirements?
|
|
43
|
+
├─ HIGH (immediate updates, multi-user sync)
|
|
44
|
+
│ → Event-Driven Architecture
|
|
45
|
+
│ → Message Queue (RabbitMQ, Redis, Kafka)
|
|
46
|
+
│ VALIDATE: Can you handle eventual consistency?
|
|
47
|
+
│ ├─ YES → Event-driven valid
|
|
48
|
+
│ └─ NO → Synchronous with polling
|
|
49
|
+
└─ LOW (eventual consistency acceptable)
|
|
50
|
+
→ Synchronous (REST/GraphQL)
|
|
51
|
+
Simpler = Better, Faster
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## The 3 Questions (Before ANY Pattern)
|
|
55
|
+
|
|
56
|
+
1. **Problem Solved**: What SPECIFIC problem does this pattern solve?
|
|
57
|
+
2. **Simpler Alternative**: Is there a simpler solution?
|
|
58
|
+
3. **Deferred Complexity**: Can we add this LATER when needed?
|
|
59
|
+
|
|
60
|
+
## Red Flags (Anti-patterns)
|
|
61
|
+
|
|
62
|
+
| Pattern | Anti-pattern | Simpler Alternative |
|
|
63
|
+
|---------|-------------|-------------------|
|
|
64
|
+
| Microservices | Premature splitting | Start monolith, extract later |
|
|
65
|
+
| Clean/Hexagonal | Over-abstraction | Concrete first, interfaces later |
|
|
66
|
+
| Event Sourcing | Over-engineering | Append-only audit log |
|
|
67
|
+
| CQRS | Unnecessary complexity | Single model |
|
|
68
|
+
| Repository | YAGNI for simple CRUD | ORM direct access |
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Architecture Patterns Reference
|
|
2
|
+
|
|
3
|
+
> Quick reference for common patterns with usage guidance.
|
|
4
|
+
|
|
5
|
+
## Data Access Patterns
|
|
6
|
+
|
|
7
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
8
|
+
|---------|-------------|-----------------|------------|
|
|
9
|
+
| **Active Record** | Simple CRUD, rapid prototyping | Complex queries, multiple sources | Low |
|
|
10
|
+
| **Repository** | Testing needed, multiple sources | Simple CRUD, single database | Medium |
|
|
11
|
+
| **Unit of Work** | Complex transactions | Simple operations | High |
|
|
12
|
+
| **Data Mapper** | Complex domain, performance | Simple CRUD, rapid dev | High |
|
|
13
|
+
|
|
14
|
+
## Domain Logic Patterns
|
|
15
|
+
|
|
16
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
17
|
+
|---------|-------------|-----------------|------------|
|
|
18
|
+
| **Transaction Script** | Simple CRUD, procedural | Complex business rules | Low |
|
|
19
|
+
| **Table Module** | Record-based logic | Rich behavior needed | Low |
|
|
20
|
+
| **Domain Model** | Complex business logic | Simple CRUD | Medium |
|
|
21
|
+
| **DDD (Full)** | Complex domain, domain experts | Simple domain, no experts | High |
|
|
22
|
+
|
|
23
|
+
## Distributed System Patterns
|
|
24
|
+
|
|
25
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
26
|
+
|---------|-------------|-----------------|------------|
|
|
27
|
+
| **Modular Monolith** | Small teams, unclear boundaries | Clear contexts, different scales | Medium |
|
|
28
|
+
| **Microservices** | Different scales, large teams | Small teams, simple domain | Very High |
|
|
29
|
+
| **Event-Driven** | Real-time, loose coupling | Simple workflows, strong consistency | High |
|
|
30
|
+
| **CQRS** | Read/write performance diverges | Simple CRUD, same model | High |
|
|
31
|
+
| **Saga** | Distributed transactions | Single database, simple ACID | High |
|
|
32
|
+
|
|
33
|
+
## API Patterns
|
|
34
|
+
|
|
35
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
36
|
+
|---------|-------------|-----------------|------------|
|
|
37
|
+
| **REST** | Standard CRUD, resources | Real-time, complex queries | Low |
|
|
38
|
+
| **GraphQL** | Flexible queries, multiple clients | Simple CRUD, caching needs | Medium |
|
|
39
|
+
| **gRPC** | Internal services, performance | Public APIs, browser clients | Medium |
|
|
40
|
+
| **WebSocket** | Real-time updates | Simple request/response | Medium |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Simplicity Principle
|
|
45
|
+
|
|
46
|
+
**"Start simple, add complexity only when proven necessary."**
|
|
47
|
+
|
|
48
|
+
- You can always add patterns later
|
|
49
|
+
- Removing complexity is MUCH harder than adding it
|
|
50
|
+
- When in doubt, choose simpler option
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Trade-off Analysis & ADR
|
|
2
|
+
|
|
3
|
+
> Document every architectural decision with trade-offs.
|
|
4
|
+
|
|
5
|
+
## Decision Framework
|
|
6
|
+
|
|
7
|
+
For EACH architectural component, document:
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
## Architecture Decision Record
|
|
11
|
+
|
|
12
|
+
### Context
|
|
13
|
+
- **Problem**: [What problem are we solving?]
|
|
14
|
+
- **Constraints**: [Team size, scale, timeline, budget]
|
|
15
|
+
|
|
16
|
+
### Options Considered
|
|
17
|
+
|
|
18
|
+
| Option | Pros | Cons | Complexity | When Valid |
|
|
19
|
+
|--------|------|------|------------|-----------|
|
|
20
|
+
| Option A | Benefit 1 | Cost 1 | Low | [Conditions] |
|
|
21
|
+
| Option B | Benefit 2 | Cost 2 | High | [Conditions] |
|
|
22
|
+
|
|
23
|
+
### Decision
|
|
24
|
+
**Chosen**: [Option B]
|
|
25
|
+
|
|
26
|
+
### Rationale
|
|
27
|
+
1. [Reason 1 - tied to constraints]
|
|
28
|
+
2. [Reason 2 - tied to requirements]
|
|
29
|
+
|
|
30
|
+
### Trade-offs Accepted
|
|
31
|
+
- [What we're giving up]
|
|
32
|
+
- [Why this is acceptable]
|
|
33
|
+
|
|
34
|
+
### Consequences
|
|
35
|
+
- **Positive**: [Benefits we gain]
|
|
36
|
+
- **Negative**: [Costs/risks we accept]
|
|
37
|
+
- **Mitigation**: [How we'll address negatives]
|
|
38
|
+
|
|
39
|
+
### Revisit Trigger
|
|
40
|
+
- [When to reconsider this decision]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## ADR Template
|
|
44
|
+
|
|
45
|
+
```markdown
|
|
46
|
+
# ADR-[XXX]: [Decision Title]
|
|
47
|
+
|
|
48
|
+
## Status
|
|
49
|
+
Proposed | Accepted | Deprecated | Superseded by [ADR-YYY]
|
|
50
|
+
|
|
51
|
+
## Context
|
|
52
|
+
[What problem? What constraints?]
|
|
53
|
+
|
|
54
|
+
## Decision
|
|
55
|
+
[What we chose - be specific]
|
|
56
|
+
|
|
57
|
+
## Rationale
|
|
58
|
+
[Why - tie to requirements and constraints]
|
|
59
|
+
|
|
60
|
+
## Trade-offs
|
|
61
|
+
[What we're giving up - be honest]
|
|
62
|
+
|
|
63
|
+
## Consequences
|
|
64
|
+
- **Positive**: [Benefits]
|
|
65
|
+
- **Negative**: [Costs]
|
|
66
|
+
- **Mitigation**: [How to address]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ADR Storage
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
docs/
|
|
73
|
+
└── architecture/
|
|
74
|
+
├── adr-001-use-nextjs.md
|
|
75
|
+
├── adr-002-postgresql-over-mongodb.md
|
|
76
|
+
└── adr-003-adopt-repository-pattern.md
|
|
77
|
+
```
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bash-linux
|
|
3
|
+
description: Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Bash Linux Patterns
|
|
8
|
+
|
|
9
|
+
> Essential patterns for Bash on Linux/macOS.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Operator Syntax
|
|
14
|
+
|
|
15
|
+
### Chaining Commands
|
|
16
|
+
|
|
17
|
+
| Operator | Meaning | Example |
|
|
18
|
+
|----------|---------|---------|
|
|
19
|
+
| `;` | Run sequentially | `cmd1; cmd2` |
|
|
20
|
+
| `&&` | Run if previous succeeded | `npm install && npm run dev` |
|
|
21
|
+
| `\|\|` | Run if previous failed | `npm test \|\| echo "Tests failed"` |
|
|
22
|
+
| `\|` | Pipe output | `ls \| grep ".js"` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. File Operations
|
|
27
|
+
|
|
28
|
+
### Essential Commands
|
|
29
|
+
|
|
30
|
+
| Task | Command |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| List all | `ls -la` |
|
|
33
|
+
| Find files | `find . -name "*.js" -type f` |
|
|
34
|
+
| File content | `cat file.txt` |
|
|
35
|
+
| First N lines | `head -n 20 file.txt` |
|
|
36
|
+
| Last N lines | `tail -n 20 file.txt` |
|
|
37
|
+
| Follow log | `tail -f log.txt` |
|
|
38
|
+
| Search in files | `grep -r "pattern" --include="*.js"` |
|
|
39
|
+
| File size | `du -sh *` |
|
|
40
|
+
| Disk usage | `df -h` |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 3. Process Management
|
|
45
|
+
|
|
46
|
+
| Task | Command |
|
|
47
|
+
|------|---------|
|
|
48
|
+
| List processes | `ps aux` |
|
|
49
|
+
| Find by name | `ps aux \| grep node` |
|
|
50
|
+
| Kill by PID | `kill -9 <PID>` |
|
|
51
|
+
| Find port user | `lsof -i :3000` |
|
|
52
|
+
| Kill port | `kill -9 $(lsof -t -i :3000)` |
|
|
53
|
+
| Background | `npm run dev &` |
|
|
54
|
+
| Jobs | `jobs -l` |
|
|
55
|
+
| Bring to front | `fg %1` |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 4. Text Processing
|
|
60
|
+
|
|
61
|
+
### Core Tools
|
|
62
|
+
|
|
63
|
+
| Tool | Purpose | Example |
|
|
64
|
+
|------|---------|---------|
|
|
65
|
+
| `grep` | Search | `grep -rn "TODO" src/` |
|
|
66
|
+
| `sed` | Replace | `sed -i 's/old/new/g' file.txt` |
|
|
67
|
+
| `awk` | Extract columns | `awk '{print $1}' file.txt` |
|
|
68
|
+
| `cut` | Cut fields | `cut -d',' -f1 data.csv` |
|
|
69
|
+
| `sort` | Sort lines | `sort -u file.txt` |
|
|
70
|
+
| `uniq` | Unique lines | `sort file.txt \| uniq -c` |
|
|
71
|
+
| `wc` | Count | `wc -l file.txt` |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 5. Environment Variables
|
|
76
|
+
|
|
77
|
+
| Task | Command |
|
|
78
|
+
|------|---------|
|
|
79
|
+
| View all | `env` or `printenv` |
|
|
80
|
+
| View one | `echo $PATH` |
|
|
81
|
+
| Set temporary | `export VAR="value"` |
|
|
82
|
+
| Set in script | `VAR="value" command` |
|
|
83
|
+
| Add to PATH | `export PATH="$PATH:/new/path"` |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 6. Network
|
|
88
|
+
|
|
89
|
+
| Task | Command |
|
|
90
|
+
|------|---------|
|
|
91
|
+
| Download | `curl -O https://example.com/file` |
|
|
92
|
+
| API request | `curl -X GET https://api.example.com` |
|
|
93
|
+
| POST JSON | `curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL` |
|
|
94
|
+
| Check port | `nc -zv localhost 3000` |
|
|
95
|
+
| Network info | `ifconfig` or `ip addr` |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 7. Script Template
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
#!/bin/bash
|
|
103
|
+
set -euo pipefail # Exit on error, undefined var, pipe fail
|
|
104
|
+
|
|
105
|
+
# Colors (optional)
|
|
106
|
+
RED='\033[0;31m'
|
|
107
|
+
GREEN='\033[0;32m'
|
|
108
|
+
NC='\033[0m'
|
|
109
|
+
|
|
110
|
+
# Script directory
|
|
111
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
112
|
+
|
|
113
|
+
# Functions
|
|
114
|
+
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
|
115
|
+
log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
|
|
116
|
+
|
|
117
|
+
# Main
|
|
118
|
+
main() {
|
|
119
|
+
log_info "Starting..."
|
|
120
|
+
# Your logic here
|
|
121
|
+
log_info "Done!"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
main "$@"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 8. Common Patterns
|
|
130
|
+
|
|
131
|
+
### Check if command exists
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
if command -v node &> /dev/null; then
|
|
135
|
+
echo "Node is installed"
|
|
136
|
+
fi
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Default variable value
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
NAME=${1:-"default_value"}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Read file line by line
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
while IFS= read -r line; do
|
|
149
|
+
echo "$line"
|
|
150
|
+
done < file.txt
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Loop over files
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
for file in *.js; do
|
|
157
|
+
echo "Processing $file"
|
|
158
|
+
done
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 9. Differences from PowerShell
|
|
164
|
+
|
|
165
|
+
| Task | PowerShell | Bash |
|
|
166
|
+
|------|------------|------|
|
|
167
|
+
| List files | `Get-ChildItem` | `ls -la` |
|
|
168
|
+
| Find files | `Get-ChildItem -Recurse` | `find . -type f` |
|
|
169
|
+
| Environment | `$env:VAR` | `$VAR` |
|
|
170
|
+
| String concat | `"$a$b"` | `"$a$b"` (same) |
|
|
171
|
+
| Null check | `if ($x)` | `if [ -n "$x" ]` |
|
|
172
|
+
| Pipeline | Object-based | Text-based |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 10. Error Handling
|
|
177
|
+
|
|
178
|
+
### Set options
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
set -e # Exit on error
|
|
182
|
+
set -u # Exit on undefined variable
|
|
183
|
+
set -o pipefail # Exit on pipe failure
|
|
184
|
+
set -x # Debug: print commands
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Trap for cleanup
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
cleanup() {
|
|
191
|
+
echo "Cleaning up..."
|
|
192
|
+
rm -f /tmp/tempfile
|
|
193
|
+
}
|
|
194
|
+
trap cleanup EXIT
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
> **Remember:** Bash is text-based. Use `&&` for success chains, `set -e` for safety, and quote your variables!
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-checklist
|
|
3
|
+
description: Code review guidelines covering code quality, security, and best practices.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Review Checklist
|
|
8
|
+
|
|
9
|
+
## Quick Review Checklist
|
|
10
|
+
|
|
11
|
+
### Correctness
|
|
12
|
+
- [ ] Code does what it's supposed to do
|
|
13
|
+
- [ ] Edge cases handled
|
|
14
|
+
- [ ] Error handling in place
|
|
15
|
+
- [ ] No obvious bugs
|
|
16
|
+
|
|
17
|
+
### Security
|
|
18
|
+
- [ ] Input validated and sanitized
|
|
19
|
+
- [ ] No SQL/NoSQL injection vulnerabilities
|
|
20
|
+
- [ ] No XSS or CSRF vulnerabilities
|
|
21
|
+
- [ ] No hardcoded secrets or sensitive credentials
|
|
22
|
+
- [ ] **AI-Specific:** Protection against Prompt Injection (if applicable)
|
|
23
|
+
- [ ] **AI-Specific:** Outputs are sanitized before being used in critical sinks
|
|
24
|
+
|
|
25
|
+
### Performance
|
|
26
|
+
- [ ] No N+1 queries
|
|
27
|
+
- [ ] No unnecessary loops
|
|
28
|
+
- [ ] Appropriate caching
|
|
29
|
+
- [ ] Bundle size impact considered
|
|
30
|
+
|
|
31
|
+
### Code Quality
|
|
32
|
+
- [ ] Clear naming
|
|
33
|
+
- [ ] DRY - no duplicate code
|
|
34
|
+
- [ ] SOLID principles followed
|
|
35
|
+
- [ ] Appropriate abstraction level
|
|
36
|
+
|
|
37
|
+
### Testing
|
|
38
|
+
- [ ] Unit tests for new code
|
|
39
|
+
- [ ] Edge cases tested
|
|
40
|
+
- [ ] Tests readable and maintainable
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
- [ ] Complex logic commented
|
|
44
|
+
- [ ] Public APIs documented
|
|
45
|
+
- [ ] README updated if needed
|
|
46
|
+
|
|
47
|
+
## AI & LLM Review Patterns (2025)
|
|
48
|
+
|
|
49
|
+
### Logic & Hallucinations
|
|
50
|
+
- [ ] **Chain of Thought:** Does the logic follow a verifiable path?
|
|
51
|
+
- [ ] **Edge Cases:** Did the AI account for empty states, timeouts, and partial failures?
|
|
52
|
+
- [ ] **External State:** Is the code making safe assumptions about file systems or networks?
|
|
53
|
+
|
|
54
|
+
### Prompt Engineering Review
|
|
55
|
+
```markdown
|
|
56
|
+
// ❌ Vague prompt in code
|
|
57
|
+
const response = await ai.generate(userInput);
|
|
58
|
+
|
|
59
|
+
// ✅ Structured & Safe prompt
|
|
60
|
+
const response = await ai.generate({
|
|
61
|
+
system: "You are a specialized parser...",
|
|
62
|
+
input: sanitize(userInput),
|
|
63
|
+
schema: ResponseSchema
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Anti-Patterns to Flag
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// ❌ Magic numbers
|
|
71
|
+
if (status === 3) { ... }
|
|
72
|
+
|
|
73
|
+
// ✅ Named constants
|
|
74
|
+
if (status === Status.ACTIVE) { ... }
|
|
75
|
+
|
|
76
|
+
// ❌ Deep nesting
|
|
77
|
+
if (a) { if (b) { if (c) { ... } } }
|
|
78
|
+
|
|
79
|
+
// ✅ Early returns
|
|
80
|
+
if (!a) return;
|
|
81
|
+
if (!b) return;
|
|
82
|
+
if (!c) return;
|
|
83
|
+
// do work
|
|
84
|
+
|
|
85
|
+
// ❌ Long functions (100+ lines)
|
|
86
|
+
// ✅ Small, focused functions
|
|
87
|
+
|
|
88
|
+
// ❌ any type
|
|
89
|
+
const data: any = ...
|
|
90
|
+
|
|
91
|
+
// ✅ Proper types
|
|
92
|
+
const data: UserData = ...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Review Comments Guide
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
// Blocking issues use 🔴
|
|
99
|
+
🔴 BLOCKING: SQL injection vulnerability here
|
|
100
|
+
|
|
101
|
+
// Important suggestions use 🟡
|
|
102
|
+
🟡 SUGGESTION: Consider using useMemo for performance
|
|
103
|
+
|
|
104
|
+
// Minor nits use 🟢
|
|
105
|
+
🟢 NIT: Prefer const over let for immutable variable
|
|
106
|
+
|
|
107
|
+
// Questions use ❓
|
|
108
|
+
❓ QUESTION: What happens if user is null here?
|
|
109
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database-design
|
|
3
|
+
description: Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Database Design
|
|
8
|
+
|
|
9
|
+
> **Learn to THINK, not copy SQL patterns.**
|
|
10
|
+
|
|
11
|
+
## 🎯 Selective Reading Rule
|
|
12
|
+
|
|
13
|
+
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
|
14
|
+
|
|
15
|
+
| File | Description | When to Read |
|
|
16
|
+
|------|-------------|--------------|
|
|
17
|
+
| `database-selection.md` | PostgreSQL vs Neon vs Turso vs SQLite | Choosing database |
|
|
18
|
+
| `orm-selection.md` | Drizzle vs Prisma vs Kysely | Choosing ORM |
|
|
19
|
+
| `schema-design.md` | Normalization, PKs, relationships | Designing schema |
|
|
20
|
+
| `indexing.md` | Index types, composite indexes | Performance tuning |
|
|
21
|
+
| `optimization.md` | N+1, EXPLAIN ANALYZE | Query optimization |
|
|
22
|
+
| `migrations.md` | Safe migrations, serverless DBs | Schema changes |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ⚠️ Core Principle
|
|
27
|
+
|
|
28
|
+
- ASK user for database preferences when unclear
|
|
29
|
+
- Choose database/ORM based on CONTEXT
|
|
30
|
+
- Don't default to PostgreSQL for everything
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Decision Checklist
|
|
35
|
+
|
|
36
|
+
Before designing schema:
|
|
37
|
+
|
|
38
|
+
- [ ] Asked user about database preference?
|
|
39
|
+
- [ ] Chosen database for THIS context?
|
|
40
|
+
- [ ] Considered deployment environment?
|
|
41
|
+
- [ ] Planned index strategy?
|
|
42
|
+
- [ ] Defined relationship types?
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Anti-Patterns
|
|
47
|
+
|
|
48
|
+
❌ Default to PostgreSQL for simple apps (SQLite may suffice)
|
|
49
|
+
❌ Skip indexing
|
|
50
|
+
❌ Use SELECT * in production
|
|
51
|
+
❌ Store JSON when structured data is better
|
|
52
|
+
❌ Ignore N+1 queries
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Database Selection (2025)
|
|
2
|
+
|
|
3
|
+
> Choose database based on context, not default.
|
|
4
|
+
|
|
5
|
+
## Decision Tree
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
What are your requirements?
|
|
9
|
+
│
|
|
10
|
+
├── Full relational features needed
|
|
11
|
+
│ ├── Self-hosted → PostgreSQL
|
|
12
|
+
│ └── Serverless → Neon, Supabase
|
|
13
|
+
│
|
|
14
|
+
├── Edge deployment / Ultra-low latency
|
|
15
|
+
│ └── Turso (edge SQLite)
|
|
16
|
+
│
|
|
17
|
+
├── AI / Vector search
|
|
18
|
+
│ └── PostgreSQL + pgvector
|
|
19
|
+
│
|
|
20
|
+
├── Simple / Embedded / Local
|
|
21
|
+
│ └── SQLite
|
|
22
|
+
│
|
|
23
|
+
└── Global distribution
|
|
24
|
+
└── PlanetScale, CockroachDB, Turso
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Comparison
|
|
28
|
+
|
|
29
|
+
| Database | Best For | Trade-offs |
|
|
30
|
+
|----------|----------|------------|
|
|
31
|
+
| **PostgreSQL** | Full features, complex queries | Needs hosting |
|
|
32
|
+
| **Neon** | Serverless PG, branching | PG complexity |
|
|
33
|
+
| **Turso** | Edge, low latency | SQLite limitations |
|
|
34
|
+
| **SQLite** | Simple, embedded, local | Single-writer |
|
|
35
|
+
| **PlanetScale** | MySQL, global scale | No foreign keys |
|
|
36
|
+
|
|
37
|
+
## Questions to Ask
|
|
38
|
+
|
|
39
|
+
1. What's the deployment environment?
|
|
40
|
+
2. How complex are the queries?
|
|
41
|
+
3. Is edge/serverless important?
|
|
42
|
+
4. Vector search needed?
|
|
43
|
+
5. Global distribution required?
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Indexing Principles
|
|
2
|
+
|
|
3
|
+
> When and how to create indexes effectively.
|
|
4
|
+
|
|
5
|
+
## When to Create Indexes
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Index these:
|
|
9
|
+
├── Columns in WHERE clauses
|
|
10
|
+
├── Columns in JOIN conditions
|
|
11
|
+
├── Columns in ORDER BY
|
|
12
|
+
├── Foreign key columns
|
|
13
|
+
└── Unique constraints
|
|
14
|
+
|
|
15
|
+
Don't over-index:
|
|
16
|
+
├── Write-heavy tables (slower inserts)
|
|
17
|
+
├── Low-cardinality columns
|
|
18
|
+
├── Columns rarely queried
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Index Type Selection
|
|
22
|
+
|
|
23
|
+
| Type | Use For |
|
|
24
|
+
|------|---------|
|
|
25
|
+
| **B-tree** | General purpose, equality & range |
|
|
26
|
+
| **Hash** | Equality only, faster |
|
|
27
|
+
| **GIN** | JSONB, arrays, full-text |
|
|
28
|
+
| **GiST** | Geometric, range types |
|
|
29
|
+
| **HNSW/IVFFlat** | Vector similarity (pgvector) |
|
|
30
|
+
|
|
31
|
+
## Composite Index Principles
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Order matters for composite indexes:
|
|
35
|
+
├── Equality columns first
|
|
36
|
+
├── Range columns last
|
|
37
|
+
├── Most selective first
|
|
38
|
+
└── Match query pattern
|
|
39
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Migration Principles
|
|
2
|
+
|
|
3
|
+
> Safe migration strategy for zero-downtime changes.
|
|
4
|
+
|
|
5
|
+
## Safe Migration Strategy
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
For zero-downtime changes:
|
|
9
|
+
│
|
|
10
|
+
├── Adding column
|
|
11
|
+
│ └── Add as nullable → backfill → add NOT NULL
|
|
12
|
+
│
|
|
13
|
+
├── Removing column
|
|
14
|
+
│ └── Stop using → deploy → remove column
|
|
15
|
+
│
|
|
16
|
+
├── Adding index
|
|
17
|
+
│ └── CREATE INDEX CONCURRENTLY (non-blocking)
|
|
18
|
+
│
|
|
19
|
+
└── Renaming column
|
|
20
|
+
└── Add new → migrate data → deploy → drop old
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Migration Philosophy
|
|
24
|
+
|
|
25
|
+
- Never make breaking changes in one step
|
|
26
|
+
- Test migrations on data copy first
|
|
27
|
+
- Have rollback plan
|
|
28
|
+
- Run in transaction when possible
|
|
29
|
+
|
|
30
|
+
## Serverless Databases
|
|
31
|
+
|
|
32
|
+
### Neon (Serverless PostgreSQL)
|
|
33
|
+
|
|
34
|
+
| Feature | Benefit |
|
|
35
|
+
|---------|---------|
|
|
36
|
+
| Scale to zero | Cost savings |
|
|
37
|
+
| Instant branching | Dev/preview |
|
|
38
|
+
| Full PostgreSQL | Compatibility |
|
|
39
|
+
| Autoscaling | Traffic handling |
|
|
40
|
+
|
|
41
|
+
### Turso (Edge SQLite)
|
|
42
|
+
|
|
43
|
+
| Feature | Benefit |
|
|
44
|
+
|---------|---------|
|
|
45
|
+
| Edge locations | Ultra-low latency |
|
|
46
|
+
| SQLite compatible | Simple |
|
|
47
|
+
| Generous free tier | Cost |
|
|
48
|
+
| Global distribution | Performance |
|