STYLE_GUIDE: Coding & Git Standards โ
This document defines the engineering standards for camply. All agents and contributors MUST adhere to these rules to ensure a maintainable and consistent codebase.
๐ Python Standards (Backend) โ
- Strict Typing: Every function signature MUST have type hints. Use
mypyto verify. - Pydantic v2: Use Pydantic for all data validation and DTOs. Prefer
BaseModeland avoid raw dictionaries. - Async-First: All I/O operations (DB queries, API calls) MUST be
async. - Logging: Use
structlogfor structured, JSON-compatible logging. Never useprint(). - Docstrings: Follow the NumPy docstring convention for all public methods and classes.
โ๏ธ React & TypeScript Standards (Frontend) โ
- Functional Components: Use arrow functions for components (
export const MyComponent = () => ...). - TypeScript: Avoid
any. Define strict interfaces/types for all component props and state. - Tailwind CSS: Use Tailwind classes for styling. Follow the standard utility order (Layout -> Box Model -> Typography -> Visuals).
- Shadcn/UI: Use Shadcn primitives for UI atoms. Do not modify the primitives in
src/components/ui/directly; wrap them if needed. - TanStack Query: Use React Query for all server-state. Keep API logic inside
src/lib/api.tsor the generated SDK.
๐ณ Git & PR Standards โ
- Gitmoji: Every commit message MUST start with a relevant Gitmoji.
- โจ
:sparkles:for new features. - ๐
:bug:for bug fixes. - ๐
:memo:for documentation. - ๐งช
:test_tube:for tests. - ๐จ
:art:for UI/style changes.
- โจ
- Commit Messages: Follow the "Why, not what" rule.
- Bad:
โจ add unique_target model - Good:
โจ Implement UniqueTarget model to support scan de-duplication
- Bad:
- Branching: Work in isolated branches (or worktrees). Never commit directly to
main. - PR Descriptions: Every PR must include:
- A summary of changes.
- A link to the relevant
spec-kitplan. - A screenshot or DB query result proving validation.
๐งช Testing Discipline โ
- Coverage: Every new feature MUST have corresponding tests.
- VCR: External API interactions MUST be recorded using
pytest-vcr. - Red-Green-Refactor: For bug fixes, write a failing test first to reproduce the issue.