# API Error Reproduction

> Troubleshoots API error issues: reproduce failures, trace error flows, correlate with releases, and fix root causes. Use when working with error reproduction, log analysis or when the user mentions error reproduction, log analysis.

- Skill: `opknock/api-error-reproduction` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-error-reproduction`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-error-reproduction/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-error-reproduction

---


Troubleshoots API error issues: reproduce failures, trace error flows, correlate with releases, and fix root causes.

## Agentic Workflow: Read -> Reason -> Act (api-error-reproduction)

You are **Api Error Reproduction** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — backend context for `api-error-reproduction`
- Domain: Troubleshoots API error issues: reproduce failures, trace error flows, correlate with releases, and fix root causes.
- **error-reproduction**: Reproduce error conditions with curl and scenario payloads — `curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/js`
- **log-analysis**: Correlate errors in logs and metrics to find root causes — `node -e "console.log('trace_id=abc123 err=DB_TIMEOUT op=users.list')"`
- Check `knowledge` and `prerequisites: node.js, python, openapi`

### 2. Reason — think for `api-error-reproduction`
- For `error-reproduction`: Reproduce error conditions with curl and scenario payloads — decide which checks to run
- For `log-analysis`: Correlate errors in logs and metrics to find root causes — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-error-reproduction` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-error-reproduction:fcabb7cd`

# API Error (Troubleshooting)

Diagnoses and fixes error-handling problems in running APIs.

## When to Use
- Unexplained 5xx spikes
- Inconsistent error bodies in production
- Errors only appear after deploys

## Real Commands

```bash
# Reproduce
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'
curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'

# Logs
kubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20

# Metrics
curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | head

# Health
curl -s http://localhost:3000/health -w '\n%{http_code}'
```

## Root Cause Checklist
- Is the error body consistent? (format issue)
- When did the spike start? (release correlation)
- Is a dependency failing? (timeouts/upstream)

## Testing
Turn each reproduction into an automated regression test.

## Best Practices
- Add trace IDs to every error response
- Alert on rate deltas, not raw counts

## Capabilities

### error-reproduction
Reproduce error conditions with curl and scenario payloads

**Parameters:**
- `url` (string): Endpoint to probe
- `method` (string): HTTP method

**Commands:**
- `curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'`
- `curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'`
- `curl -s -X PUT http://localhost:3000/api/users/1 -H 'Content-Type: application/json' -d '{"email":"x@y.z"}' -w '\n%{http_code}'`
- `curl -s -X DELETE http://localhost:3000/api/users/1 -w '\n%{http_code}'`
- `curl -s -H 'Authorization: Bearer invalid' http://localhost:3000/api/me -w '\n%{http_code}'`

**Examples:**
- curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'
- curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'
- curl -s -H 'Authorization: Bearer invalid' http://localhost:3000/api/me -w '\n%{http_code}'

### log-analysis
Correlate errors in logs and metrics to find root causes

**Parameters:**
- `pattern` (string): Log filter pattern
- `lines` (string): Number of log lines

**Commands:**
- `node -e "console.log('trace_id=abc123 err=DB_TIMEOUT op=users.list')"`
- `curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | head`
- `kubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20`
- `node -e "const r=require('os');console.log('pid',process.pid,'load',r.loadavg()[0])"`
- `curl -s http://localhost:3000/health -w '\n%{http_code}'`

**Examples:**
- kubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20
- curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | head
- curl -s http://localhost:3000/health -w '\n%{http_code}'

## References
- [kubectl Logs](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_logs/)
- [Prometheus Metrics](https://prometheus.io/docs/instrumenting/writing_exporters/)

