Skill metadata
Reference: full SKILL.md
The following is the complete skill definition that Mibyan loads when this skill is triggered. This is what the agent sees as instructions when the skill is active.
API Testing & Debugging
Drive REST and GraphQL diagnosis through Mibyan tools —terminal for curl, execute_code for Python requests, web_extract for vendor docs. Isolate the failing layer before guessing at the fix.
When to Use
- API returns unexpected status or body
- Auth fails (401/403 after token refresh, OAuth, API key)
- Works in Postman but fails in code
- Webhook / callback integration debugging
- Building or reviewing API integration tests
- Rate limiting or pagination issues
Core Principle
Isolate the layer, then fix. A 200 OK can hide broken data. A 500 can mask a one-character auth typo. Walk the chain in order; never skip a step.5-Minute Quickstart
REST via terminal
GraphQL via terminal
errors field regardless of status code:
Python (requests) via execute_code
Layered Debug Flow
Step 1 — Connectivity
Step 1.5 — Timeouts
Distinguish can’t reach from reaches but slow:requests has no default and will hang forever:
time_connect is network/firewall; high time_starttransfer with low time_connect is a slow server.
Step 2 — TLS/SSL
-k only for ad-hoc debug, never in code.
Step 3 — Authentication
- Token expired? (
expclaim in JWT) - Right scheme? Bearer vs Basic vs Token vs
X-Api-Key - Right environment? Staging key on prod is a classic
- API key in header vs query param (
?api_key=…)?
Step 4 — Request Format
Step 5 — Response Parsing
Always inspect content-type before calling.json():
Step 6 — Semantic Validation
Parsed cleanly — but is the data correct?- Does
"status": "active"mean what your code thinks? - ID in response matches the one requested?
- Timestamps in expected timezone?
- Pagination returning all results, or just page 1?
HTTP Status Playbook
401 Unauthorized — credentials missing or invalid
Authorizationheader actually present? (curl -vto confirm)- Token correct and unexpired?
- Right auth scheme? (
BearervsBasicvsToken) - Some APIs use query param (
?api_key=…) instead of header.
403 Forbidden — authenticated but not authorized
- Token has the required scopes/permissions?
- Resource owned by a different account?
- IP allowlist blocking you?
- CORS in browser? (check
Access-Control-Allow-Origin)
404 Not Found — resource doesn’t exist or URL is wrong
- Path correct? (trailing slash, typo, version prefix)
- Resource ID exists?
- Right API version (
/v1/vs/v2/)? - Right base URL (staging vs prod)?
409 Conflict — state collision
- Resource already exists (duplicate create)?
- Stale
ETag/If-Match? - Concurrent modification by another process?
422 Unprocessable Entity — valid JSON, invalid data
The error body usually names the bad fields. Check:- Field types (string vs int, date format)
- Required vs optional
- Enum values inside the allowed set
429 Too Many Requests — rate limited
CheckRetry-After and X-RateLimit-* headers. Exponential backoff:
5xx — server-side, usually not your fault
- 500 — server bug. Capture correlation ID, file with provider.
- 502 — upstream down. Backoff + retry.
- 503 — overloaded / maintenance. Check status page.
- 504 — upstream timeout. Reduce payload or raise timeout.
Pagination & Idempotency
Pagination. Verify you’re getting all results. Look fornext_cursor, next_page, total_count. Two patterns:
- Offset (
?limit=100&offset=200) — simple, can skip items if data shifts. - Cursor (
?cursor=abc123) — preferred for live or large datasets.
Idempotency-Key: <uuid> so retries don’t double-charge / double-create. Mandatory for payments and orders.
Contract Validation
Catch schema drift before it hits production:Correlation IDs
Always capture the provider’s request ID — fastest path to vendor support:Regression Test Template
Drop this intotests/ and run via terminal('pytest tests/test_api_smoke.py -v'):
Security
Token handling
- Never log full tokens. Redact:
Bearer <REDACTED>. - Never hardcode tokens in scripts. Read from env (
os.environ["API_TOKEN"]) or${mibyan_HOME:-~/.mibyan}/.env. - Rotate immediately if a token surfaces in logs, error messages, or git history.
Safe logging
Leak checklist
- Credentials in URLs. API keys in query strings end up in server logs, browser history, referrer headers — use headers.
- PII in error responses.
404 on /users/123shouldn’t reveal whether the user exists (enumeration). - Stack traces in prod. 500s shouldn’t leak file paths, framework versions.
- Internal hostnames/IPs.
10.x.x.x,internal-api.corp.localin error bodies. - Tokens echoed back. Some APIs include the auth token in error details. Verify they don’t.
- Verbose
Server/X-Powered-By. Stack-info leaks. Note for security review.
Mibyan Tool Patterns
terminal — for curl, dig, openssl
execute_code — for multi-step Python flows
When debugging spans auth → fetch → paginate → validate, useexecute_code. Variables persist for the script, results print to stdout, no risk of token spam in your context:
web_extract — for vendor API docs
Pull the spec for the endpoint you’re debugging instead of guessing:delegate_task — for full CRUD test sweeps
Output Format
When reporting findings:Related
systematic-debugging— once the failing API layer is isolated, root-cause your codetest-driven-development— write the regression test before shipping the fix

