Skip to main content

Convert FastAPI apps and OpenAPI specs into CLI tools and AI agent skills (SKILL.md)

Project description

fastapi-to-skill

Convert any FastAPI app or OpenAPI spec into a CLI + SKILL.md for AI agents — in one command.

From API Chaos to Agent Skills

pip install fastapi-to-skill
fastapi-to-skill generate main:app -o ./skills/myapi/

One Command. Agent-Ready.


The Problem

A year ago, APIs served frontends. Developers read docs, learned the UI, wrote integration code.

Now APIs serve AI agents. And agents don't read docs — they read skill files.

If your product has no SKILL.md, agents can't discover it, can't use it, and will use a competitor that does have one.

The new distribution channel is not the App Store. It's the agent skill registry.


The Solution

fastapi-to-skill takes your existing FastAPI app (or any OpenAPI spec) and generates everything an AI agent needs to use your API:

Output What it is
cli.py Standalone Typer CLI — one command per endpoint, no deps on this tool
SKILL.md Universal skill file for Claude Code, OpenClaw, and any Agent Skills-compatible platform
openapi.json Copy of the spec for reference
pyproject.toml Install the CLI as a named command (pip install -e .)

No MCP server. No AI costs. No infrastructure. Just files.


Why FastAPI?

FastAPI auto-generates an OpenAPI spec from your Python type hints. You write:

@app.post("/tasks")
def create_task(task: Task) -> TaskOut:
    ...

FastAPI gives you a full API contract for free — endpoints, parameters, request bodies, types, auth schemes. Always in sync with your code. No manual YAML.

fastapi-to-skill reads that spec with one call to app.openapi() and turns it into agent-ready tools. The whole pipeline is: your type hints → OpenAPI spec → CLI + SKILL.md.

Big thanks to @sebastianramirez for building FastAPI + Typer — an ecosystem where this kind of tooling is possible in a weekend.


Quick Start

Install

pip install fastapi-to-skill
# or for global CLI tools (recommended)
pipx install fastapi-to-skill

Generate from a FastAPI app

# main.py
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI(title="Task Manager API")

class Task(BaseModel):
    title: str
    done: bool = False

@app.post("/tasks")
def create_task(task: Task):
    ...

@app.get("/tasks/{task_id}")
def get_task(task_id: int):
    ...
fastapi-to-skill generate main:app -o ./skills/task-manager/

Output:

skills/task-manager/
├── cli.py          ← standalone CLI
├── SKILL.md        ← agent skill file
├── openapi.json    ← spec copy
└── pyproject.toml  ← install as named command

Install and use the generated CLI

cd skills/task-manager/
pip install -e .

# Run without a command — shows SKILL.md (AI-friendly)
task-manager-api

# List all commands
task-manager-api --help

# See body schema for any command
task-manager-api create-task --help
# Body fields:
#   title: string (required)
#   done: boolean  default: False

# Call the API
task-manager-api create-task --body '{"title": "Ship the feature"}'
task-manager-api get-task 1
task-manager-api list-tasks --done false

# Search commands by keyword
task-manager-api search "task"

Generate from an OpenAPI spec file

fastapi-to-skill generate --spec openapi.json -o ./skills/myapi/
fastapi-to-skill generate --spec openapi.yaml -o ./skills/myapi/

Choose target platform

# Claude Code (default)
fastapi-to-skill generate main:app -t claude-code

# OpenClaw
fastapi-to-skill generate main:app -t openclaw

Other options

# Preview without writing files
fastapi-to-skill generate main:app --dry-run

# Validate spec only
fastapi-to-skill generate main:app --validate

# Override base URL
fastapi-to-skill generate main:app --base-url https://api.myapp.com

Authentication

Set your credentials via environment variables before calling any command:

# API key
export MYAPI_API_KEY="sk-your-key"

# Bearer token
export MYAPI_TOKEN="your-token"

# Custom base URL
export MYAPI_BASE_URL="https://api.myapp.com"

The env var prefix is derived from your API title automatically.


How the SKILL.md works

When an AI agent encounters your CLI, it runs:

task-manager-api          # reads SKILL.md, understands the API
task-manager-api --help   # sees all available commands
task-manager-api create-task --help  # sees body schema

No human needed. The agent discovers capabilities, reads the contract, and starts calling commands.

The SKILL.md follows the Agent Skills open standard — compatible with Claude Code, OpenClaw, and any platform that supports it.


License

MIT


Built on FastAPI + Typer by Sebastian Ramirez.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_to_skill-0.1.5.tar.gz (3.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_to_skill-0.1.5-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_to_skill-0.1.5.tar.gz.

File metadata

  • Download URL: fastapi_to_skill-0.1.5.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for fastapi_to_skill-0.1.5.tar.gz
Algorithm Hash digest
SHA256 041044ba434934b2694ce55b1e6b9ef59f52469329c2b77d658b5a2e6635b1be
MD5 1b81fcf11f0a8c99f3b2f16d8f9cd355
BLAKE2b-256 1e142e543bcec1a1f2c3c6acc36cbf023a3956a427806ad1aaf68ab8b33ad8b2

See more details on using hashes here.

File details

Details for the file fastapi_to_skill-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_to_skill-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ac8a50f5ad6b3a46a712d78029276c5a06f49a7622ed8427dbdd887e5d3aff40
MD5 577f335cc32e84412c5e6b8cd475fdfa
BLAKE2b-256 7274e45f3cab59d9627456e2d2fb1f4f006d4e9ed3ee470ad82d1cabf0b50f5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page