API Testing
Purpose
Verify backend API contracts, validation, authorization, error handling, and integration behavior.
Project Stack
FastAPI, pytest/project test infrastructure, HTTP clients.
Operating Principles
- Test successful responses.
- Test invalid input.
- Test unauthenticated access.
- Test unauthorized access.
- Test missing resources.
- Test conflicts where applicable.
- Verify response schemas.
- Verify important side effects.
- Test transaction behavior for multi-step operations.
- Keep tests independent and deterministic.
- Do not weaken assertions merely to make a test pass.
Required Workflow
- Identify the endpoint contract.
- Inspect existing API tests.
- Create representative fixtures.
- Test happy path.
- Test validation failures.
- Test authentication and authorization.
- Test resource-not-found and conflict cases.
- Verify database side effects.
- Run the complete relevant API test set.
- Inspect failures using actual response and server evidence.
Evidence Rules
Use the strongest available evidence in this order:
- Runtime behavior
- Automated test results
- Type checking, linting, and build results
- Installed package/source behavior
- Official framework or library documentation
- Repository configuration
- Static code inspection
- General model knowledge
Never report an assumption as a verified result.
Tool Selection
- Use Filesystem MCP for repository exploration and file inspection.
- Use Context7 for current, version-specific library/framework documentation.
- Use Fetch when official documentation or public web resources need to be retrieved.
- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.
- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.
- Prefer the smallest tool set that establishes reliable evidence.
Failure Handling
When something fails:
- Reproduce the failure.
- Capture the exact error.
- Identify the failing layer.
- Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.
- Research uncertain behavior using authoritative sources.
- Apply the smallest appropriate fix.
- Reproduce the original failure again.
- Run regression checks.
- Inspect the final diff.
Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.
Security
- Never expose secrets.
- Never commit credentials.
- Treat all external input as untrusted.
- Preserve authentication and authorization boundaries.
- Avoid leaking internal implementation details through errors.
- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.
Completion Criteria
A task using this skill is complete only when:
- The requested behavior is implemented.
- Existing project conventions are preserved.
- Relevant static checks pass.
- Relevant tests pass or their absence is explicitly reported.
- Browser verification is performed when the task affects user-facing behavior.
- Security implications have been considered.
- The final diff has been inspected.
- Verified facts are clearly distinguished from assumptions or remaining uncertainty.
1---2name: api-testing3description: API Testing4---5# API Testing67## Purpose89Verify backend API contracts, validation, authorization, error handling, and integration behavior.1011## Project Stack1213FastAPI, pytest/project test infrastructure, HTTP clients.1415## Operating Principles16171. Test successful responses.182. Test invalid input.193. Test unauthenticated access.204. Test unauthorized access.215. Test missing resources.226. Test conflicts where applicable.237. Verify response schemas.248. Verify important side effects.259. Test transaction behavior for multi-step operations.2610. Keep tests independent and deterministic.2711. Do not weaken assertions merely to make a test pass.2829## Required Workflow30311. Identify the endpoint contract.322. Inspect existing API tests.333. Create representative fixtures.344. Test happy path.355. Test validation failures.366. Test authentication and authorization.377. Test resource-not-found and conflict cases.388. Verify database side effects.399. Run the complete relevant API test set.4010. Inspect failures using actual response and server evidence.4142## Evidence Rules4344Use the strongest available evidence in this order:45461. Runtime behavior472. Automated test results483. Type checking, linting, and build results494. Installed package/source behavior505. Official framework or library documentation516. Repository configuration527. Static code inspection538. General model knowledge5455Never report an assumption as a verified result.5657## Tool Selection5859- Use Filesystem MCP for repository exploration and file inspection.60- Use Context7 for current, version-specific library/framework documentation.61- Use Fetch when official documentation or public web resources need to be retrieved.62- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.63- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.64- Prefer the smallest tool set that establishes reliable evidence.6566## Failure Handling6768When something fails:69701. Reproduce the failure.712. Capture the exact error.723. Identify the failing layer.734. Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.745. Research uncertain behavior using authoritative sources.756. Apply the smallest appropriate fix.767. Reproduce the original failure again.778. Run regression checks.789. Inspect the final diff.7980Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.8182## Security8384- Never expose secrets.85- Never commit credentials.86- Treat all external input as untrusted.87- Preserve authentication and authorization boundaries.88- Avoid leaking internal implementation details through errors.89- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.9091## Completion Criteria9293A task using this skill is complete only when:9495- The requested behavior is implemented.96- Existing project conventions are preserved.97- Relevant static checks pass.98- Relevant tests pass or their absence is explicitly reported.99- Browser verification is performed when the task affects user-facing behavior.100- Security implications have been considered.101- The final diff has been inspected.102- Verified facts are clearly distinguished from assumptions or remaining uncertainty.