ワンクリックで
gen-contract-test
Generate a contract test skeleton for a backend or frontend service following TDD Article III
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generate a contract test skeleton for a backend or frontend service following TDD Article III
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Scan a project, interview the user about unknowns, and generate a complete AI harness (Copilot + Claude + Opencode) with Constitutional Articles I–IX
Scan a project, interview the user about unknowns, and generate a complete AI harness (Copilot + Claude + Opencode) with Constitutional Articles I–IX
Scaffold a {{DB_PROVIDER}} SQL migration compliant with sql-standards.md
Scan E2E tests for no-op assertions and overly permissive checks that provide false confidence
Triage hardcoded dates, AsyncMock misuse, cross-tier truncates, and envelope assertion bugs in the test suite
Scan a project, interview the user about unknowns, and generate a complete AI harness (Copilot + Claude + Opencode) with Constitutional Articles I–IX
| name | gen-contract-test |
| description | Generate a contract test skeleton for a backend or frontend service following TDD Article III |
| user-invocable | true |
| disable-model-invocation | true |
| arguments | [{"name":"target","description":"Service or module to test (e.g., 'analytics-service', 'auth/login')","required":true},{"name":"stack","description":"backend or frontend (default: backend)","required":false}] |
Scaffold a contract test that follows the project's TDD mandate (Article III) and existing test patterns.
Based on the target argument, locate the service/module:
{{BACKEND_PATH}}/src/libs/ and {{BACKEND_PATH}}/app/ for the matching service, router, or module.{{FRONTEND_PATH}}/src/services/ and {{FRONTEND_PATH}}/src/contracts/ for the matching service interface.Read the target's source code to understand its public API surface.
Search {{BACKEND_PATH}}/tests/contract/ or {{FRONTEND_PATH}}/tests/contract/ for existing tests. Report what's covered and only scaffold uncovered endpoints.
Create {{BACKEND_PATH}}/tests/contract/test_{target_snake_case}_contract.py:
"""
Contract test for {Target Description}
Validates externally visible interface/schema boundary.
"""
import pytest
from fastapi import status
from httpx import AsyncClient
pytestmark = pytest.mark.asyncio
class Test{TargetPascalCase}Contract:
"""{Target} contract compliance tests"""
async def test_{endpoint}_success_response_schema(self, client: AsyncClient):
"""Test successful response returns correct schema"""
response = await client.{method}("{path}", json={...})
assert response.status_code == status.HTTP_{EXPECTED}
data = response.json()
# Validate field presence and types for the success envelope.
...
async def test_{endpoint}_validation_errors(self, client: AsyncClient):
"""Test input validation returns Article IV error envelope"""
response = await client.{method}("{path}", json={invalid_input})
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
data = response.json()
assert "error" in data
assert "code" in data["error"]
assert "message" in data["error"]
async def test_{endpoint}_unauthorized(self, client: AsyncClient):
"""Test unauthenticated access returns 401"""
response = await client.{method}("{path}")
assert response.status_code == status.HTTP_401_UNAUTHORIZED
data = response.json()
assert "error" in data or "detail" in data
Create {{FRONTEND_PATH}}/tests/contract/{target-kebab-case}-contract.test.ts:
/**
* {Target} Contract Test - Constitutional Compliance
* Tests {Target} interface compliance.
*
* CRITICAL: This test MUST FAIL initially (RED phase of TDD)
*/
import { describe, it, expect, beforeEach } from 'vitest'
describe('{Target} Contract Compliance', () => {
describe('Service Interface', () => {
it('should implement required methods', () => { ... })
it('should return correct response shape', async () => { ... })
})
describe('Error Handling Compliance', () => {
it('should handle invalid input gracefully', async () => { ... })
it('should handle network errors gracefully', async () => { ... })
})
})
Do NOT include:
After generating, run the test to confirm it fails:
cd {{BACKEND_PATH}} && {{TEST_BACKEND_CMD}} tests/contract/test_{name}_contract.py -vcd {{FRONTEND_PATH}} && {{TEST_FRONTEND_CMD}} tests/contract/test-{name}-contract.test.tsReport the failure output. This confirms the RED phase of TDD is working correctly.
@pytest.mark.skip or @pytest.mark.xfail.it.skip, test.skip, describe.skip, .todo, xit, or xdescribe.test_{name}_contract.py (backend), {name}-contract.test.ts (frontend).