PA

paasta-api-endpoint

Automates the boilerplate creation of new API endpoints in PaaSTA, including documentation and tests.

Install

mkdir -p .claude/skills/paasta-api-endpoint && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2345" && unzip -o skill.zip -d .claude/skills/paasta-api-endpoint && rm skill.zip

Installs to .claude/skills/paasta-api-endpoint

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Automates the creation of new PaaSTA API endpoints following established patterns
81 charsno explicit “when” trigger
Beginner

Key capabilities

  • Generates standardized API view functions
  • Automatically registers routes in central API registry
  • Updates Swagger 2.0 and OpenAPI 3.0 documentation
  • Scaffolds consistent unit test files

How it works

Uses a guided interactive prompt to scaffold boilerplate code files and update existing API configuration files.

Inputs & outputs

You give it
Endpoint requirements (method, path, body, params)
You get back
Implemented route, registered endpoint, updated docs, and generated tests

When to use paasta-api-endpoint

  • Create new GET/POST API endpoints
  • Generate OpenAPI/Swagger documentation
  • Scaffold boilerplate code for API routes

About this skill

PaaSTA API Endpoint Generator

Description

Automates the creation of new PaaSTA API endpoints following established patterns. This skill guides you through adding a new endpoint to the PaaSTA API, including view function, route registration, Swagger/OpenAPI documentation, and comprehensive tests.

Usage

/paasta-api-endpoint

What This Skill Does

This skill will:

  1. Gather endpoint requirements interactively
  2. Generate a view function in paasta_tools/api/views/
  3. Register the route in paasta_tools/api/api.py
  4. Add Swagger 2.0 documentation to swagger.json
  5. Add OpenAPI 3.0 documentation to oapi.yaml
  6. Generate unit tests following PaaSTA conventions
  7. Run the OpenAPI code generator
  8. Run tests to verify the implementation

When to Use This Skill

Use this skill when you need to:

  • Add a new GET/POST/PUT/DELETE endpoint to the PaaSTA API
  • Ensure consistency with existing API patterns
  • Automatically generate boilerplate code and documentation
  • Get comprehensive test coverage from the start

Instructions

When this skill is invoked, follow these steps:

Step 1: Gather Requirements

Ask the user the following questions (use AskUserQuestion tool for better UX):

  1. Endpoint purpose: What does this endpoint do? (brief description)
  2. HTTP method: GET, POST, PUT, or DELETE?
  3. URL pattern: What's the URL path? (e.g., /v1/services/{service}/instances/{instance}/status)
  4. Path parameters: What path parameters are needed? (e.g., service, instance, deploy_group)
  5. Query parameters: Any query parameters? (optional)
  6. Request body: Does this endpoint accept a request body? If yes, what fields?
  7. Response structure: What does the response look like? (e.g., {"status": "running", "count": 5})
  8. Error cases: What error scenarios should be handled? (e.g., 404 not found, 500 config error)
  9. View file: Which view file should contain this endpoint?
    • Use existing: service.py, instance.py, autoscaler.py, etc.
    • Or create new: provide filename
  10. Utility functions: What existing utility functions from paasta_tools/utils.py will be used?

Step 2: Generate View Function

Create the view function following this template:

@view_config(route_name="<route_name>", request_method="<METHOD>", renderer="json")
def <function_name>(request):
    """<Docstring describing what this endpoint does>."""
    # Extract parameters from request
    param1 = request.swagger_data.get("param1")
    param2 = request.swagger_data.get("param2")
    soa_dir = settings.soa_dir

    try:
        # Call utility functions to get data
        result = some_utility_function(param1, param2, soa_dir=soa_dir)

        # Build response
        response_body = {"key": result}
        return Response(json_body=response_body, status_code=200)

    except SpecificException as e:
        raise ApiFailure(str(e), 404)

    except AnotherException as e:
        raise ApiFailure(str(e), 500)

Important conventions:

  • Import Response from pyramid.response for explicit status codes
  • Import ApiFailure from paasta_tools.api.views.exception for error handling
  • All imports at the top of the file (no inline imports)
  • Use settings.soa_dir to get the SOA configuration directory
  • Return 200 for success, 404 for not found, 500 for server errors
  • Always include proper error handling with try/except

Step 3: Register Route

Add route registration to paasta_tools/api/api.py:

config.add_route(
    "<route_name>",
    "<url_pattern>",
)

Find the appropriate location (routes are loosely grouped by functionality).

Step 4: Add Swagger 2.0 Documentation

Update paasta_tools/api/api_docs/swagger.json:

  1. Add endpoint definition to "paths" section:
"/path/{param}": {
    "get": {
        "responses": {
            "200": {
                "description": "Success description",
                "schema": {
                    "$ref": "#/definitions/ResponseSchema"
                }
            },
            "404": {
                "description": "Not found description"
            }
        },
        "summary": "Brief summary",
        "operationId": "operation_id",
        "tags": ["service"],
        "parameters": [
            {
                "in": "path",
                "description": "Parameter description",
                "name": "param",
                "required": true,
                "type": "string"
            }
        ]
    }
}
  1. Add response schema to "definitions" section if needed:
"ResponseSchema": {
    "description": "Schema description",
    "type": "object",
    "properties": {
        "field": {
            "type": "string",
            "description": "Field description"
        }
    },
    "required": ["field"]
}

Nullable fields in Swagger 2.0: For fields that can be null, use the x-nullable extension:

"optional_field": {
    "type": "string",
    "description": "This field can be null",
    "x-nullable": true
}

Step 5: Add OpenAPI 3.0 Documentation

Update paasta_tools/api/api_docs/oapi.yaml:

  1. Add schema to components/schemas section:
ResponseSchema:
  description: Schema description
  type: object
  properties:
    field:
      type: string
      description: Field description
  required:
    - field
  1. Add endpoint to paths section:
/path/{param}:
  get:
    operationId: operation_id
    parameters:
    - description: Parameter description
      in: path
      name: param
      required: true
      schema:
        type: string
    responses:
      "200":
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseSchema'
        description: Success description
      "404":
        description: Not found description
    summary: Brief summary
    tags:
    - service

Nullable fields in OpenAPI 3.0: For fields that can be null, use the nullable property:

optional_field:
  type: string
  description: This field can be null
  nullable: true

Step 6: Generate Unit Tests

Create comprehensive unit tests in tests/api/test_<view_file>.py:

Test conventions:

  • Use context manager form of mocking (with mock.patch(...) as mock_name:)
  • Always use autospec=True for patches
  • Use spec=ClassName for Mock objects that represent class instances
  • Test success case (200 response)
  • Test all error cases (404, 500, etc.)
  • Use descriptive test names: test_<function_name>_<scenario>
  • Use descriptive docstrings

Test template:

def test_endpoint_name_success():
    """Test successful response."""
    with mock.patch(
        "paasta_tools.api.views.<module>.<function>", autospec=True
    ) as mock_function:
        mock_function.return_value = "expected_value"

        request = testing.DummyRequest()
        request.swagger_data = {"param": "value"}

        response = endpoint_function(request)
        assert response.status_code == 200
        assert response.json_body == {"key": "expected_value"}


def test_endpoint_name_not_found():
    """Test 404 when resource not found."""
    with mock.patch(
        "paasta_tools.api.views.<module>.<function>", autospec=True
    ) as mock_function:
        mock_function.side_effect = SomeException("not found")

        request = testing.DummyRequest()
        request.swagger_data = {"param": "value"}

        with pytest.raises(ApiFailure) as exc_info:
            endpoint_function(request)
        assert exc_info.value.msg == "not found"
        assert exc_info.value.err == 404

Step 7: Generate OpenAPI Client Code

Run the code generator:

make openapi-codegen

This regenerates the Python client code in paasta_tools/paastaapi/ based on the updated oapi.yaml.

Step 8: Run Tests and Validation

  1. Run the new tests:
.tox/py310-linux/bin/pytest tests/api/test_<view_file>.py::<test_name> -xvs
  1. Run mypy type checking:
.tox/py310-linux/bin/mypy paasta_tools/api/views/<view_file>.py
.tox/py310-linux/bin/mypy tests/api/test_<view_file>.py
  1. Run pre-commit checks:
.tox/py310-linux/bin/pre-commit run --files paasta_tools/api/views/<view_file>.py tests/api/test_<view_file>.py paasta_tools/api/api.py paasta_tools/api/api_docs/swagger.json paasta_tools/api/api_docs/oapi.yaml
  1. Stage the generated files:
git add paasta_tools/paastaapi/

Step 9: Summary

Provide a summary of:

  • Files created/modified
  • Endpoint URL and method
  • Test coverage (number of tests added)
  • Any manual steps needed

Example Reference

See the container image endpoint implementation as a reference:

  • View: paasta_tools/api/views/service.py:43-63
  • Route: paasta_tools/api/api.py:166-169
  • Tests: tests/api/test_service.py:63-143

Common Patterns

Error Handling

  • NoDeploymentsAvailable → 404
  • KeyError for missing config fields → 500
  • ValueError for invalid input → 400
  • Generic exceptions → 500

Response Patterns

  • Single value: {"field_name": "value"}
  • List: {"items": [...]}
  • Complex object: Use TypedDict schema

Utility Functions

Common utilities are usually found in paasta_tools/utils.py

Notes

  • Atomic commits: Each endpoint should be a single, self-contained commit
  • Bisectable history: All tests must pass after adding the endpoint
  • Type safety: Use type hints and ensure mypy passes
  • Documentation: Keep Swagger and OpenAPI docs in sync
  • Testing: Aim for 100% coverage of the new endpoint

Skill Exit

After completing all steps successfully, provide the user with:

  1. Summary of changes
  2. Test results
  3. Verification that pre-commit checks pass
  4. Suggested commit message following PaaSTA conventions

When not to use it

  • Implementing non-PaaSTA standard APIs
  • Adding experimental routes outside standard patterns

Prerequisites

PaaSTA codebase access

Limitations

  • Restricted to PaaSTA architecture patterns
  • Requires manual definition of complex endpoint logic

How it compares

It enforces architectural uniformity across all API endpoints automatically, avoiding manual file creation errors.

Compared to similar skills

paasta-api-endpoint side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
paasta-api-endpoint (this skill)26moReviewBeginner
fastapi-templates5202moNo flagsIntermediate
fastapi-pro794moNo flagsAdvanced
telegram-bot-builder1066moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

5201,086

fastapi-pro

sickn33

Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.

79181

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

billing-automation

wshobson

Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

1098

home-assistant-integration-knowledge

home-assistant

Everything you need to know to build, test and review Home Assistant Integrations. If you're looking at an integration, you must use this as your primary reference.

863

Search skills

Search the agent skills registry