Skip to content

Commit ec1c374

Browse files
committed
Add comprehensive CLAUDE.md documentation
Create initial CLAUDE.md file with project overview, architecture guidelines, development setup instructions, coding conventions, and best practices for the preference-injector project.
0 parents  commit ec1c374

1 file changed

Lines changed: 211 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Preference Injector
2+
3+
## Project Overview
4+
5+
This project implements a preference injection system that allows dynamic modification of user preferences or settings in applications. The system is designed to inject, override, or manage user preferences at runtime.
6+
7+
## Project Structure
8+
9+
```
10+
preference-injector/
11+
├── src/ # Source code
12+
│ ├── core/ # Core injection logic
13+
│ ├── providers/ # Preference providers
14+
│ ├── utils/ # Utility functions
15+
│ └── types/ # TypeScript type definitions
16+
├── tests/ # Test files
17+
├── examples/ # Usage examples
18+
├── docs/ # Documentation
19+
└── dist/ # Build output (generated)
20+
```
21+
22+
## Development Setup
23+
24+
### Prerequisites
25+
- Node.js (LTS version recommended)
26+
- npm or yarn package manager
27+
- TypeScript
28+
29+
### Installation
30+
```bash
31+
npm install
32+
```
33+
34+
### Build
35+
```bash
36+
npm run build
37+
```
38+
39+
### Testing
40+
```bash
41+
npm test
42+
```
43+
44+
### Development Mode
45+
```bash
46+
npm run dev
47+
```
48+
49+
## Architecture
50+
51+
### Core Components
52+
53+
1. **Injector**: Main class responsible for injecting preferences into target applications
54+
2. **Providers**: Sources of preference data (file-based, API-based, environment variables)
55+
3. **Resolvers**: Logic for resolving preference conflicts and priorities
56+
4. **Validators**: Ensure preference values are valid and safe
57+
58+
### Key Concepts
59+
60+
- **Preference Sources**: Where preferences originate (config files, databases, APIs)
61+
- **Injection Points**: Where preferences are applied in the application
62+
- **Priority Levels**: Mechanism for handling conflicting preferences
63+
- **Validation Rules**: Constraints and validation for preference values
64+
65+
## Coding Conventions
66+
67+
### TypeScript
68+
- Use strict TypeScript configuration
69+
- Prefer interfaces over types for object shapes
70+
- Use explicit return types for functions
71+
- Avoid `any` type; use `unknown` when type is truly unknown
72+
73+
### Naming Conventions
74+
- Files: `kebab-case.ts`
75+
- Classes: `PascalCase`
76+
- Functions/Variables: `camelCase`
77+
- Constants: `UPPER_SNAKE_CASE`
78+
- Interfaces: `PascalCase` (prefix with `I` only if necessary for clarity)
79+
80+
### Code Style
81+
- Use 2 spaces for indentation
82+
- Use single quotes for strings
83+
- Add semicolons
84+
- Use async/await over raw Promises
85+
- Prefer const over let; avoid var
86+
87+
### Error Handling
88+
- Use custom error classes for domain-specific errors
89+
- Always handle promise rejections
90+
- Provide meaningful error messages
91+
- Log errors appropriately
92+
93+
## Testing Strategy
94+
95+
- Unit tests: Test individual components in isolation
96+
- Integration tests: Test component interactions
97+
- End-to-end tests: Test complete preference injection workflows
98+
- Coverage target: >80%
99+
100+
### Test File Naming
101+
- Unit tests: `*.test.ts`
102+
- Integration tests: `*.integration.test.ts`
103+
- E2E tests: `*.e2e.test.ts`
104+
105+
## Security Considerations
106+
107+
1. **Input Validation**: Always validate preference values before injection
108+
2. **Sanitization**: Sanitize user-provided preferences to prevent injection attacks
109+
3. **Access Control**: Ensure proper authorization for preference modifications
110+
4. **Encryption**: Sensitive preferences should be encrypted at rest and in transit
111+
5. **Audit Logging**: Track all preference changes for security auditing
112+
113+
## Performance Guidelines
114+
115+
- Cache frequently accessed preferences
116+
- Use lazy loading for large preference sets
117+
- Implement efficient lookup mechanisms (hash maps, indexes)
118+
- Avoid synchronous blocking operations
119+
- Batch preference updates when possible
120+
121+
## Common Tasks
122+
123+
### Adding a New Preference Provider
124+
1. Create new provider class in `src/providers/`
125+
2. Implement the `PreferenceProvider` interface
126+
3. Add validation logic
127+
4. Write tests
128+
5. Update documentation
129+
130+
### Adding a New Injection Point
131+
1. Define injection point interface
132+
2. Implement injection logic
133+
3. Add error handling
134+
4. Write integration tests
135+
5. Document usage
136+
137+
### Modifying Validation Rules
138+
1. Update validator in `src/validators/`
139+
2. Add test cases for new rules
140+
3. Update schema documentation
141+
4. Consider backward compatibility
142+
143+
## Dependencies
144+
145+
### Runtime Dependencies
146+
- Check `package.json` for current dependencies
147+
- Key dependencies are documented with their purpose
148+
149+
### Development Dependencies
150+
- TypeScript
151+
- Testing framework (Jest/Mocha)
152+
- Linters (ESLint)
153+
- Formatter (Prettier)
154+
155+
## Troubleshooting
156+
157+
### Common Issues
158+
159+
**Preference not being injected**
160+
- Check provider configuration
161+
- Verify injection point is registered
162+
- Check priority settings
163+
- Review validation rules
164+
165+
**Type errors**
166+
- Ensure TypeScript definitions are up to date
167+
- Check for missing type imports
168+
- Verify generic type parameters
169+
170+
**Build failures**
171+
- Clear dist folder and rebuild
172+
- Check for circular dependencies
173+
- Verify all imports are correct
174+
175+
## API Reference
176+
177+
Detailed API documentation is available in `docs/api.md` (when created).
178+
179+
## Contributing
180+
181+
When adding new features:
182+
1. Create feature branch from main
183+
2. Write tests first (TDD approach preferred)
184+
3. Implement feature
185+
4. Ensure all tests pass
186+
5. Update documentation
187+
6. Create pull request with clear description
188+
189+
## Environment Variables
190+
191+
```bash
192+
# Example configuration
193+
PREFERENCE_SOURCE=file|api|env
194+
PREFERENCE_CACHE_TTL=3600
195+
PREFERENCE_VALIDATION_STRICT=true
196+
LOG_LEVEL=info|debug|error
197+
```
198+
199+
## Git Workflow
200+
201+
- Main branch: `main` (protected)
202+
- Feature branches: `feature/<description>`
203+
- Bug fixes: `fix/<description>`
204+
- Claude AI branches: `claude/*`
205+
206+
## Additional Notes
207+
208+
- This project may integrate with various application frameworks
209+
- Preference schemas should be versioned for backward compatibility
210+
- Consider implementing preference migration strategies
211+
- Document all breaking changes in CHANGELOG.md

0 commit comments

Comments
 (0)