@malamute/ai-rules 1.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.
Files changed (46) hide show
  1. package/README.md +174 -0
  2. package/bin/cli.js +5 -0
  3. package/configs/_shared/.claude/commands/fix-issue.md +38 -0
  4. package/configs/_shared/.claude/commands/generate-tests.md +49 -0
  5. package/configs/_shared/.claude/commands/review-pr.md +77 -0
  6. package/configs/_shared/.claude/rules/accessibility.md +270 -0
  7. package/configs/_shared/.claude/rules/performance.md +226 -0
  8. package/configs/_shared/.claude/rules/security.md +188 -0
  9. package/configs/_shared/.claude/skills/debug/SKILL.md +118 -0
  10. package/configs/_shared/.claude/skills/learning/SKILL.md +224 -0
  11. package/configs/_shared/.claude/skills/review/SKILL.md +86 -0
  12. package/configs/_shared/.claude/skills/spec/SKILL.md +112 -0
  13. package/configs/_shared/CLAUDE.md +174 -0
  14. package/configs/angular/.claude/rules/components.md +257 -0
  15. package/configs/angular/.claude/rules/state.md +250 -0
  16. package/configs/angular/.claude/rules/testing.md +422 -0
  17. package/configs/angular/.claude/settings.json +31 -0
  18. package/configs/angular/CLAUDE.md +251 -0
  19. package/configs/dotnet/.claude/rules/api.md +370 -0
  20. package/configs/dotnet/.claude/rules/architecture.md +199 -0
  21. package/configs/dotnet/.claude/rules/database/efcore.md +408 -0
  22. package/configs/dotnet/.claude/rules/testing.md +389 -0
  23. package/configs/dotnet/.claude/settings.json +9 -0
  24. package/configs/dotnet/CLAUDE.md +319 -0
  25. package/configs/nestjs/.claude/rules/auth.md +321 -0
  26. package/configs/nestjs/.claude/rules/database/prisma.md +305 -0
  27. package/configs/nestjs/.claude/rules/database/typeorm.md +379 -0
  28. package/configs/nestjs/.claude/rules/modules.md +215 -0
  29. package/configs/nestjs/.claude/rules/testing.md +315 -0
  30. package/configs/nestjs/.claude/rules/validation.md +279 -0
  31. package/configs/nestjs/.claude/settings.json +15 -0
  32. package/configs/nestjs/CLAUDE.md +263 -0
  33. package/configs/nextjs/.claude/rules/components.md +211 -0
  34. package/configs/nextjs/.claude/rules/state/redux-toolkit.md +429 -0
  35. package/configs/nextjs/.claude/rules/state/zustand.md +299 -0
  36. package/configs/nextjs/.claude/rules/testing.md +315 -0
  37. package/configs/nextjs/.claude/settings.json +29 -0
  38. package/configs/nextjs/CLAUDE.md +376 -0
  39. package/configs/python/.claude/rules/database/sqlalchemy.md +355 -0
  40. package/configs/python/.claude/rules/fastapi.md +272 -0
  41. package/configs/python/.claude/rules/flask.md +332 -0
  42. package/configs/python/.claude/rules/testing.md +374 -0
  43. package/configs/python/.claude/settings.json +18 -0
  44. package/configs/python/CLAUDE.md +273 -0
  45. package/package.json +41 -0
  46. package/src/install.js +315 -0
@@ -0,0 +1,224 @@
1
+ ---
2
+ name: learning
3
+ description: Pedagogical coding mode - explains everything before implementing, sources all decisions, shows alternatives. Use when learning a new framework or when you want to understand the code being generated.
4
+ argument-hint: [framework-name]
5
+ ---
6
+
7
+ # Learning Mode Activated
8
+
9
+ You are now in **learning mode**. The user wants to understand everything before implementation.
10
+
11
+ ## Core Rules
12
+
13
+ ### 1. NEVER Implement Without Explicit Approval
14
+
15
+ Before writing ANY code, you MUST:
16
+
17
+ 1. Explain the approach in detail
18
+ 2. Show the planned code with comments
19
+ 3. **Wait for explicit validation** ("ok", "go", "approved", "let's do it")
20
+
21
+ Format your proposals like this:
22
+
23
+ ````
24
+ ## Proposed Implementation
25
+
26
+ **What we're building**: [clear description]
27
+
28
+ **Approach**: [detailed explanation of the strategy]
29
+
30
+ **Files to create/modify**:
31
+ - `path/to/file1.ts` - [purpose]
32
+ - `path/to/file2.ts` - [purpose]
33
+
34
+ **Code preview**:
35
+ ```[language]
36
+ // Commented code showing what will be created
37
+ ````
38
+
39
+ **Why this approach?**
40
+
41
+ - Reason 1
42
+ - Source: [official doc link]
43
+ - Reason 2
44
+ - Source: [official doc link]
45
+
46
+ **Alternative approaches**:
47
+
48
+ | Approach | Pros | Cons | When to use |
49
+ | -------------- | ---- | ---- | ----------- |
50
+ | Current choice | ... | ... | ... |
51
+ | Alternative A | ... | ... | ... |
52
+
53
+ ---
54
+
55
+ 👉 **Do you approve this implementation?** (reply "go" to proceed)
56
+
57
+ ````
58
+
59
+ ### 2. Source EVERYTHING
60
+
61
+ Every technical decision must include a source. Acceptable sources (in order of preference):
62
+
63
+ 1. **Official documentation** (always preferred)
64
+ 2. **Official blog posts** (Vercel blog, Angular blog, etc.)
65
+ 3. **GitHub issues/discussions** (for edge cases)
66
+ 4. **Reputable tech blogs** (when official docs are lacking)
67
+
68
+ Format:
69
+ ```typescript
70
+ // Server Components are default in App Router
71
+ // Source: https://nextjs.org/docs/app/building-your-application/rendering/server-components
72
+
73
+ // Use 'use client' directive for client-side interactivity
74
+ // Source: https://nextjs.org/docs/app/building-your-application/rendering/client-components
75
+ ````
76
+
77
+ ### 3. Always Show Alternatives
78
+
79
+ For every significant decision, present at least ONE alternative:
80
+
81
+ ```
82
+ **Chosen**: Server Components with native fetch
83
+ - Built-in caching and deduplication
84
+ - Source: https://nextjs.org/docs/app/building-your-application/data-fetching
85
+
86
+ **Alternative**: React Query with Client Components
87
+ - Better for: real-time data, optimistic updates, complex client state
88
+ - Source: https://tanstack.com/query/latest/docs/framework/react/overview
89
+
90
+ **Why I chose the first**: [specific reason for this use case]
91
+ ```
92
+
93
+ ### 4. Comment Code Extensively
94
+
95
+ When showing code, add explanatory comments:
96
+
97
+ ```typescript
98
+ // app/users/page.tsx
99
+
100
+ // No 'use client' = Server Component (default in App Router)
101
+ // Server Components can use async/await directly
102
+ // Source: https://nextjs.org/docs/app/building-your-application/rendering/server-components
103
+ export default async function UsersPage() {
104
+
105
+ // fetch() in Server Components has automatic caching
106
+ // Default: cache: 'force-cache' (static data)
107
+ // Options: 'no-store' (dynamic), { next: { revalidate: N } } (ISR)
108
+ // Source: https://nextjs.org/docs/app/api-reference/functions/fetch
109
+ const users = await fetch('https://api.example.com/users', {
110
+ cache: 'no-store', // Real-time data, no caching
111
+ }).then(res => res.json());
112
+
113
+ return (
114
+ <ul>
115
+ {/* key is required for React reconciliation */}
116
+ {users.map(user => (
117
+ <li key={user.id}>{user.name}</li>
118
+ ))}
119
+ </ul>
120
+ );
121
+ }
122
+ ```
123
+
124
+ ### 5. Use Checkpoints for Complex Tasks
125
+
126
+ Break large implementations into validated steps:
127
+
128
+ ```
129
+ ## Implementation Plan
130
+
131
+ ### Checkpoint 1: Project Setup ⏳
132
+ - [ ] Initialize project structure
133
+ - [ ] Configure TypeScript
134
+ - [ ] Setup routing
135
+
136
+ ### Checkpoint 2: Data Layer
137
+ - [ ] Create API routes
138
+ - [ ] Setup data fetching
139
+ - [ ] Add error handling
140
+
141
+ ### Checkpoint 3: UI Components
142
+ - [ ] Build page layouts
143
+ - [ ] Create reusable components
144
+ - [ ] Add styling
145
+
146
+ ---
147
+
148
+ 👉 **Ready to start Checkpoint 1?**
149
+ ```
150
+
151
+ After completing each checkpoint, summarize what was done and ask before proceeding.
152
+
153
+ ### 6. Explain Errors Pedagogically
154
+
155
+ When errors occur:
156
+
157
+ ````
158
+ ## Error Explanation
159
+
160
+ **Error message**:
161
+ `TypeError: Cannot read properties of undefined (reading 'name')`
162
+
163
+ **What happened**:
164
+ We tried to access `.name` on a variable that was `undefined`
165
+
166
+ **Why this happens**:
167
+ In JavaScript/TypeScript, accessing properties on `undefined` throws this error.
168
+ Common causes:
169
+ - Data not loaded yet
170
+ - API returned empty/null
171
+ - Typo in property name
172
+
173
+ **The fix**:
174
+ ```typescript
175
+ // Option 1: Optional chaining
176
+ user?.name
177
+
178
+ // Option 2: Nullish coalescing
179
+ user?.name ?? 'Default Name'
180
+
181
+ // Option 3: Early return / guard clause
182
+ if (!user) return null;
183
+ ````
184
+
185
+ **How to prevent this**:
186
+
187
+ - Enable TypeScript strict mode
188
+ - Always handle loading/error states
189
+ - Use proper typing
190
+
191
+ Source: https://www.typescriptlang.org/tsconfig#strictNullChecks
192
+
193
+ ```
194
+
195
+ ### 7. Check Understanding (Optional)
196
+
197
+ Periodically offer comprehension checks:
198
+
199
+ ```
200
+
201
+ **Quick check** (skip if clear):
202
+
203
+ - Do you understand why we use 'use client' here but not on the page?
204
+ - Any questions about the caching strategy?
205
+
206
+ ```
207
+
208
+ ## Framework-Specific Context
209
+
210
+ If the user specified a framework with `/learning [framework]`:
211
+
212
+ - **$ARGUMENTS** contains the framework name
213
+ - Focus explanations on that framework's conventions
214
+ - Prioritize that framework's official documentation
215
+
216
+ ## Deactivation
217
+
218
+ The user can exit learning mode by saying:
219
+ - "exit learning mode"
220
+ - "mode normal"
221
+ - "stop explaining"
222
+
223
+ Then return to standard implementation behavior.
224
+ ```
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: review
3
+ description: Code review workflow with structured checklist
4
+ argument-hint: [file-or-folder]
5
+ ---
6
+
7
+ # Code Review Skill
8
+
9
+ You are now in **code review mode**. Review the code systematically and provide actionable feedback.
10
+
11
+ ## Target
12
+
13
+ If an argument is provided, review that specific file or folder: `$ARGUMENTS`
14
+ If no argument, ask the user what to review.
15
+
16
+ ## Review Checklist
17
+
18
+ Go through each category and report findings:
19
+
20
+ ### 1. Correctness
21
+ - [ ] Logic errors or bugs
22
+ - [ ] Edge cases not handled
23
+ - [ ] Null/undefined checks missing
24
+ - [ ] Error handling gaps
25
+
26
+ ### 2. Security
27
+ - [ ] Input validation
28
+ - [ ] SQL/NoSQL injection risks
29
+ - [ ] XSS vulnerabilities
30
+ - [ ] Secrets or credentials exposed
31
+ - [ ] Authentication/authorization issues
32
+
33
+ ### 3. Performance
34
+ - [ ] N+1 queries
35
+ - [ ] Unnecessary re-renders (frontend)
36
+ - [ ] Missing indexes (database)
37
+ - [ ] Large payloads or memory leaks
38
+ - [ ] Blocking operations in async code
39
+
40
+ ### 4. Code Quality
41
+ - [ ] Naming clarity
42
+ - [ ] Function/method length (< 30 lines ideal)
43
+ - [ ] Single responsibility principle
44
+ - [ ] Dead code
45
+ - [ ] Duplicated logic
46
+
47
+ ### 5. Testing
48
+ - [ ] Critical paths covered
49
+ - [ ] Edge cases tested
50
+ - [ ] Mocks used appropriately
51
+
52
+ ### 6. Project Conventions
53
+ - [ ] Follows project CLAUDE.md rules
54
+ - [ ] Consistent with existing patterns
55
+ - [ ] Proper file/folder structure
56
+
57
+ ## Output Format
58
+
59
+ Structure your review as:
60
+
61
+ ```
62
+ ## Summary
63
+ [1-2 sentences overall assessment]
64
+
65
+ ## Critical Issues
66
+ [Must fix before merge]
67
+
68
+ ## Suggestions
69
+ [Nice to have improvements]
70
+
71
+ ## Good Practices
72
+ [What's done well - be specific]
73
+ ```
74
+
75
+ ## Behavior
76
+
77
+ 1. Read the target files thoroughly
78
+ 2. Check each category in the checklist
79
+ 3. Be specific: include file paths and line numbers
80
+ 4. Prioritize: critical > suggestions > praise
81
+ 5. Be constructive, not just critical
82
+ 6. If everything looks good, say so confidently
83
+
84
+ ## Exit
85
+
86
+ When done, ask: "Want me to fix any of these issues?"
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: spec
3
+ description: Generate technical specification before implementing
4
+ argument-hint: [feature-description]
5
+ ---
6
+
7
+ # Technical Specification Skill
8
+
9
+ You are now in **specification mode**. Before writing any code, create a clear technical spec.
10
+
11
+ ## Input
12
+
13
+ Feature to specify: `$ARGUMENTS`
14
+
15
+ If no argument provided, ask: "What feature should I specify?"
16
+
17
+ ## Process
18
+
19
+ ### Step 1: Understand Requirements
20
+
21
+ Ask clarifying questions if needed:
22
+ - What problem does this solve?
23
+ - Who are the users?
24
+ - What are the acceptance criteria?
25
+ - Any constraints (tech, time, dependencies)?
26
+
27
+ ### Step 2: Research Codebase
28
+
29
+ Before writing the spec:
30
+ 1. Search for similar existing patterns
31
+ 2. Identify files that will be affected
32
+ 3. Check for dependencies or conflicts
33
+ 4. Understand current architecture
34
+
35
+ ### Step 3: Write Specification
36
+
37
+ ## Spec Template
38
+
39
+ ```markdown
40
+ # [Feature Name] - Technical Specification
41
+
42
+ ## Overview
43
+ [2-3 sentences describing the feature]
44
+
45
+ ## Goals
46
+ - [ ] Goal 1
47
+ - [ ] Goal 2
48
+
49
+ ## Non-Goals
50
+ - What this feature will NOT do
51
+
52
+ ## Technical Approach
53
+
54
+ ### Architecture
55
+ [How it fits into existing system]
56
+
57
+ ### Files to Create/Modify
58
+ | File | Action | Description |
59
+ |------|--------|-------------|
60
+ | path/to/file.ts | Create | New service for X |
61
+ | path/to/other.ts | Modify | Add method Y |
62
+
63
+ ### Data Model
64
+ [If applicable: new entities, schemas, migrations]
65
+
66
+ ### API Changes
67
+ [If applicable: new endpoints, request/response shapes]
68
+
69
+ ### Dependencies
70
+ - External packages needed
71
+ - Internal modules to import
72
+
73
+ ## Implementation Steps
74
+ 1. [ ] Step 1
75
+ 2. [ ] Step 2
76
+ 3. [ ] Step 3
77
+
78
+ ## Testing Strategy
79
+ - Unit tests for: ...
80
+ - Integration tests for: ...
81
+ - E2E tests for: ...
82
+
83
+ ## Risks & Mitigations
84
+ | Risk | Mitigation |
85
+ |------|------------|
86
+ | Risk 1 | How to handle |
87
+
88
+ ## Open Questions
89
+ - [ ] Question 1
90
+ - [ ] Question 2
91
+ ```
92
+
93
+ ## Behavior
94
+
95
+ 1. Never start coding without user approval of the spec
96
+ 2. Be thorough but concise
97
+ 3. Identify risks early
98
+ 4. Break down into small, testable steps
99
+ 5. Reference existing code patterns
100
+
101
+ ## Validation
102
+
103
+ After presenting the spec, ask:
104
+ - "Does this approach make sense?"
105
+ - "Any requirements I missed?"
106
+ - "Ready to implement?"
107
+
108
+ ## Exit
109
+
110
+ Only exit spec mode and start implementation when user explicitly approves.
111
+
112
+ Say: "Spec approved. Starting implementation..." before writing code.
@@ -0,0 +1,174 @@
1
+ # Shared Conventions
2
+
3
+ ## Git Workflow
4
+
5
+ ### Branch Naming
6
+
7
+ ```
8
+ feature/[ticket-id]-short-description
9
+ fix/[ticket-id]-short-description
10
+ refactor/description
11
+ chore/description
12
+ ```
13
+
14
+ ### Commit Messages (Conventional Commits)
15
+
16
+ ```
17
+ type(scope): description
18
+
19
+ [optional body]
20
+
21
+ [optional footer]
22
+ ```
23
+
24
+ Types:
25
+ - `feat`: New feature
26
+ - `fix`: Bug fix
27
+ - `docs`: Documentation only
28
+ - `style`: Formatting, no code change
29
+ - `refactor`: Code change that neither fixes a bug nor adds a feature
30
+ - `perf`: Performance improvement
31
+ - `test`: Adding or updating tests
32
+ - `chore`: Maintenance tasks
33
+
34
+ Examples:
35
+ ```
36
+ feat(users): add user profile page
37
+ fix(auth): resolve token refresh race condition
38
+ refactor(api): simplify error handling
39
+ test(cart): add unit tests for checkout flow
40
+ ```
41
+
42
+ ### Pull Requests
43
+
44
+ - Keep PRs small and focused
45
+ - One feature/fix per PR
46
+ - Write meaningful descriptions
47
+ - Link related issues
48
+
49
+ ## TypeScript Guidelines
50
+
51
+ ### Strict Mode
52
+
53
+ Always use strict TypeScript configuration:
54
+ ```json
55
+ {
56
+ "compilerOptions": {
57
+ "strict": true,
58
+ "noImplicitAny": true,
59
+ "strictNullChecks": true,
60
+ "noImplicitReturns": true
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### Type Definitions
66
+
67
+ ```typescript
68
+ // Prefer interfaces for object shapes
69
+ interface User {
70
+ id: string;
71
+ name: string;
72
+ email: string;
73
+ }
74
+
75
+ // Use type for unions, intersections, utility types
76
+ type Status = 'pending' | 'active' | 'inactive';
77
+ type UserWithRole = User & { role: Role };
78
+
79
+ // Avoid 'any' - use 'unknown' if type is truly unknown
80
+ function parse(input: unknown): Result {
81
+ // ...
82
+ }
83
+ ```
84
+
85
+ ### Naming Conventions
86
+
87
+ | Element | Convention | Example |
88
+ |---------|------------|---------|
89
+ | Classes | PascalCase | `UserService` |
90
+ | Interfaces | PascalCase | `UserProfile` |
91
+ | Functions | camelCase | `getUserById` |
92
+ | Variables | camelCase | `currentUser` |
93
+ | Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
94
+ | Files | kebab-case | `user-profile.service.ts` |
95
+ | Folders | kebab-case | `user-management/` |
96
+
97
+ ### Explicit Return Types
98
+
99
+ Always declare return types on public methods:
100
+
101
+ ```typescript
102
+ // Good
103
+ function getUser(id: string): User | null {
104
+ // ...
105
+ }
106
+
107
+ // Avoid
108
+ function getUser(id: string) {
109
+ // ...
110
+ }
111
+ ```
112
+
113
+ ## Code Quality
114
+
115
+ ### Avoid
116
+
117
+ - `any` type
118
+ - Magic numbers (use named constants)
119
+ - Deep nesting (max 3 levels)
120
+ - Long functions (max ~50 lines)
121
+ - Commented-out code
122
+ - Useless comments (code should be self-documenting)
123
+ - Cryptic variable names (`c`, `x`, `tmp`, `data`)
124
+
125
+ ### Prefer
126
+
127
+ - Early returns
128
+ - Descriptive variable names
129
+ - Single responsibility principle
130
+ - Composition over inheritance
131
+ - Immutable data patterns
132
+
133
+ ### Naming - Be Explicit
134
+
135
+ ```typescript
136
+ // BAD
137
+ const c = getConfig();
138
+ users.filter(u => u.a);
139
+ const handleClick = (e) => { ... };
140
+
141
+ // GOOD
142
+ const appConfig = getConfig();
143
+ users.filter(user => user.isActive);
144
+ const handleUserSelection = (event: MouseEvent) => { ... };
145
+ ```
146
+
147
+ ### Lint Rules - Never Disable Without Justification
148
+
149
+ ```typescript
150
+ // FORBIDDEN
151
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
+ const data: any = response;
153
+
154
+ // ONLY IF ABSOLUTELY NECESSARY - with explicit reason
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Legacy API returns untyped, see ticket TECH-456
156
+ const legacyData: any = legacyApi.fetch();
157
+ ```
158
+
159
+ ## Documentation
160
+
161
+ - Write self-documenting code first
162
+ - Add JSDoc only when intent isn't obvious
163
+ - Keep comments up-to-date or remove them
164
+ - Document "why", not "what"
165
+
166
+ ```typescript
167
+ // Bad: describes what code does
168
+ // Increment counter by 1
169
+ counter++;
170
+
171
+ // Good: explains why
172
+ // Compensate for 0-based index in display
173
+ counter++;
174
+ ```