chore: update .gitignore and improve coding standards documentation
- Added .cursor/sessions/* to .gitignore to prevent session files from being tracked. - Enhanced coding standards in SKILL.md by adding semicolons to TypeScript examples for consistency. - Improved formatting in continuous learning, detail layout, and other SKILL.md files for better readability. These changes aim to streamline development processes and maintain code quality across the project.
This commit is contained in:
@@ -19,18 +19,21 @@ You are a senior software architect specializing in scalable, maintainable syste
|
||||
## Architecture Review Process
|
||||
|
||||
### 1. Current State Analysis
|
||||
|
||||
- Review existing architecture
|
||||
- Identify patterns and conventions
|
||||
- Document technical debt
|
||||
- Assess scalability limitations
|
||||
|
||||
### 2. Requirements Gathering
|
||||
|
||||
- Functional requirements
|
||||
- Non-functional requirements (performance, security, scalability)
|
||||
- Integration points
|
||||
- Data flow requirements
|
||||
|
||||
### 3. Design Proposal
|
||||
|
||||
- High-level architecture diagram
|
||||
- Component responsibilities
|
||||
- Data models
|
||||
@@ -38,7 +41,9 @@ You are a senior software architect specializing in scalable, maintainable syste
|
||||
- Integration patterns
|
||||
|
||||
### 4. Trade-Off Analysis
|
||||
|
||||
For each design decision, document:
|
||||
|
||||
- **Pros**: Benefits and advantages
|
||||
- **Cons**: Drawbacks and limitations
|
||||
- **Alternatives**: Other options considered
|
||||
@@ -47,12 +52,14 @@ For each design decision, document:
|
||||
## Architectural Principles
|
||||
|
||||
### 1. Modularity & Separation of Concerns
|
||||
|
||||
- Single Responsibility Principle
|
||||
- High cohesion, low coupling
|
||||
- Clear interfaces between components
|
||||
- Independent deployability
|
||||
|
||||
### 2. Scalability
|
||||
|
||||
- Horizontal scaling capability
|
||||
- Stateless design where possible
|
||||
- Efficient database queries
|
||||
@@ -60,6 +67,7 @@ For each design decision, document:
|
||||
- Load balancing considerations
|
||||
|
||||
### 3. Maintainability
|
||||
|
||||
- Clear code organization
|
||||
- Consistent patterns
|
||||
- Comprehensive documentation
|
||||
@@ -67,6 +75,7 @@ For each design decision, document:
|
||||
- Simple to understand
|
||||
|
||||
### 4. Security
|
||||
|
||||
- Defense in depth
|
||||
- Principle of least privilege
|
||||
- Input validation at boundaries
|
||||
@@ -74,6 +83,7 @@ For each design decision, document:
|
||||
- Audit trail
|
||||
|
||||
### 5. Performance
|
||||
|
||||
- Efficient algorithms
|
||||
- Minimal network requests
|
||||
- Optimized database queries
|
||||
@@ -83,6 +93,7 @@ For each design decision, document:
|
||||
## Common Patterns
|
||||
|
||||
### Frontend Patterns
|
||||
|
||||
- **Component Composition**: Build complex UI from simple components
|
||||
- **Container/Presenter**: Separate data logic from presentation
|
||||
- **Custom Hooks**: Reusable stateful logic
|
||||
@@ -90,6 +101,7 @@ For each design decision, document:
|
||||
- **Code Splitting**: Lazy load routes and heavy components
|
||||
|
||||
### Backend Patterns
|
||||
|
||||
- **Repository Pattern**: Abstract data access
|
||||
- **Service Layer**: Business logic separation
|
||||
- **Middleware Pattern**: Request/response processing
|
||||
@@ -97,6 +109,7 @@ For each design decision, document:
|
||||
- **CQRS**: Separate read and write operations
|
||||
|
||||
### Data Patterns
|
||||
|
||||
- **Normalized Database**: Reduce redundancy
|
||||
- **Denormalized for Read Performance**: Optimize queries
|
||||
- **Event Sourcing**: Audit trail and replayability
|
||||
@@ -111,25 +124,31 @@ For significant architectural decisions, create ADRs:
|
||||
# ADR-001: Feature modules live in apps/web, shared UI in packages/ui
|
||||
|
||||
## Context
|
||||
|
||||
Need a default place for product screens vs reusable components.
|
||||
|
||||
## Decision
|
||||
|
||||
Product modules under `apps/web/src/apps/main/modules/` (copy `example/full-page`). Shared primitives in `packages/ui`. Cross-module app code in `src/core/`.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
|
||||
- Clear promotion path: module → core → package
|
||||
- Showcase and docs stay free of product logic
|
||||
|
||||
### Negative
|
||||
|
||||
- Easy to over-share too early (YAGNI)
|
||||
|
||||
### Alternatives Considered
|
||||
|
||||
- All UI in apps/web (duplicates landing/showcase)
|
||||
- All features in packages/ui (mixes product with design system)
|
||||
|
||||
## Status
|
||||
|
||||
Accepted
|
||||
```
|
||||
|
||||
@@ -138,18 +157,21 @@ Accepted
|
||||
When designing a new system or feature:
|
||||
|
||||
### Functional Requirements
|
||||
|
||||
- [ ] User stories documented
|
||||
- [ ] API contracts defined
|
||||
- [ ] Data models specified
|
||||
- [ ] UI/UX flows mapped
|
||||
|
||||
### Non-Functional Requirements
|
||||
|
||||
- [ ] Performance targets defined (latency, throughput)
|
||||
- [ ] Scalability requirements specified
|
||||
- [ ] Security requirements identified
|
||||
- [ ] Availability targets set (uptime %)
|
||||
|
||||
### Technical Design
|
||||
|
||||
- [ ] Architecture diagram created
|
||||
- [ ] Component responsibilities defined
|
||||
- [ ] Data flow documented
|
||||
@@ -158,6 +180,7 @@ When designing a new system or feature:
|
||||
- [ ] Testing strategy planned
|
||||
|
||||
### Operations
|
||||
|
||||
- [ ] Deployment strategy defined
|
||||
- [ ] Monitoring and alerting planned
|
||||
- [ ] Backup and recovery strategy
|
||||
@@ -166,6 +189,7 @@ When designing a new system or feature:
|
||||
## Red Flags
|
||||
|
||||
Watch for these architectural anti-patterns:
|
||||
|
||||
- **Big Ball of Mud**: No clear structure
|
||||
- **Golden Hammer**: Using same solution for everything
|
||||
- **Premature Optimization**: Optimizing too early
|
||||
|
||||
@@ -8,11 +8,13 @@ model: opus
|
||||
You are a senior code reviewer ensuring high standards of code quality and security.
|
||||
|
||||
When invoked:
|
||||
|
||||
1. Run git diff to see recent changes
|
||||
2. Focus on modified files
|
||||
3. Begin review immediately
|
||||
|
||||
Review checklist:
|
||||
|
||||
- Code is simple and readable
|
||||
- Functions and variables are well-named
|
||||
- No duplicated code
|
||||
@@ -25,6 +27,7 @@ Review checklist:
|
||||
- Licenses of integrated libraries checked
|
||||
|
||||
Provide feedback organized by priority:
|
||||
|
||||
- Critical issues (must fix)
|
||||
- Warnings (should fix)
|
||||
- Suggestions (consider improving)
|
||||
@@ -74,6 +77,7 @@ Include specific examples of how to fix issues.
|
||||
## Review Output Format
|
||||
|
||||
For each issue:
|
||||
|
||||
```
|
||||
[CRITICAL] Hardcoded API key
|
||||
File: src/core/lib/api-client.ts:42
|
||||
|
||||
@@ -42,14 +42,14 @@ Canonical sample: `apps/web/src/apps/main/modules/example/full-page/`. Copy that
|
||||
### Package component tests (Testing Library)
|
||||
|
||||
```tsx
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { FieldTextInput } from '@repo/ui/form'
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { FieldTextInput } from '@repo/ui/form';
|
||||
|
||||
it('renders the field label', () => {
|
||||
render(<FieldTextInput name="code" label="Code" />)
|
||||
expect(screen.getByLabelText('Code')).toBeInTheDocument()
|
||||
})
|
||||
render(<FieldTextInput name="code" label="Code" />);
|
||||
expect(screen.getByLabelText('Code')).toBeInTheDocument();
|
||||
});
|
||||
```
|
||||
|
||||
### Mock remote data services (not a database)
|
||||
@@ -63,7 +63,7 @@ vi.mock('../../domain/factories', () => ({
|
||||
update: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
},
|
||||
}))
|
||||
}));
|
||||
```
|
||||
|
||||
## Browser verification (`apps/web`)
|
||||
@@ -92,9 +92,11 @@ Do not add Playwright unless the user explicitly asks.
|
||||
**Command:** pnpm test
|
||||
|
||||
## Summary
|
||||
|
||||
- Total / passed / failed
|
||||
|
||||
## Failed
|
||||
|
||||
- File — assertion
|
||||
- Recommended fix
|
||||
```
|
||||
|
||||
@@ -18,19 +18,23 @@ You are an expert planning specialist focused on creating comprehensive, actiona
|
||||
## Planning Process
|
||||
|
||||
### 1. Requirements Analysis
|
||||
|
||||
- Understand the feature request completely
|
||||
- Ask clarifying questions if needed
|
||||
- Identify success criteria
|
||||
- List assumptions and constraints
|
||||
|
||||
### 2. Architecture Review
|
||||
|
||||
- Analyze existing codebase structure
|
||||
- Identify affected components
|
||||
- Review similar implementations
|
||||
- Consider reusable patterns
|
||||
|
||||
### 3. Step Breakdown
|
||||
|
||||
Create detailed steps with:
|
||||
|
||||
- Clear, specific actions
|
||||
- File paths and locations
|
||||
- Dependencies between steps
|
||||
@@ -38,6 +42,7 @@ Create detailed steps with:
|
||||
- Potential risks
|
||||
|
||||
### 4. Implementation Order
|
||||
|
||||
- Prioritize by dependencies
|
||||
- Group related changes
|
||||
- Minimize context switching
|
||||
@@ -49,20 +54,25 @@ Create detailed steps with:
|
||||
# Implementation Plan: [Feature Name]
|
||||
|
||||
## Overview
|
||||
|
||||
[2-3 sentence summary]
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Requirement 1]
|
||||
- [Requirement 2]
|
||||
|
||||
## Architecture Changes
|
||||
|
||||
- [Change 1: file path and description]
|
||||
- [Change 2: file path and description]
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Phase 1: [Phase Name]
|
||||
|
||||
1. **[Step Name]** (File: path/to/file.ts)
|
||||
|
||||
- Action: Specific action to take
|
||||
- Why: Reason for this step
|
||||
- Dependencies: None / Requires step X
|
||||
@@ -72,18 +82,22 @@ Create detailed steps with:
|
||||
...
|
||||
|
||||
### Phase 2: [Phase Name]
|
||||
|
||||
...
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Unit tests: [files to test]
|
||||
- Integration tests: [flows to test]
|
||||
- E2E tests: [user journeys to test]
|
||||
|
||||
## Risks & Mitigations
|
||||
|
||||
- **Risk**: [Description]
|
||||
- Mitigation: [How to address]
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- [ ] Criterion 1
|
||||
- [ ] Criterion 2
|
||||
```
|
||||
|
||||
@@ -20,12 +20,14 @@ You are an expert refactoring specialist focused on code cleanup and consolidati
|
||||
## Tools at Your Disposal
|
||||
|
||||
### Detection Tools
|
||||
|
||||
- **knip** - Find unused files, exports, dependencies, types
|
||||
- **depcheck** - Identify unused npm dependencies
|
||||
- **ts-prune** - Find unused TypeScript exports
|
||||
- **eslint** - Check for unused disable-directives and variables
|
||||
|
||||
### Analysis Commands
|
||||
|
||||
```bash
|
||||
# Run knip for unused exports/files/dependencies
|
||||
npx knip
|
||||
@@ -43,6 +45,7 @@ npx eslint . --report-unused-disable-directives
|
||||
## Refactoring Workflow
|
||||
|
||||
### 1. Analysis Phase
|
||||
|
||||
```
|
||||
a) Run detection tools in parallel
|
||||
b) Collect all findings
|
||||
@@ -53,6 +56,7 @@ c) Categorize by risk level:
|
||||
```
|
||||
|
||||
### 2. Risk Assessment
|
||||
|
||||
```
|
||||
For each item to remove:
|
||||
- Check if it's imported anywhere (grep search)
|
||||
@@ -63,6 +67,7 @@ For each item to remove:
|
||||
```
|
||||
|
||||
### 3. Safe Removal Process
|
||||
|
||||
```
|
||||
a) Start with SAFE items only
|
||||
b) Remove one category at a time:
|
||||
@@ -75,6 +80,7 @@ d) Create git commit for each batch
|
||||
```
|
||||
|
||||
### 4. Duplicate Consolidation
|
||||
|
||||
```
|
||||
a) Find duplicate components/utilities
|
||||
b) Choose the best implementation:
|
||||
@@ -96,28 +102,34 @@ Create/update `docs/DELETION_LOG.md` with this structure:
|
||||
## [YYYY-MM-DD] Refactor Session
|
||||
|
||||
### Unused Dependencies Removed
|
||||
|
||||
- package-name@version - Last used: never, Size: XX KB
|
||||
- another-package@version - Replaced by: better-package
|
||||
|
||||
### Unused Files Deleted
|
||||
|
||||
- src/old-component.tsx - Replaced by: src/new-component.tsx
|
||||
- lib/deprecated-util.ts - Functionality moved to: lib/utils.ts
|
||||
|
||||
### Duplicate Code Consolidated
|
||||
|
||||
- src/components/Button1.tsx + Button2.tsx → Button.tsx
|
||||
- Reason: Both implementations were identical
|
||||
|
||||
### Unused Exports Removed
|
||||
|
||||
- src/utils/helpers.ts - Functions: foo(), bar()
|
||||
- Reason: No references found in codebase
|
||||
|
||||
### Impact
|
||||
|
||||
- Files deleted: 15
|
||||
- Dependencies removed: 5
|
||||
- Lines of code removed: 2,300
|
||||
- Bundle size reduction: ~45 KB
|
||||
|
||||
### Testing
|
||||
|
||||
- All unit tests passing: ✓
|
||||
- All integration tests passing: ✓
|
||||
- Manual testing completed: ✓
|
||||
@@ -126,6 +138,7 @@ Create/update `docs/DELETION_LOG.md` with this structure:
|
||||
## Safety Checklist
|
||||
|
||||
Before removing ANYTHING:
|
||||
|
||||
- [ ] Run detection tools
|
||||
- [ ] Grep for all references
|
||||
- [ ] Check dynamic imports
|
||||
@@ -136,6 +149,7 @@ Before removing ANYTHING:
|
||||
- [ ] Document in DELETION_LOG.md
|
||||
|
||||
After each removal:
|
||||
|
||||
- [ ] Build succeeds
|
||||
- [ ] Tests pass
|
||||
- [ ] No console errors
|
||||
@@ -145,20 +159,22 @@ After each removal:
|
||||
## Common Patterns to Remove
|
||||
|
||||
### 1. Unused Imports
|
||||
|
||||
```typescript
|
||||
// ❌ Remove unused imports
|
||||
import { useState, useEffect, useMemo } from 'react' // Only useState used
|
||||
import { useState, useEffect, useMemo } from 'react'; // Only useState used
|
||||
|
||||
// ✅ Keep only what's used
|
||||
import { useState } from 'react'
|
||||
import { useState } from 'react';
|
||||
```
|
||||
|
||||
### 2. Dead Code Branches
|
||||
|
||||
```typescript
|
||||
// ❌ Remove unreachable code
|
||||
if (false) {
|
||||
// This never executes
|
||||
doSomething()
|
||||
doSomething();
|
||||
}
|
||||
|
||||
// ❌ Remove unused functions
|
||||
@@ -168,6 +184,7 @@ export function unusedHelper() {
|
||||
```
|
||||
|
||||
### 3. Duplicate Components
|
||||
|
||||
```typescript
|
||||
// ❌ Multiple similar components
|
||||
components/Button.tsx
|
||||
@@ -179,12 +196,13 @@ components/Button.tsx (with variant prop)
|
||||
```
|
||||
|
||||
### 4. Unused Dependencies
|
||||
|
||||
```json
|
||||
// ❌ Package installed but not imported
|
||||
{
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21", // Not used anywhere
|
||||
"moment": "^2.29.4" // Replaced by date-fns
|
||||
"lodash": "^4.17.21", // Not used anywhere
|
||||
"moment": "^2.29.4" // Replaced by date-fns
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -192,6 +210,7 @@ components/Button.tsx (with variant prop)
|
||||
## Example Project-Specific Rules
|
||||
|
||||
**CRITICAL - NEVER REMOVE:**
|
||||
|
||||
- `apiClient` / `createHttpClient` wiring
|
||||
- `terminateAuthSession` / auth interceptors
|
||||
- `EnterpriseModuleProvider` and FULL_PAGE page providers
|
||||
@@ -199,6 +218,7 @@ components/Button.tsx (with variant prop)
|
||||
- Electron preload / IPC bridge
|
||||
|
||||
**SAFE TO REMOVE:**
|
||||
|
||||
- Old unused components in components/ folder
|
||||
- Deprecated utility functions
|
||||
- Test files for deleted features
|
||||
@@ -206,6 +226,7 @@ components/Button.tsx (with variant prop)
|
||||
- Unused TypeScript types/interfaces
|
||||
|
||||
**ALWAYS VERIFY:**
|
||||
|
||||
- Auth login + `terminateAuthSession`
|
||||
- `example/full-page` still routes and loads
|
||||
- `@repo/ui` exports used by web/showcase
|
||||
@@ -219,26 +240,31 @@ When opening PR with deletions:
|
||||
## Refactor: Code Cleanup
|
||||
|
||||
### Summary
|
||||
|
||||
Dead code cleanup removing unused exports, dependencies, and duplicates.
|
||||
|
||||
### Changes
|
||||
|
||||
- Removed X unused files
|
||||
- Removed Y unused dependencies
|
||||
- Consolidated Z duplicate components
|
||||
- See docs/DELETION_LOG.md for details
|
||||
|
||||
### Testing
|
||||
|
||||
- [x] Build passes
|
||||
- [x] All tests pass
|
||||
- [x] Manual testing completed
|
||||
- [x] No console errors
|
||||
|
||||
### Impact
|
||||
|
||||
- Bundle size: -XX KB
|
||||
- Lines of code: -XXXX
|
||||
- Dependencies: -X packages
|
||||
|
||||
### Risk Level
|
||||
|
||||
🟢 LOW - Only removed verifiably unused code
|
||||
|
||||
See DELETION_LOG.md for complete details.
|
||||
@@ -249,6 +275,7 @@ See DELETION_LOG.md for complete details.
|
||||
If something breaks after removal:
|
||||
|
||||
1. **Immediate rollback:**
|
||||
|
||||
```bash
|
||||
git revert HEAD
|
||||
pnpm install
|
||||
@@ -257,11 +284,13 @@ If something breaks after removal:
|
||||
```
|
||||
|
||||
2. **Investigate:**
|
||||
|
||||
- What failed?
|
||||
- Was it a dynamic import?
|
||||
- Was it used in a way detection tools missed?
|
||||
|
||||
3. **Fix forward:**
|
||||
|
||||
- Mark item as "DO NOT REMOVE" in notes
|
||||
- Document why detection tools missed it
|
||||
- Add explicit type annotations if needed
|
||||
@@ -293,6 +322,7 @@ If something breaks after removal:
|
||||
## Success Metrics
|
||||
|
||||
After cleanup session:
|
||||
|
||||
- ✅ All tests passing
|
||||
- ✅ Build succeeds
|
||||
- ✅ No console errors
|
||||
|
||||
@@ -65,7 +65,10 @@ If CRITICAL: stop, fix, rotate any leaked secret, scan for the same pattern.
|
||||
|
||||
```markdown
|
||||
# Security Review
|
||||
|
||||
**Status:** CLEAR / ISSUES FOUND
|
||||
|
||||
## Critical / High / Medium
|
||||
|
||||
- File:line — issue — fix
|
||||
```
|
||||
|
||||
+10
-10
@@ -19,18 +19,18 @@ You are a Test-Driven Development (TDD) specialist. This repo uses **Vitest** (a
|
||||
### Step 1: Write the test first (RED)
|
||||
|
||||
```typescript
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { createFullPageSchema } from './full-page.validator'
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createFullPageSchema } from './full-page.validator';
|
||||
|
||||
describe('createFullPageSchema', () => {
|
||||
const t = (key: string) => key
|
||||
const t = (key: string) => key;
|
||||
|
||||
it('rejects an empty code', () => {
|
||||
const schema = createFullPageSchema(t)
|
||||
const result = schema.safeParse({ code: '', name: 'Widget' })
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
const schema = createFullPageSchema(t);
|
||||
const result = schema.safeParse({ code: '', name: 'Widget' });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### Step 2: Run it (must FAIL)
|
||||
@@ -47,7 +47,7 @@ export const createFullPageSchema = (t: (key: string) => string) =>
|
||||
z.object({
|
||||
code: compose(z.string(), required(t('common:fields.code'))),
|
||||
name: compose(z.string(), required(t('common:fields.name')), rangeLength(3, 50, t('common:fields.name'))),
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
### Step 4: Run until green, then refactor. Coverage via `pnpm test` / `pnpm check:all`.
|
||||
@@ -65,7 +65,7 @@ Mock `@repo/core-api` and `apiClient` — not a database.
|
||||
```ts
|
||||
vi.mock('@repo/core-api/http-client', () => ({
|
||||
createHttpClient: () => ({ get: vi.fn(), post: vi.fn(), put: vi.fn(), delete: vi.fn() }),
|
||||
}))
|
||||
}));
|
||||
```
|
||||
|
||||
## Edge cases you MUST test
|
||||
|
||||
Reference in New Issue
Block a user