Cline rules
.clinerules/validation_rules.mdCline rules
Quality
73/100
Scores the file, not the repository.Length
465 words
25 headings · 9 code blocksRepository
0
— · pushed 25 days agoLast changed
2 days ago
First indexed 2 days ago.1# Validation Rules23## Critical Backend Rules45### Import Paths6**MUST** be relative to `backend/app/` (NO `app.` prefix)78✅ **CORRECT**:9```python10from core.database import get_db11from schemas.user import UserCreate12from services.user_service import UserService13from models.user import User14from repositories.user_repository import UserRepository15```1617❌ **WRONG**:18```python19from app.core.database import get_db20from backend.app.schemas.user import UserCreate21```2223### Password Handling24**ALWAYS** hash passwords before storing in database2526```python27from core.security import hash_password, verify_password2829# Hash before storing30hashed = hash_password(plain_password)3132# Verify on login33is_valid = verify_password(plain_password, hashed)34```3536### Database Operations37**ALWAYS** use async/await for all database operations3839```python40# ✅ CORRECT41async def get_user(user_id: int, db: AsyncSession):42 repo = UserRepository(db)43 user = await repo.get_by_id(user_id)44 return user45```4647### Database Writes48**ALWAYS** commit after write operations4950```python51# ✅ CORRECT52async def create_user(data: UserCreate, db: AsyncSession):53 repo = UserRepository(db)54 user = await repo.create(**data.model_dump())55 await db.commit() # Don't forget!56 await db.refresh(user) # Refresh to get updated data57 return user58```5960### SQLAlchemy 2.0 Patterns61Use modern syntax with type hints6263```python64from sqlalchemy.orm import Mapped, mapped_column6566class User(Base):67 __tablename__ = "users"6869 user_id: Mapped[int] = mapped_column(primary_key=True)70 username: Mapped[str]71 email: Mapped[str]72```7374## Architecture Layer Rules7576### API Layer (`backend/app/api/routers/`)77- Handle HTTP request/response78- Use Pydantic schemas for validation79- Inject dependencies (database session)80- NO business logic here8182### Service Layer (`backend/app/services/`)83- Implement business logic84- Handle authentication/authorization85- Calculate achievements86- Enforce business rules87- NO direct database access (use repositories)8889### Repository Layer (`backend/app/repositories/`)90- CRUD operations only91- Custom database queries92- Extend `BaseRepository` for common operations93- NO business logic here9495### Database Layer (`backend/app/models/`)96- SQLAlchemy ORM models97- Define table structure98- Define relationships99- NO business logic here100101## Docker Rules102103### Always Rebuild After Code Changes104```bash105docker compose down && docker compose up --build -d106```107108**Why?** Docker caches layers. Code changes won't reflect without rebuild.109110## Pydantic Schema Rules111112### Use `model_config` for ORM mode113```python114from pydantic import BaseModel, ConfigDict115116class UserResponse(BaseModel):117 model_config = ConfigDict(from_attributes=True)118119 user_id: int120 username: str121```122123### Separate Create/Update/Response schemas124- `UserCreate` - For creating new records125- `UserUpdate` - For updating existing records126- `UserResponse` - For API responses127128## FastAPI Dependency Injection129130### Database Session131```python132from fastapi import Depends133from core.database import get_db134from sqlalchemy.ext.asyncio import AsyncSession135136async def endpoint(db: AsyncSession = Depends(get_db)):137 # Use db here138 pass139```140141## Common Pitfalls to Avoid142143❌ Forgetting to commit after database writes144❌ Using sync code instead of async/await145❌ Not hashing passwords before storing146❌ Wrong import paths (using `app.` prefix)147❌ Not rebuilding Docker containers after changes148❌ Putting business logic in API layer149❌ Direct database access from service layer (skip repository)150151## Quick Reference152153→ Detailed patterns: `docs/development-guide.md#common-patterns`154→ Architecture details: `docs/architecture.md`155→ Adding features: `docs/development-guide.md#adding-a-new-feature`156
Also in KiralyAlparCsaba/Sapi3D
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| KiralyAlparCsaba/Sapi3D.clinerules/api_patterns.md · 0 | Cline rules | teststyleapiui+1 | 52/100 | 2 days ago | |
| KiralyAlparCsaba/Sapi3D.clinerules/architecture.md · 0 | Cline rules | archdatabaseapiui+2 | 54/100 | 2 days ago | |
| KiralyAlparCsaba/Sapi3D.clinerules/common_tasks.md · 0 | Cline rules | setupbuildtestdatabase+3 | 82/100 | 2 days ago | |
| KiralyAlparCsaba/Sapi3D.clinerules/database.md · 0 | Cline rules | archsecuritydatabaseperformance+1 | 62/100 | 2 days ago | |
| KiralyAlparCsaba/Sapi3D.clinerules/file_locations.md · 0 | Cline rules | archdatabaseapiui+1 | 58/100 | 2 days ago | |
| KiralyAlparCsaba/Sapi3D.clinerules/project_overview.md · 0 | Cline rules | archdatabasedocs | 48/100 | 2 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bashdeban/fastmind.clinerules/.project-consistency-keeper2.md · 5 | Cline rules | setupbuildtestlint-format+11 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.clinerules · 31k | Cline rules | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| BryaanF/LiantPortfolio.clinerules/project-guidelines.md · 0 | Cline rules | buildstylearchgit+2 | 96/100 | 3 days ago | |
| u9401066/zotero-keeper.clinerules/50-pubmed-project.md · 6 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/zotero-keepervscode-extension/resources/repo-assets/pubmed-search-mcp/.clinerules/50-pubmed-project.md · 6 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/pubmed-search-mcp.clinerules/50-pubmed-project.md · 23 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| prabhakar267/paper-games.clinerules/git-commit-guidelines.md · 0 | Cline rules | lint-formatstylearchgit+3 | 93/100 | 2 days ago | |
| VaillerTeeter/HoshimiNest.clinerules/project-identity.md · 1 | Cline rules | setuparchtypesdo-not | 93/100 | yesterday |
