Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
442 changes: 442 additions & 0 deletions backend_index.py

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions claude.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@
- There may be multiple environments running simultaneously using different worktrees. To determine the corren environment, you can get port numbers and env name from the root .env file.
- When refactoring module names, run `grep -r "old_module_name" .` before committing to catch all remaining references (especially entry points like `main.py`). Use `__init__.py` re-exports for backward compatibility.

## Backend Development Workflow

**BEFORE writing ANY backend code, follow this workflow:**

### Step 1: Read Backend Quick Reference
Read `ushadow/backend/BACKEND_QUICK_REF.md` - it's ~1000 tokens and covers all available services, patterns, and architecture rules.

### Step 2: Search for Existing Code
```bash
# Search for existing methods before creating new ones
grep -rn "async def method_name" ushadow/backend/src/services/
grep -rn "class ClassName" ushadow/backend/src/

# Check available services
cat ushadow/backend/src/services/__init__.py

# Check backend index (method/class reference)
cat ushadow/backend/src/backend_index.py
```

### Step 3: Check Architecture
Read `ushadow/backend/src/ARCHITECTURE.md` for:
- Layer definitions (router/service/store)
- Naming conventions (Manager/Registry/Store)
- Data flow patterns

### Step 4: Follow Patterns
- **Routers**: Thin HTTP adapters (max 30 lines per endpoint, max 500 lines per file)
- **Services**: Business logic, return data not HTTP responses (max 800 lines per file)
- **Stores**: Data persistence (YAML/DB access)
- **Utils**: Pure functions, stateless (max 300 lines per file)

### File Size Limits (Ruff enforced)
- **Routers**: Max 500 lines β†’ Split by resource domain
- **Services**: Max 800 lines β†’ Extract helper services
- **Utils**: Max 300 lines β†’ Split into focused modules
- **Complexity**: Max 10 (McCabe), max 5 parameters per function

### What NOT to Do
- ❌ Business logic in routers β†’ Move to services
- ❌ `raise HTTPException` in services β†’ Return data/None, let router handle HTTP
- ❌ Direct DB/file access in routers β†’ Use services/stores
- ❌ Nested functions >50 lines β†’ Extract to methods/utilities
- ❌ Methods with >5 params β†’ Use Pydantic models
- ❌ Skip layer architecture β†’ Follow routerβ†’serviceβ†’store flow

## CRITICAL Frontend Development Rules

**MANDATORY: Every frontend change MUST include `data-testid` attributes for ALL interactive elements.**
Expand Down
Loading