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.zipInstalls 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 patternsKey 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
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:
- Gather endpoint requirements interactively
- Generate a view function in
paasta_tools/api/views/ - Register the route in
paasta_tools/api/api.py - Add Swagger 2.0 documentation to
swagger.json - Add OpenAPI 3.0 documentation to
oapi.yaml - Generate unit tests following PaaSTA conventions
- Run the OpenAPI code generator
- 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):
- Endpoint purpose: What does this endpoint do? (brief description)
- HTTP method: GET, POST, PUT, or DELETE?
- URL pattern: What's the URL path? (e.g.,
/v1/services/{service}/instances/{instance}/status) - Path parameters: What path parameters are needed? (e.g., service, instance, deploy_group)
- Query parameters: Any query parameters? (optional)
- Request body: Does this endpoint accept a request body? If yes, what fields?
- Response structure: What does the response look like? (e.g.,
{"status": "running", "count": 5}) - Error cases: What error scenarios should be handled? (e.g., 404 not found, 500 config error)
- View file: Which view file should contain this endpoint?
- Use existing:
service.py,instance.py,autoscaler.py, etc. - Or create new: provide filename
- Use existing:
- Utility functions: What existing utility functions from
paasta_tools/utils.pywill 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
Responsefrompyramid.responsefor explicit status codes - Import
ApiFailurefrompaasta_tools.api.views.exceptionfor error handling - All imports at the top of the file (no inline imports)
- Use
settings.soa_dirto 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:
- 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"
}
]
}
}
- 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:
- Add schema to
components/schemassection:
ResponseSchema:
description: Schema description
type: object
properties:
field:
type: string
description: Field description
required:
- field
- Add endpoint to
pathssection:
/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=Truefor patches - Use
spec=ClassNamefor 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
- Run the new tests:
.tox/py310-linux/bin/pytest tests/api/test_<view_file>.py::<test_name> -xvs
- 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
- 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
- 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→ 404KeyErrorfor missing config fields → 500ValueErrorfor 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:
- Summary of changes
- Test results
- Verification that pre-commit checks pass
- Suggested commit message following PaaSTA conventions
When not to use it
- →Implementing non-PaaSTA standard APIs
- →Adding experimental routes outside standard patterns
Prerequisites
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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| paasta-api-endpoint (this skill) | 2 | 6mo | Review | Beginner |
| fastapi-templates | 520 | 2mo | No flags | Intermediate |
| fastapi-pro | 79 | 4mo | No flags | Advanced |
| telegram-bot-builder | 106 | 6mo | Review | Intermediate |
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.
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.
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.
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.
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.
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.