Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问许可证需确认审计提醒

architect-python-uv-fastapi-sqlalchemy架构师 Python UV FastAPI sqlalchemy

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

269

周安装

11

GitHub Stars

公开资料未说明

下载量

86
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:architect-python-uv-fastapi-sqlalchemy(架构师 Python UV FastAPI sqlalchemy)
来源仓库:https://github.com/ajrlewis/ai-skills
仓库路径:skills/architect-python-uv-fastapi-sqlalchemy
安装命令:
npx skills add https://github.com/ajrlewis/ai-skills --skill architect-python-uv-fastapi-sqlalchemy
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ajrlewis/ai-skills --skill architect-python-uv-fastapi-sqlalchemy

简介

architect-python-uv-fastapi-sqlalchemy 构建基于 FastAPI 和 SQLAlchemy 的生产级 API 脚手架。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 中快速启动带数据库迁移和容器化的后端服务。
  • 通过 GitHub 安装,使用 npx skills add 命令添加技能,默认集成 Docker 和 CI 配置。
  • 安装前建议确认权限范围,注意是否会触发网络请求、数据库连接或容器构建操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Architect: Python + uv + FastAPI + SQLAlchemy

Use this skill when the user wants a production API scaffold in Python with modern packaging (uv), database migrations, containerization, and CI. Docker is required by default for this runnable base architect skill. Only allow NO_DOCKER=yes when the user explicitly asks for a local-only exception.

Inputs

Collect these values first:

  • PROJECT_NAME: kebab-case repository/folder name.
  • MODULE_NAME: import-safe module name (usually snake_case).
  • PYTHON_VERSION: default 3.12.
  • DATABASE_URL: runtime DB URL.
  • NO_DOCKER: default no. Set yes only when user explicitly opts out of containerization.

Use these version defaults unless user requests otherwise:

  • uv latest stable via astral-sh/setup-uv
  • Python 3.12
  • postgres:16-alpine

Preflight Checks

Run before scaffolding:

command -v uv >/dev/null && uv --version || echo "uv-missing"
python3 --version
command -v docker >/dev/null && docker --version || echo "docker-missing"

Execution modes:

  • production-default: create and validate container artifacts (NO_DOCKER=no).
  • local-no-docker: skip container files only when user explicitly sets NO_DOCKER=yes.
  • offline-smoke: tools/network constrained; scaffold structure and report verification limits.

Production-default contract:

  • Must create Dockerfile, .dockerignore, and docker-compose.yml.
  • Must include CI image build check.
  • Must run containerized smoke validation.

Scaffold Workflow

  1. Initialize project:
uv init --package {{PROJECT_NAME}}
cd {{PROJECT_NAME}}
  1. Install runtime and dev dependencies:
uv add fastapi "uvicorn[standard]" sqlalchemy asyncpg alembic pydantic-settings
uv add -d pytest pytest-asyncio httpx ruff mypy
  1. Create source layout:
src/{{MODULE_NAME}}/
  api/routes/health.py
  core/config.py
  db/base.py
  db/session.py
  main.py
tests/
  1. Initialize Alembic and wire metadata:
uv run alembic init alembic
  • Set alembic.ini sqlalchemy.url to ${DATABASE_URL}.
  • In alembic/env.py, import Base.metadata from src/{{MODULE_NAME}}/db/base.py.
  1. Add infrastructure and CI files (NO_DOCKER=no):
  • Dockerfile
  • .dockerignore
  • docker-compose.yml
  • .github/workflows/ci.yml If NO_DOCKER=yes, document this exception in project notes and keep non-container validation.

Required File Templates

src/{{MODULE_NAME}}/core/config.py

from pydantic_settings import BaseSettings, SettingsConfigDict

class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
    app_name: str = "api"
    environment: str = "development"
    database_url: str = "postgresql+asyncpg://app:app@localhost:5432/app"

settings = Settings()

src/{{MODULE_NAME}}/db/base.py

from sqlalchemy.orm import DeclarativeBase

class Base(DeclarativeBase):
    pass

src/{{MODULE_NAME}}/db/session.py

from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine

from {{MODULE_NAME}}.core.config import settings

engine = create_async_engine(settings.database_url, pool_pre_ping=True)
SessionLocal = async_sessionmaker(bind=engine, expire_on_commit=False)

src/{{MODULE_NAME}}/api/routes/health.py

from fastapi import APIRouter

router = APIRouter()

@router.get("/healthz", tags=["health"])
async def healthcheck() -> dict[str, str]:
    return {"status": "ok"}

src/{{MODULE_NAME}}/main.py

from fastapi import FastAPI

from {{MODULE_NAME}}.api.routes.health import router as health_router

app = FastAPI(title="{{PROJECT_NAME}}")
app.include_router(health_router)

Dockerfile

FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS build
WORKDIR /app
COPY pyproject.toml uv.lock ./
COPY src ./src
RUN uv sync --frozen --no-dev

FROM python:3.12-slim AS run
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN useradd --create-home --shell /bin/bash app
COPY --from=build /app/.venv /app/.venv
COPY src ./src
COPY alembic ./alembic
COPY alembic.ini ./
ENV PATH="/app/.venv/bin:$PATH"
USER app
EXPOSE 8000
CMD ["uvicorn", "{{MODULE_NAME}}.main:app", "--host", "0.0.0.0", "--port", "8000"]

.dockerignore

.git
.venv
__pycache__
.pytest_cache
.mypy_cache
.ruff_cache
*.pyc
dist
build

docker-compose.yml

services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: app
      POSTGRES_USER: app
      POSTGRES_PASSWORD: app
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app -d app"]
      interval: 5s
      timeout: 5s
      retries: 20
    volumes:
      - pg_data:/var/lib/postgresql/data

  api:
    build: .
    environment:
      DATABASE_URL: postgresql+asyncpg://app:app@db:5432/app
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "8000:8000"

volumes:
  pg_data:

Keep ports: - "8000:8000" on the api service so the host can reach the app. If documenting direct docker run usage for the API image, include -p 8000:8000 and the required DATABASE_URL; docker compose remains the default local path because it provides the database too.

.github/workflows/ci.yml

name: ci
on:
  push:
  pull_request:

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - uses: astral-sh/setup-uv@v5
      - name: Install deps
        run: uv sync --frozen --dev
      - name: Ruff
        run: uv run ruff check .
      - name: Ruff Docstrings
        run: uv run ruff check . --select D
      - name: Mypy
        run: uv run mypy src
      - name: Pytest
        run: uv run pytest -q
      - uses: docker/setup-buildx-action@v3
      - uses: docker/build-push-action@v6
        with:
          context: .
          push: false
          tags: {{PROJECT_NAME}}:ci
          cache-from: type=gha
          cache-to: type=gha,mode=max

Guardrails

  • Documentation contract for generated code:

- Python: write module docstrings and docstrings for public classes, methods, and functions. - Next.js/TypeScript: write JSDoc for exported components, hooks, utilities, and route handlers. - Add concise rationale comments only for non-obvious logic, invariants, or safety constraints. - Apply this contract even when using template snippets below; expand templates as needed.

  • Keep async DB stack consistent (sqlalchemy.ext.asyncio + asyncpg).
  • Never hardcode secrets; use environment variables and .env.
  • Ensure Alembic migrations are generated and committed.
  • Ensure container runs as non-root user.
  • Prefer docker compose in docs and scripts.
  • Treat NO_DOCKER=yes as an explicit exception, not default behavior.
  • Ensure uv.lock is committed before Docker build; the Dockerfile copies it explicitly for deterministic uv sync --frozen installs.

Validation Checklist

  • Confirm generated code includes required docstrings/JSDoc and rationale comments for non-obvious logic.

Run and fix failures before finishing:

uv run ruff check .
uv run ruff check . --select D
uv run mypy src
uv run pytest -q
uv run alembic upgrade head
test -f uv.lock
docker build -t {{PROJECT_NAME}}:local .
docker compose up -d --build
docker compose ps
curl http://localhost:8000/healthz

local-no-docker (NO_DOCKER=yes):

uv run ruff check .
uv run ruff check . --select D
uv run mypy src
uv run pytest -q
uv run alembic upgrade head

Fallback (offline-smoke):

python3 -m compileall src
test -f Dockerfile || echo "docker-artifacts-missing-in-offline-smoke"

Decision Justification Rule

  • Every non-trivial decision must include a concrete justification.
  • Capture the alternatives considered and why they were rejected.
  • State tradeoffs and residual risks for the chosen option.
  • If justification is missing, treat the task as incomplete and surface it as a blocker.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.16%
按下载量换算32

Claude

28.43%
按下载量换算24

Cursor

19.93%
按下载量换算17

Gemini CLI

9.79%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills