원클릭으로
fastapi-sweetener
Add FastAPI server capabilities to an existing Python project with uvicorn, OpenAPI docs, and configuration management
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Add FastAPI server capabilities to an existing Python project with uvicorn, OpenAPI docs, and configuration management
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generate semantic versioned releases with changelog and GitHub releases
Set up macOS launchd service for auto-starting Python applications
Initialize complete Python project with comprehensive documentation, development environment, and tooling. Use when creating a new Python project from scratch.
Install git hooks to prevent common workflow mistakes
| name | fastapi-sweetener |
| description | Add FastAPI server capabilities to an existing Python project with uvicorn, OpenAPI docs, and configuration management |
| allowed-tools | Read, Write, Edit, Bash, Glob, AskUserQuestion |
Add FastAPI server capabilities to an existing Python project, integrating as a CLI subcommand alongside existing functionality.
This skill assumes you already have a Python project (typically created with /plinth:python-project-init) with:
pyproject.toml__init__.pycli.py)Adds FastAPI server capabilities to your existing project:
{package} server to start the APINew files:
{package}/server.py - FastAPI application{package}/config.py - Configuration managementconfig.example.json - Example configuration.env.example - Environment variable templateModified files:
{package}/cli.py - Adds server subcommand (converts to Click if needed)pyproject.toml - Adds dependencies (fastapi, uvicorn, click, pyyaml)Use Glob and Read to discover:
pyproject.toml in current directoryproject.name and package name from pyproject.toml{package}/ or src/{package}/)cli.py)__init__.py or __version__.py to get descriptionIf unable to detect structure, ask user for:
Check if server already exists:
ls {package}/server.py
If it exists, ask user if they want to overwrite it.
Ask user for (use AskUserQuestion if needed):
Optional parameters (with defaults):
SERVER_HOST (string) - Default: "0.0.0.0"
SERVER_PORT (integer) - Default: 8000
Create the following files from templates in skills/fastapi-sweetener/assets/:
{package}/server.py - FastAPI application:
assets/server.py.template{package}/server.py{package}/config.py - Configuration management:
assets/config.py.template{package}/config.pyconfig.example.json - Example config:
assets/config.example.json.templateconfig.example.json.env.example - Environment template:
assets/.env.example.template.env.exampleThis is the most critical step. The CLI needs to support subcommands.
If cli.py uses Click:
Add a new @main.command() for the server:
@main.command()
@click.option('--host', default=None, help='Server host (default: from config)')
@click.option('--port', default=None, type=int, help='Server port (default: from config)')
@click.option('--reload', is_flag=True, help='Enable auto-reload for development')
@click.option('--log-level', default='info',
type=click.Choice(['critical', 'error', 'warning', 'info', 'debug']),
help='Logging level')
def server(host, port, reload, log_level):
"""Start the FastAPI server.
This starts the HTTP server that provides the API.
The server will be accessible via http://HOST:PORT
"""
import uvicorn
from .config import Config
config = Config()
# Override config with CLI options if provided
server_host = host or config.server_host
server_port = port or config.server_port
print(f"Starting server at http://{server_host}:{server_port}")
print(f"OpenAPI docs: http://{server_host}:{server_port}/docs")
uvicorn.run(
"{{PACKAGE_NAME}}.server:app",
host=server_host,
port=server_port,
reload=reload,
log_level=log_level
)
If cli.py uses argparse:
Convert to Click. This is a significant change but necessary for subcommands:
cli.pyArgumentParser() to @click.group()@main.command() named appropriatelyserver subcommand as shown aboveAdd required dependencies to pyproject.toml:
Use Edit tool to add to the dependencies array:
dependencies = [
# ... existing deps ...
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"click>=8.0",
"pyyaml>=6.0",
]
Run uv sync to install new dependencies:
uv sync
Guide user to create config from example:
cp config.example.json config.json
Provide verification commands:
# Verify CLI still works
uv run {package} --version
# Start development server
uv run {package} server --reload
# Open in browser
open http://localhost:{port}/docs
Tell user:
{package} server subcommandconfig.json (copy from config.example.json){package}/server.py/docs and /redoc/plinth:macos-launchd-service to set up auto-start| Variable | Example | Source |
|---|---|---|
{{PROJECT_NAME}} | "Temoa" | From pyproject.toml or user input |
{{PACKAGE_NAME}} | "temoa" | Detected from directory structure |
{{PACKAGE_NAME_UPPER}} | "TEMOA" | Derived from PACKAGE_NAME |
{{DESCRIPTION}} | "Semantic search" | From init.py or user input |
{{SERVER_HOST}} | "0.0.0.0" | User input or default |
{{SERVER_PORT}} | "8000" | User input or default |
User request: "Add FastAPI to my CLI project"
Detected:
User provides:
Result:
Files added:
myproject/server.pymyproject/config.pyconfig.example.json.env.exampleFiles modified:
myproject/cli.py (added server command)pyproject.toml (added fastapi, uvicorn, etc.)Usage:
myproject --help # Shows all subcommands
myproject server # Starts FastAPI on port 8080
myproject server --reload # Development mode with auto-reload
The skill should be safe to run multiple times:
server.py exists before creatingIf the existing CLI uses argparse, the skill will convert it to Click. This is necessary for subcommands. The conversion:
server subcommandWarn the user about this change.
If the default port is occupied, user can override:
myproject server --port 8001
Server requires config.json. If missing:
cp config.example.json config.json
Edit values as needed.
uv runAfter adding FastAPI, users typically:
config.json with their specific configurationserver.py/plinth:macos-launchd-serviceWorks well with:
/plinth:python-project-init - Creates the base project first/plinth:macos-launchd-service - Auto-start the server/plinth:session-wrapup - Document the addition