AgentSkillsCN

Project Conventions

可自定义的项目规范模板。可根据您特定项目的技术栈、结构与标准,灵活调整这些设置。

SKILL.md
--- frontmatter
description: Customizable project conventions template. Adapt these settings to match your specific project's technology stack, structure, and standards.
user_invocable: false

Project Conventions

Customize the sections below to match your project. All agents reference these conventions when making implementation decisions.

Technology Stack

<!-- Update these to match your project. The defaults below reflect a typical full-stack setup. -->
LayerTechnologyVersion
Backend LanguagePython3.11+
Backend FrameworkFastAPI
Frontend LanguageTypeScript5.x
Frontend FrameworkReact19.x
Frontend BuildVite6.x
Frontend RoutingTanStack Router
Frontend StateTanStack Query
Frontend StylingTailwind CSS + shadcn/ui
DatabasePostgreSQL
ORMSQLAlchemy 2.0 (async)
MigrationsAlembic
Backend Testingpytest
Frontend TestingVitest + React Testing Library
E2E TestingPlaywright
Backend Package Manageruv
Frontend Package Managerpnpm
Build SystemTurborepo
CI/CDGitHub Actions
ContainerPodman / Docker
CloudOpenShift / Kubernetes

Project Structure

<!-- Update to match your project's directory layout. The default below is a Turborepo monorepo. -->
code
project/
├── packages/
│   ├── ui/                   # React frontend (pnpm)
│   │   ├── src/
│   │   │   ├── components/   # UI components (atoms, molecules, organisms, templates)
│   │   │   ├── routes/       # TanStack Router file-based routes
│   │   │   ├── hooks/        # Custom React hooks (TanStack Query wrappers)
│   │   │   ├── services/     # API client functions
│   │   │   ├── schemas/      # Zod schemas for API response validation
│   │   │   ├── styles/       # Global CSS and Tailwind config
│   │   │   └── test/         # Test utilities and setup
│   │   └── vitest.config.ts
│   ├── api/                  # FastAPI backend (uv/Python)
│   │   ├── src/
│   │   │   ├── core/         # Settings and configuration
│   │   │   ├── routes/       # API route handlers
│   │   │   ├── schemas/      # Pydantic request/response models
│   │   │   ├── models/       # SQLAlchemy models (re-exported from db)
│   │   │   └── main.py       # FastAPI application entry point
│   │   └── tests/
│   ├── db/                   # Database models & migrations (uv/Python)
│   │   ├── src/db/
│   │   │   ├── database.py   # Connection and session management
│   │   │   └── models.py     # SQLAlchemy model definitions
│   │   └── alembic/          # Alembic migration versions
│   └── configs/              # Shared ESLint, Prettier, Ruff configs
├── deploy/
│   └── helm/                 # Helm charts for OpenShift/Kubernetes
├── plans/                    # SDD planning artifacts (product plan, architecture, requirements)
│   └── reviews/              # Agent review documents (product-plan-review-*.md, etc.)
├── docs/
│   ├── adr/                  # Architecture Decision Records
│   ├── api/                  # API documentation
│   ├── product/              # PRDs and product plans (legacy — prefer plans/ for SDD)
│   ├── project/              # Work breakdowns, Jira/Linear exports
│   ├── technical-designs/    # Technical Design Documents
│   └── sre/                  # SLOs, runbooks, incident reviews
├── compose.yml               # Local development with containers
├── turbo.json                # Turborepo pipeline configuration
└── Makefile                  # Common development commands

Planning Artifacts (SDD Workflow)

When following the Spec-Driven Development workflow (see workflow-patterns/SKILL.md), planning artifacts live in plans/ with agent reviews in plans/reviews/.

ArtifactPathProduced By
Product planplans/product-plan.md@product-manager
Architecture designplans/architecture.md@architect
Requirements documentplans/requirements.md@requirements-analyst
Technical design (per phase)plans/technical-design-phase-N.md@tech-lead
Agent reviewplans/reviews/<artifact>-review-<agent-name>.mdReviewing agent
Work breakdown (per phase)docs/project/work-breakdown-phase-N.md@project-manager

Review File Naming Convention

code
plans/reviews/product-plan-review-architect.md
plans/reviews/product-plan-review-api-designer.md
plans/reviews/product-plan-review-security-engineer.md
plans/reviews/architecture-review-security-engineer.md
plans/reviews/architecture-review-sre-engineer.md
plans/reviews/requirements-review-product-manager.md
plans/reviews/requirements-review-architect.md
plans/reviews/technical-design-phase-1-review-code-reviewer.md

Naming Conventions

ItemConventionExample
Python filessnake_caseuser_profile.py
Python variables/functionssnake_caseget_user_profile
Python classesPascalCaseUserProfile
React component filesPascalCaseUserProfile.tsx
React hookscamelCase with use prefixuseUserProfile.ts
TypeScript utility fileskebab-caseapi-client.ts
TypeScript variables/functionscamelCasegetUserProfile
ConstantsUPPER_SNAKE_CASEMAX_RETRIES
DB tablessnake_caseuser_profiles
DB columnssnake_casecreated_at
API endpointskebab-case/user-profiles
Env variablesUPPER_SNAKE_CASEDATABASE_URL

Error Handling Pattern

<!-- Customize for your project's error handling approach -->

Backend (Python)

python
class AppError(Exception):
    def __init__(self, message: str, code: str, status_code: int):
        self.message = message
        self.code = code
        self.status_code = status_code
        super().__init__(message)

class NotFoundError(AppError):
    def __init__(self, resource: str, id: str):
        super().__init__(
            message=f"{resource} {id} not found",
            code="NOT_FOUND",
            status_code=404,
        )

Frontend (TypeScript)

typescript
class AppError extends Error {
  constructor(
    message: string,
    public readonly code: string,
    public readonly statusCode: number,
  ) {
    super(message);
  }
}

Environment Configuration

<!-- List required environment variables -->
VariableRequiredDescription
APP_ENVYesdevelopment, staging, production
PORTNoServer port (default: 8000)
DATABASE_URLYesDatabase connection string
LOG_LEVELNoLogging level (default: info)
SECRET_KEYYesApplication secret key
CORS_ORIGINSNoAllowed CORS origins (default: http://localhost:5173)

Git Workflow

<!-- Customize merge strategy and branch rules for your project. --> <!-- The git-workflow rule (.claude/rules/git-workflow.md) defines commit conventions. --> <!-- Override the merge strategy below to match your team's preference. -->
  • Branch from main
  • PR required for merge
  • At least 1 approval required
  • CI must pass before merge
  • Rebase onto main before merging (prefer linear history)

Frontend Architecture

<!-- Customize for your project's frontend patterns. Remove if backend-only. --> <!-- For detailed path-scoped rules, see .claude/rules/ui-development.md -->

Routing

TanStack Router with file-based route definitions:

FileRoute
routes/index.tsx/
routes/about.tsx/about
routes/users/$id.tsx/users/:id (dynamic)
routes/__root.tsxRoot layout wrapper

State Management

  • Server state: TanStack Query for all API data (fetching, caching, synchronization)
  • Client state: React hooks (useState, useReducer) for local UI state
  • No global state library unless the project genuinely needs client-side state beyond server cache

Component Organization

Atomic design pattern:

code
components/
├── atoms/           # Basic building blocks (Button, Input, Badge)
├── molecules/       # Combinations of atoms (FormField, Card)
├── organisms/       # Complex components (Header, Footer, DataTable)
└── templates/       # Page layouts (DashboardLayout)

API Integration Pattern

code
Component → Hook → TanStack Query → Service → API
  • Schemas (schemas/): Zod schemas for API response validation
  • Services (services/): Fetch functions that call the API and parse responses
  • Hooks (hooks/): TanStack Query wrappers around services
  • Components: Consume hooks for data, handle loading/error states

Database Development

<!-- Customize for your project's database patterns. Remove if no database. --> <!-- For detailed path-scoped rules, see .claude/rules/database-development.md -->

ORM Patterns (SQLAlchemy 2.0)

Use the modern Mapped[] type annotations for all models:

python
from sqlalchemy.orm import Mapped, mapped_column

class User(Base):
    __tablename__ = "users"

    id: Mapped[int] = mapped_column(primary_key=True)
    email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
    name: Mapped[str] = mapped_column(String(100))
    created_at: Mapped[datetime] = mapped_column(
        DateTime(timezone=True), server_default=func.now()
    )

Migration Workflow

  1. Define or modify the SQLAlchemy model
  2. Auto-generate migration: alembic revision --autogenerate -m "description"
  3. Review the generated migration — auto-generate is not infallible
  4. Apply: alembic upgrade head
  5. Always provide both upgrade() and downgrade() functions

Best Practices

  • Index frequently queried columns
  • Use server defaults for timestamps (server_default=func.now())
  • Use async sessions for all database operations
  • Define relationships explicitly with back_populates

Inter-Package Dependencies

<!-- Customize for your project's package dependency graph. -->
code
ui ──────► api (HTTP)
           │
           ▼
          db (Python import)
  • The ui package calls the api via HTTP (configured via environment variable)
  • The api package imports models from db as a Python dependency
  • The db package is standalone and manages database connections/models