Guidelines for building RAG (Retrieval-Augmented Generation) applications with DDD architecture, TDD practices, and AI-assisted development using Cursor Tools
A comprehensive skill for developing RAG (Retrieval-Augmented Generation) applications using Domain-Driven Design principles, Test-Driven Development, and AI-assisted workflows with Cursor Tools.
This skill guides you through building production-quality TypeScript applications with:
**Apply DDD principles:**
**Type management:**
**Before writing code:**
```bash
cursor-tools web "best practices for [specific topic]"
```
Use Perplexity AI to research current best practices for the feature you're implementing.
**After writing code:**
```bash
cursor-tools repo "review this code for [specific concern]"
```
Use Gemini to peer review your implementation.
**Testing workflow:**
**Always enforce:**
```bash
npm run format # or your prettier command
npm run lint # or your eslint command
```
**Import conventions:**
**Environment variables:**
```
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
OPENAI_API_KEY=your_api_key_here
```
**Work in feedback cycles:**
1. **Research phase:**
```bash
cursor-tools web "how to implement [feature] in TypeScript"
# Save complex research
cursor-tools web "advanced RAG techniques" --save-to=local-research/rag-patterns.md
```
2. **Implementation phase:**
- Write failing tests first (TDD)
- Implement minimal code to pass tests
- Refactor for clarity
3. **Review phase:**
```bash
cursor-tools repo "review authentication flow for security issues"
cursor-tools repo "suggest improvements for embedding generation"
```
4. **Documentation phase:**
```bash
cursor-tools doc --output docs.md
```
5. **Repeat:** Continue the cycle for each feature
**Web Research (Perplexity):**
```bash
cursor-tools web "latest PostgreSQL vector search best practices"
cursor-tools web "TypeScript DDD patterns" --save-to=local-research/ddd-patterns.md
```
**Repository Context (Gemini):**
```bash
cursor-tools repo "explain the embedding generation flow"
cursor-tools repo "how does the document retrieval work?"
cursor-tools repo "review this function for edge cases"
```
**Documentation Generation:**
```bash
cursor-tools doc --output docs.md
cursor-tools doc --from-github=username/repo-name --save-to=local-docs/repo-name.md
```
**GitHub Operations:**
```bash
cursor-tools github pr # Last 10 PRs
cursor-tools github pr 123 # Specific PR
cursor-tools github issue # Last 10 issues
cursor-tools github issue 456 # Specific issue
```
**Browser Automation (Stagehand):**
```bash
cursor-tools browser open "http://localhost:3000" --html --screenshot=test.png
cursor-tools browser act "Click search | Type 'test query' | Click submit" --url=http://localhost:3000
cursor-tools browser extract "all document titles" --url=http://localhost:3000/documents
cursor-tools browser observe "interactive elements" --url=http://localhost:3000
cursor-tools browser act "complete user flow" --url=http://localhost:3000 --video=./test-videos
```
**Browser options:**
**Test structure:**
```typescript
import { describe, it, expect, vi } from 'vitest'
import { generateEmbedding } from './embedding'
describe('generateEmbedding', () => {
it('should generate embedding for valid text', async () => {
const mockEmbeddingService = vi.fn().mockResolvedValue([0.1, 0.2, 0.3])
const result = await generateEmbedding('test', mockEmbeddingService)
expect(result).toHaveLength(3)
})
})
```
**Run tests:**
```bash
npm test
npm run test:watch
npm run test:coverage
```
**Adding a new feature:**
1. Research:
```bash
cursor-tools web "TypeScript vector similarity search patterns"
```
2. Write test (TDD):
```typescript
it('should find similar documents', async () => {
const result = await findSimilar(queryVector, mockDb)
expect(result).toHaveLength(5)
})
```
3. Implement:
- Write minimal code to pass test
- Use dependency injection
- Keep functions pure and small
4. Review:
```bash
cursor-tools repo "review similarity search implementation for performance"
```
5. Format and lint:
```bash
npm run format
npm run lint
```
6. Repeat until feature is complete
1. **DDD First**: Organize by domain, not by technical layers
2. **TDD Always**: Tests before implementation
3. **Types Matter**: Never duplicate, always reuse
4. **AI Team**: Leverage Perplexity (web) and Gemini (repo) continuously
5. **Clean Code**: Format, lint, and review constantly
6. **Pure Functions**: Small, composable, testable units
7. **No Secrets**: Environment variables only, never committed
8. **Feedback Loop**: Research → Try → Review → Test → Repeat
You're working with a team of superhuman expert AIs. Use them constantly:
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/ddd-typescript-rag-project-development/raw