# AI Agent Rules for TypeScript Projects

**⚠️ READ AGENTS_RULES.md FOR COMPLETE DOCUMENTATION**

This is a quick reference. Full rules are in `AGENTS_RULES.md`.

## Quick Reference

### Workflow
1. **Plan** → Discuss with user
2. **Test** → Write failing tests first (TDD)
3. **Develop** → Implement with TypeScript best practices
4. **Test** → `npm test` (90% coverage minimum)
5. **Commit** → Get user approval first

### TypeScript Best Practices
- **Type Safety**: Use strict mode, avoid `any`
- **Interfaces**: Define clear contracts
- **Generics**: For reusable type-safe code
- **Type Guards**: Runtime type checking
- **Discriminated Unions**: For Result/Option types
- **Readonly**: Immutability by default

### Code Quality
- ❌ No `any` type (use `unknown` instead)
- ❌ No `!` non-null assertion (use type guards)
- ✅ Use strict TypeScript config
- ✅ Explicit return types on functions
- ✅ Readonly properties when possible

### Testing
```bash
npm test
npm run test:coverage
npm run test:watch
```

### Git Rules
- ❌ NEVER `git stash`
- ❌ NEVER `git push` or `git push --force`
- ✅ ALWAYS ask user approval before commit

### Commit Format
```
<type>(agt): <description>

Types: feat, fix, refac, chore, doc, test
Example: feat(agt): add user authentication module
```

### Tools
```bash
tsc                  # Compile
tsc --watch          # Watch mode
npm test             # Test
npm run lint         # ESLint
npm run format       # Prettier
```

---

**📖 For complete rules, examples, and detailed guidelines:**
**Read `AGENTS_RULES.md` in this directory**
