agentleFS
dperezcabreradperezcabrera/pico-skills/.claude/skills/add-controller/SKILL.md

add-controller

Skill4 starsChanged 4 months agoMITView on GitHub

Add a FastAPI controller with pico-fastapi. Use when creating REST API endpoints, WebSocket handlers, or HTTP routes.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a FastAPI controller for: $ARGUMENTS

    line 10
  2. Distinctive:

    Read the codebase to understand existing controllers and patterns, then create the controller.

    line 12

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add Controller

Create a FastAPI controller for: $ARGUMENTS

Read the codebase to understand existing controllers and patterns, then create the controller.

Basic Controller

@controller automatically applies @component(scope="request").

from pico_fastapi import controller, get, post, put, delete

@controller(prefix="/items", tags=["items"])
class ItemController:
    def __init__(self, service: ItemService):
        self.service = service

    @get("/")
    async def list_items(self, limit: int = 10, offset: int = 0):
        return await self.service.list(limit=limit, offset=offset)

    @get("/{item_id}")
    async def get_item(self, item_id: int):
        return await self.service.get(item_id)

    @post("/", status_code=201)
    async def create_item(self, data: ItemCreate):
        return await self.service.create(data)

    @put("/{item_id}")
    async def update_item(self, item_id: int, data: ItemUpdate):
        return await self.service.update(item_id, data)

    @delete("/{item_id}", status_code=204)
    async def delete_item(self, item_id: int):
        await self.service.delete(item_id)

WebSocket Endpoint

from pico_fastapi import controller, websocket

@controller(prefix="/ws")
class ChatController:
    def __init__(self, chat_service: ChatService):
        self.chat_service = chat_service

    @websocket("/chat")
    async def chat(self, ws):
        await ws.accept()
        async for message in ws.iter_text():
            response = await self.chat_service.process(message)
            await ws.send_text(response)

Custom App Configurer (Middleware)

from fastapi import FastAPI
from pico_ioc import component
from pico_fastapi import FastApiConfigurer

@component
class CorsConfigurer(FastApiConfigurer):
    priority = -10  # Negative = outer middleware

    def configure(self, app: FastAPI) -> None:
        from fastapi.middleware.cors import CORSMiddleware
        app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"])

Checklist

  • Controller with appropriate prefix and tags
  • Route methods with correct HTTP verbs and status codes
  • Request/response Pydantic models defined
  • Dependencies injected via constructor
  • Error handling for domain exceptions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.