Skip to content

Code Style

Snippbot uses ruff for both formatting and linting:

Terminal window
ruff check packages/ # Lint
ruff check packages/ --fix # Auto-fix
ruff format packages/ # Format
Terminal window
mypy packages/
  • Functions: snake_case
  • Classes: PascalCase
  • Constants: UPPER_SNAKE_CASE
  • Private: _prefixed
  • Max line length: 100 characters
  • Imports: stdlib → third-party → local, each group alphabetical
  • Docstrings: only on public module-level functions and classes

All route handlers and core operations are async. Use asyncio throughout — no blocking calls in async context.

# Good
async def get_project(project_id: str) -> Project:
return await project_store.get(project_id)
# Bad — blocks the event loop
def get_project(project_id: str) -> Project:
return db.execute("SELECT ...").fetchone()

Terminal window
cd packages/ui && pnpm format
Terminal window
cd packages/ui && pnpm lint
  • Components: PascalCase.tsx
  • Hooks: useXxx.ts
  • Utils: camelCase.ts
  • Types: PascalCase, defined in types/ or co-located
  • Zustand stores: one file per domain in store/
  • React Query keys: string array ['projects', id]
// Props interface at top
interface Props {
projectId: string;
onComplete?: () => void;
}
// Component
export function ProjectCard({ projectId, onComplete }: Props) {
// hooks first
const { data } = useProject(projectId);
// render
return <div>...</div>;
}

  • Branch naming: feat/description, fix/description, docs/description
  • Commits: imperative mood — “Add scheduler NL parsing” not “Added”
  • No force-push to main