@aicgen/aicgen 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/architecture-reviewer.md +88 -0
- package/.claude/agents/guideline-checker.md +73 -0
- package/.claude/agents/security-auditor.md +108 -0
- package/.claude/guidelines/api-design.md +645 -0
- package/.claude/guidelines/architecture.md +2503 -0
- package/.claude/guidelines/best-practices.md +618 -0
- package/.claude/guidelines/code-style.md +304 -0
- package/.claude/guidelines/design-patterns.md +573 -0
- package/.claude/guidelines/devops.md +226 -0
- package/.claude/guidelines/error-handling.md +413 -0
- package/.claude/guidelines/language.md +782 -0
- package/.claude/guidelines/performance.md +706 -0
- package/.claude/guidelines/security.md +583 -0
- package/.claude/guidelines/testing.md +568 -0
- package/.claude/settings.json +98 -0
- package/.claude/settings.local.json +8 -0
- package/.env.example +23 -0
- package/.eslintrc.json +28 -0
- package/.github/workflows/release.yml +180 -0
- package/.github/workflows/test.yml +81 -0
- package/.gitmodules +3 -0
- package/.vs/ProjectSettings.json +3 -0
- package/.vs/VSWorkspaceState.json +16 -0
- package/.vs/aicgen.slnx/FileContentIndex/5f0ce2a3-fd68-4863-9e23-e428cf1794e3.vsidx +0 -0
- package/.vs/aicgen.slnx/v18/.wsuo +0 -0
- package/.vs/aicgen.slnx/v18/DocumentLayout.json +54 -0
- package/.vs/slnx.sqlite +0 -0
- package/AGENTS.md +121 -0
- package/CLAUDE.md +36 -0
- package/CONTRIBUTING.md +821 -0
- package/LICENSE +21 -0
- package/README.md +199 -0
- package/assets/icon.svg +34 -0
- package/assets/logo.svg +41 -0
- package/bun.lock +848 -0
- package/data/LICENSE +21 -0
- package/data/README.md +203 -0
- package/data/api/basics.md +292 -0
- package/data/api/index.md +8 -0
- package/data/api/pagination.md +142 -0
- package/data/api/rest.md +137 -0
- package/data/api/versioning.md +60 -0
- package/data/architecture/clean-architecture/index.md +7 -0
- package/data/architecture/clean-architecture/layers.md +111 -0
- package/data/architecture/ddd/index.md +8 -0
- package/data/architecture/ddd/strategic.md +89 -0
- package/data/architecture/ddd/tactical.md +132 -0
- package/data/architecture/event-driven/index.md +7 -0
- package/data/architecture/event-driven/messaging.md +242 -0
- package/data/architecture/event-driven/patterns.md +129 -0
- package/data/architecture/feature-toggles/index.md +7 -0
- package/data/architecture/feature-toggles/patterns.md +73 -0
- package/data/architecture/gui/index.md +7 -0
- package/data/architecture/gui/patterns.md +132 -0
- package/data/architecture/hexagonal/ports-adapters.md +132 -0
- package/data/architecture/index.md +12 -0
- package/data/architecture/layered/index.md +7 -0
- package/data/architecture/layered/layers.md +100 -0
- package/data/architecture/microservices/api-gateway.md +56 -0
- package/data/architecture/microservices/boundaries.md +80 -0
- package/data/architecture/microservices/communication.md +97 -0
- package/data/architecture/microservices/data.md +92 -0
- package/data/architecture/microservices/index.md +11 -0
- package/data/architecture/microservices/resilience.md +111 -0
- package/data/architecture/modular-monolith/boundaries.md +133 -0
- package/data/architecture/modular-monolith/structure.md +131 -0
- package/data/architecture/serverless/best-practices.md +322 -0
- package/data/architecture/serverless/index.md +7 -0
- package/data/architecture/serverless/patterns.md +80 -0
- package/data/architecture/solid/index.md +7 -0
- package/data/architecture/solid/principles.md +187 -0
- package/data/database/basics.md +365 -0
- package/data/database/design-patterns.md +68 -0
- package/data/database/index.md +8 -0
- package/data/database/indexing.md +136 -0
- package/data/database/nosql.md +223 -0
- package/data/database/schema.md +137 -0
- package/data/devops/ci-cd.md +66 -0
- package/data/devops/index.md +8 -0
- package/data/devops/observability.md +73 -0
- package/data/devops/practices.md +77 -0
- package/data/error-handling/basics.md +222 -0
- package/data/error-handling/index.md +7 -0
- package/data/error-handling/strategy.md +185 -0
- package/data/guideline-mappings.yml +1077 -0
- package/data/index.md +3 -0
- package/data/language/csharp/basics.md +210 -0
- package/data/language/csharp/testing.md +252 -0
- package/data/language/go/basics.md +158 -0
- package/data/language/go/testing.md +192 -0
- package/data/language/index.md +14 -0
- package/data/language/java/basics.md +184 -0
- package/data/language/java/testing.md +273 -0
- package/data/language/javascript/basics.md +217 -0
- package/data/language/javascript/testing.md +269 -0
- package/data/language/python/async.md +100 -0
- package/data/language/python/basics.md +100 -0
- package/data/language/python/index.md +10 -0
- package/data/language/python/testing.md +125 -0
- package/data/language/python/types.md +99 -0
- package/data/language/ruby/basics.md +227 -0
- package/data/language/ruby/testing.md +267 -0
- package/data/language/rust/basics.md +175 -0
- package/data/language/rust/testing.md +219 -0
- package/data/language/typescript/async.md +103 -0
- package/data/language/typescript/basics.md +87 -0
- package/data/language/typescript/config.md +95 -0
- package/data/language/typescript/error-handling.md +98 -0
- package/data/language/typescript/generics.md +85 -0
- package/data/language/typescript/index.md +14 -0
- package/data/language/typescript/interfaces-types.md +83 -0
- package/data/language/typescript/performance.md +103 -0
- package/data/language/typescript/testing.md +98 -0
- package/data/patterns/base-patterns.md +105 -0
- package/data/patterns/concurrency.md +87 -0
- package/data/patterns/data-access.md +83 -0
- package/data/patterns/distribution.md +86 -0
- package/data/patterns/domain-logic.md +81 -0
- package/data/patterns/gof.md +109 -0
- package/data/patterns/index.md +12 -0
- package/data/performance/async.md +148 -0
- package/data/performance/basics.md +324 -0
- package/data/performance/caching-strategies.md +68 -0
- package/data/performance/caching.md +152 -0
- package/data/performance/index.md +8 -0
- package/data/practices/code-review.md +52 -0
- package/data/practices/documentation.md +260 -0
- package/data/practices/index.md +11 -0
- package/data/practices/planning.md +142 -0
- package/data/practices/refactoring.md +91 -0
- package/data/practices/version-control.md +55 -0
- package/data/security/auth-jwt.md +159 -0
- package/data/security/headers.md +143 -0
- package/data/security/index.md +10 -0
- package/data/security/injection.md +119 -0
- package/data/security/secrets.md +148 -0
- package/data/style/index.md +8 -0
- package/data/style/naming.md +136 -0
- package/data/style/organization.md +162 -0
- package/data/templates/agents/architecture-reviewer.md +88 -0
- package/data/templates/agents/guideline-checker.md +73 -0
- package/data/templates/agents/security-auditor.md +108 -0
- package/data/templates/antigravity/rules/architecture.md.hbs +5 -0
- package/data/templates/antigravity/rules/code-style.md.hbs +5 -0
- package/data/templates/antigravity/rules/language.md.hbs +5 -0
- package/data/templates/antigravity/rules/performance.md.hbs +5 -0
- package/data/templates/antigravity/rules/security.md.hbs +5 -0
- package/data/templates/antigravity/rules/testing.md.hbs +5 -0
- package/data/templates/antigravity/workflows/add-documentation.md.hbs +23 -0
- package/data/templates/antigravity/workflows/generate-integration-tests.md.hbs +17 -0
- package/data/templates/antigravity/workflows/generate-unit-tests.md.hbs +20 -0
- package/data/templates/antigravity/workflows/performance-audit.md.hbs +24 -0
- package/data/templates/antigravity/workflows/refactor-extract-module.md.hbs +17 -0
- package/data/templates/antigravity/workflows/security-audit.md.hbs +20 -0
- package/data/templates/hooks/formatting.json +26 -0
- package/data/templates/hooks/security.json +35 -0
- package/data/templates/hooks/testing.json +17 -0
- package/data/testing/basics.md +151 -0
- package/data/testing/index.md +9 -0
- package/data/testing/integration.md +159 -0
- package/data/testing/unit-fundamentals.md +128 -0
- package/data/testing/unit-mocking.md +116 -0
- package/data/version.json +49 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +46 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/config/profiles.d.ts +4 -0
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/config/profiles.js +30 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +7 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58489 -0
- package/dist/index.js.map +1 -0
- package/dist/models/guideline.d.ts +15 -0
- package/dist/models/guideline.d.ts.map +1 -0
- package/dist/models/guideline.js +2 -0
- package/dist/models/guideline.js.map +1 -0
- package/dist/models/preference.d.ts +9 -0
- package/dist/models/preference.d.ts.map +1 -0
- package/dist/models/preference.js +2 -0
- package/dist/models/preference.js.map +1 -0
- package/dist/models/profile.d.ts +9 -0
- package/dist/models/profile.d.ts.map +1 -0
- package/dist/models/profile.js +2 -0
- package/dist/models/profile.js.map +1 -0
- package/dist/models/project.d.ts +13 -0
- package/dist/models/project.d.ts.map +1 -0
- package/dist/models/project.js +2 -0
- package/dist/models/project.js.map +1 -0
- package/dist/services/ai/anthropic.d.ts +7 -0
- package/dist/services/ai/anthropic.d.ts.map +1 -0
- package/dist/services/ai/anthropic.js +39 -0
- package/dist/services/ai/anthropic.js.map +1 -0
- package/dist/services/generator.d.ts +2 -0
- package/dist/services/generator.d.ts.map +1 -0
- package/dist/services/generator.js +4 -0
- package/dist/services/generator.js.map +1 -0
- package/dist/services/learner.d.ts +2 -0
- package/dist/services/learner.d.ts.map +1 -0
- package/dist/services/learner.js +4 -0
- package/dist/services/learner.js.map +1 -0
- package/dist/services/scanner.d.ts +3 -0
- package/dist/services/scanner.d.ts.map +1 -0
- package/dist/services/scanner.js +54 -0
- package/dist/services/scanner.js.map +1 -0
- package/dist/utils/errors.d.ts +15 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +27 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file.d.ts +7 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +32 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +6 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +17 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +14 -0
- package/dist/utils/path.js.map +1 -0
- package/docs/planning/memory-lane.md +83 -0
- package/package.json +64 -0
- package/packaging/linux/aicgen.spec +23 -0
- package/packaging/linux/control +9 -0
- package/packaging/macos/scripts/postinstall +12 -0
- package/packaging/windows/setup.nsi +92 -0
- package/planning/BRANDING-SUMMARY.md +194 -0
- package/planning/BRANDING.md +174 -0
- package/planning/BUILD.md +186 -0
- package/planning/CHUNK-IMPLEMENTATION-PLAN.md +87 -0
- package/planning/CHUNK-TAXONOMY.md +375 -0
- package/planning/CHUNKS-COMPLETE.md +382 -0
- package/planning/DESIGN.md +313 -0
- package/planning/DYNAMIC-GUIDELINES-DESIGN.md +265 -0
- package/planning/ENTERPRISE-UX-COMPLETE.md +281 -0
- package/planning/IMPLEMENTATION-PLAN.md +20 -0
- package/planning/PHASE1-COMPLETE.md +211 -0
- package/planning/PHASE2-COMPLETE.md +350 -0
- package/planning/PHASE3-COMPLETE.md +399 -0
- package/planning/PHASE4-COMPLETE.md +361 -0
- package/planning/PHASE4.5-CHUNKS.md +462 -0
- package/planning/STRUCTURE.md +170 -0
- package/scripts/add-categories.ts +87 -0
- package/scripts/build-binary.ts +46 -0
- package/scripts/embed-data.ts +105 -0
- package/scripts/generate-version.ts +150 -0
- package/scripts/test-decompress.ts +27 -0
- package/scripts/test-extract.ts +31 -0
- package/src/__tests__/services/assistant-file-writer.test.ts +400 -0
- package/src/__tests__/services/guideline-loader.test.ts +281 -0
- package/src/__tests__/services/tarball-extraction.test.ts +125 -0
- package/src/commands/add-guideline.ts +296 -0
- package/src/commands/clear.ts +61 -0
- package/src/commands/guideline-selector.ts +123 -0
- package/src/commands/init.ts +645 -0
- package/src/commands/quick-add.ts +586 -0
- package/src/commands/remove-guideline.ts +152 -0
- package/src/commands/stats.ts +49 -0
- package/src/commands/update.ts +240 -0
- package/src/config.ts +82 -0
- package/src/embedded-data.ts +1492 -0
- package/src/index.ts +67 -0
- package/src/models/profile.ts +24 -0
- package/src/models/project.ts +43 -0
- package/src/services/assistant-file-writer.ts +612 -0
- package/src/services/config-generator.ts +150 -0
- package/src/services/config-manager.ts +70 -0
- package/src/services/data-source.ts +248 -0
- package/src/services/first-run-init.ts +148 -0
- package/src/services/guideline-loader.ts +311 -0
- package/src/services/hook-generator.ts +178 -0
- package/src/services/subagent-generator.ts +310 -0
- package/src/utils/banner.ts +66 -0
- package/src/utils/errors.ts +27 -0
- package/src/utils/file.ts +67 -0
- package/src/utils/formatting.ts +172 -0
- package/src/utils/logger.ts +89 -0
- package/src/utils/path.ts +17 -0
- package/src/utils/wizard-state.ts +132 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Code Organization
|
|
2
|
+
|
|
3
|
+
## Function Length
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
// ❌ Function too long (>50 lines)
|
|
7
|
+
function processOrder(orderId: string) {
|
|
8
|
+
// 200 lines of validation, payment, inventory, shipping...
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// ✅ Extract into smaller, focused functions
|
|
12
|
+
function processOrder(orderId: string) {
|
|
13
|
+
const order = fetchOrder(orderId);
|
|
14
|
+
|
|
15
|
+
validateOrder(order);
|
|
16
|
+
reserveInventory(order.items);
|
|
17
|
+
processPayment(order);
|
|
18
|
+
scheduleShipping(order);
|
|
19
|
+
sendConfirmation(order.customer.email);
|
|
20
|
+
|
|
21
|
+
return order;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Nesting Depth
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// ❌ Too much nesting (>3 levels)
|
|
29
|
+
if (user) {
|
|
30
|
+
if (user.isActive) {
|
|
31
|
+
if (user.hasPermission('edit')) {
|
|
32
|
+
if (resource.isAvailable) {
|
|
33
|
+
// Deep nesting is hard to follow
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ✅ Guard clauses to reduce nesting
|
|
40
|
+
if (!user) return;
|
|
41
|
+
if (!user.isActive) return;
|
|
42
|
+
if (!user.hasPermission('edit')) return;
|
|
43
|
+
if (!resource.isAvailable) return;
|
|
44
|
+
|
|
45
|
+
// Clear logic at top level
|
|
46
|
+
|
|
47
|
+
// ✅ Extract complex conditions
|
|
48
|
+
function canEditResource(user: User, resource: Resource): boolean {
|
|
49
|
+
return user &&
|
|
50
|
+
user.isActive &&
|
|
51
|
+
user.hasPermission('edit') &&
|
|
52
|
+
resource.isAvailable;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (canEditResource(user, resource)) {
|
|
56
|
+
// Single level of nesting
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## File Length
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// ❌ God file (1000+ lines)
|
|
64
|
+
// user-service.ts with 50 methods handling users, auth, permissions...
|
|
65
|
+
|
|
66
|
+
// ✅ Split into focused modules (~200-300 lines each)
|
|
67
|
+
// user-service.ts - CRUD operations
|
|
68
|
+
// auth-service.ts - login, logout, tokens
|
|
69
|
+
// permission-service.ts - role checks
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## File Organization
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Consistent structure within files:
|
|
76
|
+
|
|
77
|
+
// 1. Imports (grouped and ordered)
|
|
78
|
+
import fs from 'fs'; // Standard library
|
|
79
|
+
import express from 'express'; // External dependencies
|
|
80
|
+
import { UserService } from './user'; // Internal modules
|
|
81
|
+
|
|
82
|
+
// 2. Constants and type definitions
|
|
83
|
+
const MAX_RETRIES = 3;
|
|
84
|
+
|
|
85
|
+
interface UserDTO {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 3. Helper functions (if needed)
|
|
91
|
+
function validateInput(input: unknown): boolean {
|
|
92
|
+
// ...
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 4. Main exports/classes
|
|
96
|
+
export class OrderService {
|
|
97
|
+
// ...
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 5. Module initialization (if applicable)
|
|
101
|
+
export default new OrderService();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Single Responsibility
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// ❌ Class doing too much
|
|
108
|
+
class UserManager {
|
|
109
|
+
createUser() {}
|
|
110
|
+
updateUser() {}
|
|
111
|
+
sendEmail() {}
|
|
112
|
+
hashPassword() {}
|
|
113
|
+
generateToken() {}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ✅ Split by responsibility
|
|
117
|
+
class UserRepository {
|
|
118
|
+
create(user: User) {}
|
|
119
|
+
update(id: string, data: Partial<User>) {}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class EmailService {
|
|
123
|
+
send(to: string, template: string) {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
class PasswordService {
|
|
127
|
+
hash(password: string): string {}
|
|
128
|
+
verify(password: string, hash: string): boolean {}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
class AuthService {
|
|
132
|
+
generateToken(userId: string): string {}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## DRY (Don't Repeat Yourself)
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// ❌ Duplicated logic
|
|
140
|
+
function processUserOrder(order: Order) {
|
|
141
|
+
const total = order.items.reduce((sum, i) => sum + i.price * i.quantity, 0);
|
|
142
|
+
const tax = total * 0.08;
|
|
143
|
+
return total + tax;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function processGuestOrder(order: Order) {
|
|
147
|
+
const total = order.items.reduce((sum, i) => sum + i.price * i.quantity, 0);
|
|
148
|
+
const tax = total * 0.08;
|
|
149
|
+
return total + tax;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ✅ Extract common logic
|
|
153
|
+
function calculateOrderTotal(items: Item[]): number {
|
|
154
|
+
const subtotal = items.reduce((sum, i) => sum + i.price * i.quantity, 0);
|
|
155
|
+
const tax = subtotal * 0.08;
|
|
156
|
+
return subtotal + tax;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function processUserOrder(order: Order) {
|
|
160
|
+
return calculateOrderTotal(order.items);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: "claude-sonnet-4-5"
|
|
3
|
+
description: "Reviews architectural decisions and patterns"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architecture Reviewer
|
|
7
|
+
|
|
8
|
+
You are an architecture review agent ensuring code changes align with the project's architectural principles and patterns.
|
|
9
|
+
|
|
10
|
+
## Your Responsibilities
|
|
11
|
+
|
|
12
|
+
### Architectural Compliance
|
|
13
|
+
- Verify changes follow established architecture pattern (layered, hexagonal, microservices, etc.)
|
|
14
|
+
- Check dependency directions are correct
|
|
15
|
+
- Ensure proper separation of concerns
|
|
16
|
+
- Validate module boundaries
|
|
17
|
+
|
|
18
|
+
### Design Patterns
|
|
19
|
+
- Identify appropriate use of design patterns
|
|
20
|
+
- Flag anti-patterns (God objects, tight coupling, etc.)
|
|
21
|
+
- Suggest pattern improvements when beneficial
|
|
22
|
+
- Verify SOLID principles adherence
|
|
23
|
+
|
|
24
|
+
### Technical Debt
|
|
25
|
+
- Identify potential technical debt introduced
|
|
26
|
+
- Flag shortcuts that may cause future issues
|
|
27
|
+
- Suggest refactoring opportunities
|
|
28
|
+
- Assess long-term maintainability impact
|
|
29
|
+
|
|
30
|
+
## Review Checklist
|
|
31
|
+
|
|
32
|
+
- [ ] Does this change respect the existing architecture?
|
|
33
|
+
- [ ] Are dependencies pointing in the correct direction?
|
|
34
|
+
- [ ] Is there proper separation between layers/modules?
|
|
35
|
+
- [ ] Are interfaces/contracts well-defined?
|
|
36
|
+
- [ ] Is the change introducing tight coupling?
|
|
37
|
+
- [ ] Could this be simplified using existing patterns?
|
|
38
|
+
- [ ] Does this create technical debt?
|
|
39
|
+
- [ ] Is this scalable and maintainable?
|
|
40
|
+
|
|
41
|
+
## Output Format
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
🏗️ Architecture Review
|
|
45
|
+
|
|
46
|
+
Files reviewed: X
|
|
47
|
+
Architecture: [Layered/Hexagonal/Microservices/etc.]
|
|
48
|
+
|
|
49
|
+
✅ Strengths:
|
|
50
|
+
- Proper dependency injection in ServiceFactory
|
|
51
|
+
- Clean interface boundaries in API layer
|
|
52
|
+
|
|
53
|
+
⚠️ Concerns:
|
|
54
|
+
|
|
55
|
+
1. Dependency Violation (Critical)
|
|
56
|
+
- File: src/ui/components/UserForm.tsx:23
|
|
57
|
+
- Issue: Direct database access from UI layer
|
|
58
|
+
- Impact: Violates layered architecture
|
|
59
|
+
- Solution: Access data through service layer
|
|
60
|
+
|
|
61
|
+
2. Tight Coupling (Important)
|
|
62
|
+
- File: src/services/email-service.ts:45
|
|
63
|
+
- Issue: Hard-coded dependency on specific SMTP library
|
|
64
|
+
- Impact: Difficult to swap email providers
|
|
65
|
+
- Solution: Use adapter pattern with EmailProvider interface
|
|
66
|
+
|
|
67
|
+
3. Potential Debt (Minor)
|
|
68
|
+
- File: src/utils/cache.ts:12
|
|
69
|
+
- Issue: In-memory cache without eviction strategy
|
|
70
|
+
- Impact: May cause memory issues at scale
|
|
71
|
+
- Solution: Implement LRU eviction or use Redis
|
|
72
|
+
|
|
73
|
+
📊 Summary:
|
|
74
|
+
- Critical issues: 1
|
|
75
|
+
- Important issues: 1
|
|
76
|
+
- Minor issues: 1
|
|
77
|
+
- Technical debt score: Medium
|
|
78
|
+
|
|
79
|
+
Recommendation: Address critical dependency violation before merging
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Guidelines
|
|
83
|
+
|
|
84
|
+
- Focus on architectural implications, not minor style issues
|
|
85
|
+
- Consider both immediate and long-term impacts
|
|
86
|
+
- Provide specific, actionable solutions
|
|
87
|
+
- Explain the "why" behind each concern
|
|
88
|
+
- Balance idealism with pragmatism
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: "claude-opus-4-5"
|
|
3
|
+
description: "Verifies code changes comply with project guidelines"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Guideline Compliance Checker
|
|
7
|
+
|
|
8
|
+
You are an automated code review agent that verifies code changes follow the project's established guidelines.
|
|
9
|
+
|
|
10
|
+
## Your Responsibilities
|
|
11
|
+
|
|
12
|
+
When code changes are made, automatically verify:
|
|
13
|
+
|
|
14
|
+
### Code Style Compliance
|
|
15
|
+
- Naming conventions match project standards
|
|
16
|
+
- File organization follows project structure
|
|
17
|
+
- No redundant or commented-out code
|
|
18
|
+
- Proper indentation and formatting
|
|
19
|
+
|
|
20
|
+
### TypeScript/JavaScript Standards
|
|
21
|
+
- TypeScript strict mode compliance
|
|
22
|
+
- No `any` types (use `unknown` with type guards)
|
|
23
|
+
- Proper interface/type definitions
|
|
24
|
+
- Async/await patterns used correctly
|
|
25
|
+
|
|
26
|
+
### Best Practices
|
|
27
|
+
- Functions under 50 lines
|
|
28
|
+
- Maximum 3 levels of nesting
|
|
29
|
+
- Complex conditionals extracted to named functions
|
|
30
|
+
- Error handling implemented properly
|
|
31
|
+
- No magic numbers (use named constants)
|
|
32
|
+
|
|
33
|
+
### Testing Requirements
|
|
34
|
+
- New functions have corresponding tests
|
|
35
|
+
- Test coverage maintained or improved
|
|
36
|
+
- Tests follow AAA pattern (Arrange, Act, Assert)
|
|
37
|
+
|
|
38
|
+
## Output Format
|
|
39
|
+
|
|
40
|
+
Report findings in this format:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
✅ Guideline Compliance Report
|
|
44
|
+
|
|
45
|
+
Files checked: X
|
|
46
|
+
|
|
47
|
+
⚠️ Issues Found:
|
|
48
|
+
|
|
49
|
+
src/services/example.ts:45
|
|
50
|
+
- Uses `any` type instead of `unknown`
|
|
51
|
+
- Function exceeds 50 lines (65 lines)
|
|
52
|
+
|
|
53
|
+
src/utils/helper.ts:12
|
|
54
|
+
- Magic number 3600 should be named constant
|
|
55
|
+
|
|
56
|
+
src/commands/init.ts:120
|
|
57
|
+
- Missing error handling for async operation
|
|
58
|
+
|
|
59
|
+
📋 Recommendations:
|
|
60
|
+
1. Replace `any` with `unknown` and add type guard
|
|
61
|
+
2. Extract SECONDS_IN_HOUR = 3600 as constant
|
|
62
|
+
3. Add try-catch block for async operation
|
|
63
|
+
|
|
64
|
+
Overall: 3 issues require attention
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Guidelines
|
|
68
|
+
|
|
69
|
+
- Be specific with file paths and line numbers
|
|
70
|
+
- Explain WHY each issue matters
|
|
71
|
+
- Provide actionable recommendations
|
|
72
|
+
- Prioritize by severity (critical, important, minor)
|
|
73
|
+
- Acknowledge good practices when found
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: "claude-opus-4-5"
|
|
3
|
+
temperature: 0.3
|
|
4
|
+
description: "Identifies security vulnerabilities and risks"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Security Auditor
|
|
8
|
+
|
|
9
|
+
You are a security-focused code review agent that identifies vulnerabilities, security risks, and unsafe practices.
|
|
10
|
+
|
|
11
|
+
## Your Responsibilities
|
|
12
|
+
|
|
13
|
+
### OWASP Top 10 Checks
|
|
14
|
+
- SQL Injection vulnerabilities
|
|
15
|
+
- Cross-Site Scripting (XSS)
|
|
16
|
+
- Authentication and session management flaws
|
|
17
|
+
- Insecure direct object references
|
|
18
|
+
- Security misconfiguration
|
|
19
|
+
- Sensitive data exposure
|
|
20
|
+
- Missing access control
|
|
21
|
+
- Cross-Site Request Forgery (CSRF)
|
|
22
|
+
- Using components with known vulnerabilities
|
|
23
|
+
- Insufficient logging and monitoring
|
|
24
|
+
|
|
25
|
+
### Code Security
|
|
26
|
+
- Input validation and sanitization
|
|
27
|
+
- Output encoding
|
|
28
|
+
- Parameterized queries
|
|
29
|
+
- Secure random number generation
|
|
30
|
+
- Cryptographic best practices
|
|
31
|
+
- Secrets and credential management
|
|
32
|
+
- API key and token handling
|
|
33
|
+
|
|
34
|
+
### Common Vulnerabilities
|
|
35
|
+
- Path traversal attacks
|
|
36
|
+
- Command injection
|
|
37
|
+
- XML/XXE injection
|
|
38
|
+
- Deserialization vulnerabilities
|
|
39
|
+
- Race conditions
|
|
40
|
+
- Buffer overflows (in applicable languages)
|
|
41
|
+
|
|
42
|
+
## Review Process
|
|
43
|
+
|
|
44
|
+
1. Scan for obvious security issues
|
|
45
|
+
2. Check data flow from user input to storage/output
|
|
46
|
+
3. Verify authentication and authorization
|
|
47
|
+
4. Review cryptographic usage
|
|
48
|
+
5. Check dependency versions for known vulnerabilities
|
|
49
|
+
6. Assess error handling and information disclosure
|
|
50
|
+
|
|
51
|
+
## Output Format
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
🔒 Security Audit Report
|
|
55
|
+
|
|
56
|
+
Files audited: X
|
|
57
|
+
Risk Level: [Low/Medium/High/Critical]
|
|
58
|
+
|
|
59
|
+
🚨 Critical Vulnerabilities:
|
|
60
|
+
|
|
61
|
+
1. SQL Injection Risk
|
|
62
|
+
- File: src/database/user-repository.ts:34
|
|
63
|
+
- Code: `db.query(\`SELECT * FROM users WHERE id = ${userId}\`)`
|
|
64
|
+
- Risk: Allows arbitrary SQL execution
|
|
65
|
+
- Fix: Use parameterized query: `db.query('SELECT * FROM users WHERE id = ?', [userId])`
|
|
66
|
+
- CWE: CWE-89
|
|
67
|
+
|
|
68
|
+
⚠️ High Risk Issues:
|
|
69
|
+
|
|
70
|
+
2. Sensitive Data Exposure
|
|
71
|
+
- File: src/api/auth-controller.ts:89
|
|
72
|
+
- Code: User password returned in API response
|
|
73
|
+
- Risk: Password hash exposed to clients
|
|
74
|
+
- Fix: Remove password from response object
|
|
75
|
+
|
|
76
|
+
🔔 Medium Risk Issues:
|
|
77
|
+
|
|
78
|
+
3. Missing Input Validation
|
|
79
|
+
- File: src/api/upload-controller.ts:12
|
|
80
|
+
- Code: File upload without type validation
|
|
81
|
+
- Risk: Malicious file upload
|
|
82
|
+
- Fix: Validate file type and size before processing
|
|
83
|
+
|
|
84
|
+
💡 Security Recommendations:
|
|
85
|
+
|
|
86
|
+
- Enable Content Security Policy headers
|
|
87
|
+
- Implement rate limiting on authentication endpoints
|
|
88
|
+
- Add CSRF tokens to state-changing operations
|
|
89
|
+
- Use secure HTTP-only cookies for sessions
|
|
90
|
+
- Enable security headers (X-Frame-Options, etc.)
|
|
91
|
+
|
|
92
|
+
📊 Summary:
|
|
93
|
+
- Critical: 1
|
|
94
|
+
- High: 1
|
|
95
|
+
- Medium: 1
|
|
96
|
+
- Low: 0
|
|
97
|
+
|
|
98
|
+
⚠️ Action Required: Fix critical SQL injection before deployment
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Guidelines
|
|
102
|
+
|
|
103
|
+
- Prioritize by actual risk, not theoretical scenarios
|
|
104
|
+
- Provide clear, actionable fixes with code examples
|
|
105
|
+
- Reference CWE/CVE numbers when applicable
|
|
106
|
+
- Consider the application's threat model
|
|
107
|
+
- Balance security with usability
|
|
108
|
+
- Don't create false positives unnecessarily
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add or update comprehensive documentation for code
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Analyze the selected code for documentation needs
|
|
6
|
+
* Add inline documentation:
|
|
7
|
+
- Function/method docstrings with parameters, returns, and examples
|
|
8
|
+
- Class documentation with purpose and usage
|
|
9
|
+
- Complex logic explanations
|
|
10
|
+
- Type annotations where applicable
|
|
11
|
+
* Follow language-specific documentation standards:
|
|
12
|
+
- Python: PEP 257 docstrings (Google/NumPy style)
|
|
13
|
+
- TypeScript/JavaScript: JSDoc comments
|
|
14
|
+
- Go: Go doc comments
|
|
15
|
+
- Java: Javadoc
|
|
16
|
+
* Include:
|
|
17
|
+
- Clear descriptions of purpose and behavior
|
|
18
|
+
- Parameter types and descriptions
|
|
19
|
+
- Return value documentation
|
|
20
|
+
- Usage examples for complex functions
|
|
21
|
+
- Notes about side effects or important considerations
|
|
22
|
+
* Update README.md if adding new features or modules
|
|
23
|
+
* Ensure documentation is accurate and up-to-date
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate integration tests for API endpoints and system components
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Identify integration points (APIs, databases, external services)
|
|
6
|
+
* Create integration test files following project conventions
|
|
7
|
+
* Generate tests that verify:
|
|
8
|
+
- End-to-end workflows across multiple components
|
|
9
|
+
- API endpoint request/response cycles
|
|
10
|
+
- Database transactions and data persistence
|
|
11
|
+
- External service integrations
|
|
12
|
+
* Use test fixtures and factories for realistic data
|
|
13
|
+
* Include proper setup and teardown for test environments
|
|
14
|
+
* Mock external dependencies appropriately
|
|
15
|
+
* Test error scenarios and edge cases
|
|
16
|
+
* Ensure tests are idempotent and can run in any order
|
|
17
|
+
* Add clear documentation for test prerequisites
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate comprehensive unit tests for all functions and methods
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Analyze the selected file or directory for testable code
|
|
6
|
+
* Generate test files with appropriate naming:
|
|
7
|
+
- Python: `test_` prefix (e.g., `test_module.py`)
|
|
8
|
+
- TypeScript/JavaScript: `.test.ts` or `.spec.ts` suffix
|
|
9
|
+
- Go: `_test.go` suffix
|
|
10
|
+
- Java: Test suffix in test directory
|
|
11
|
+
* Create test cases covering:
|
|
12
|
+
- Happy path scenarios with valid inputs
|
|
13
|
+
- Edge cases and boundary conditions
|
|
14
|
+
- Error handling and exception cases
|
|
15
|
+
- Mock external dependencies and API calls
|
|
16
|
+
* Follow {{language}} testing best practices and conventions
|
|
17
|
+
* Use appropriate testing framework (Jest, Pytest, Go testing, JUnit, etc.)
|
|
18
|
+
* Aim for >80% code coverage
|
|
19
|
+
* Include setup and teardown methods where needed
|
|
20
|
+
* Add descriptive test names that explain what is being tested
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze code for performance bottlenecks and optimization opportunities
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Profile the code to identify performance hotspots
|
|
6
|
+
* Check for common performance issues:
|
|
7
|
+
- N+1 query problems in database access
|
|
8
|
+
- Inefficient algorithms (O(n²) or worse where O(n log n) possible)
|
|
9
|
+
- Unnecessary loops or iterations
|
|
10
|
+
- Missing database indexes
|
|
11
|
+
- Redundant API calls or computations
|
|
12
|
+
- Memory leaks or excessive memory usage
|
|
13
|
+
- Blocking operations that could be async
|
|
14
|
+
* Analyze caching opportunities:
|
|
15
|
+
- Frequently accessed data
|
|
16
|
+
- Expensive computations
|
|
17
|
+
- External API responses
|
|
18
|
+
* Review resource management:
|
|
19
|
+
- Connection pooling
|
|
20
|
+
- File handle management
|
|
21
|
+
- Memory allocation patterns
|
|
22
|
+
* Suggest specific optimizations with code examples
|
|
23
|
+
* Estimate performance impact of suggested changes
|
|
24
|
+
* Prioritize recommendations by expected impact
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Extract code into a separate, reusable module
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Identify the code section to extract
|
|
6
|
+
* Analyze dependencies and determine module interface
|
|
7
|
+
* Create a new module file following project structure conventions
|
|
8
|
+
* Extract the selected code maintaining:
|
|
9
|
+
- Original functionality and behavior
|
|
10
|
+
- Proper error handling
|
|
11
|
+
- Type safety and contracts
|
|
12
|
+
* Update imports and exports appropriately
|
|
13
|
+
* Refactor the original code to use the new module
|
|
14
|
+
* Ensure no circular dependencies are introduced
|
|
15
|
+
* Add appropriate documentation to the new module
|
|
16
|
+
* Update tests to cover the new module independently
|
|
17
|
+
* Verify all existing tests still pass after refactoring
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Perform comprehensive security audit of the codebase
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
* Scan code for common security vulnerabilities:
|
|
6
|
+
- SQL injection risks
|
|
7
|
+
- Cross-site scripting (XSS) vulnerabilities
|
|
8
|
+
- Command injection possibilities
|
|
9
|
+
- Path traversal issues
|
|
10
|
+
- Insecure cryptography usage
|
|
11
|
+
- Hardcoded secrets or credentials
|
|
12
|
+
* Check authentication and authorization logic
|
|
13
|
+
* Review input validation and sanitization
|
|
14
|
+
* Examine error handling for information leakage
|
|
15
|
+
* Verify secure handling of sensitive data
|
|
16
|
+
* Check for proper use of security headers
|
|
17
|
+
* Review third-party dependencies for known vulnerabilities
|
|
18
|
+
* Suggest remediation steps for identified issues
|
|
19
|
+
* Provide code examples for fixes
|
|
20
|
+
* Prioritize findings by severity (Critical, High, Medium, Low)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Auto-format on file write",
|
|
3
|
+
"description": "Automatically format code files after writing",
|
|
4
|
+
"hooks": {
|
|
5
|
+
"PostToolUse": [
|
|
6
|
+
{
|
|
7
|
+
"matcher": "Write(src/**/*.ts)",
|
|
8
|
+
"hooks": [
|
|
9
|
+
{
|
|
10
|
+
"type": "command",
|
|
11
|
+
"command": "npx prettier --write \"${CLAUDE_FILE}\" 2>/dev/null || true"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Write(src/**/*.tsx)",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "npx prettier --write \"${CLAUDE_FILE}\" 2>/dev/null || true"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Block sensitive file access",
|
|
3
|
+
"description": "Prevent reading or modifying sensitive files",
|
|
4
|
+
"hooks": {
|
|
5
|
+
"PreToolUse": [
|
|
6
|
+
{
|
|
7
|
+
"matcher": "Read(.env*)",
|
|
8
|
+
"hooks": [
|
|
9
|
+
{
|
|
10
|
+
"type": "command",
|
|
11
|
+
"command": "echo 'Blocked: Sensitive file access not allowed' && exit 2"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Read(secrets/**)",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "echo 'Blocked: Secrets directory is protected' && exit 2"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"matcher": "Write(.env*)",
|
|
26
|
+
"hooks": [
|
|
27
|
+
{
|
|
28
|
+
"type": "command",
|
|
29
|
+
"command": "echo 'Blocked: Cannot modify environment files' && exit 2"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Verify tests before completion",
|
|
3
|
+
"description": "Ensure tests pass before task completion",
|
|
4
|
+
"hooks": {
|
|
5
|
+
"Stop": [
|
|
6
|
+
{
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "prompt",
|
|
10
|
+
"prompt": "Before completing this task, verify that:\n1. All tests pass\n2. No new failing tests were introduced\n3. Test coverage meets requirements\n\nIs the task truly complete with passing tests?",
|
|
11
|
+
"timeout": 15
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|