Agent skill
sdk-generator
Autonomous SDK generator that discovers API endpoints from a live website or HAR archive, plans and builds typed SDKs in multiple languages, and continuously updates them as the API evolves. Use this skill whenever the user wants to reverse-engineer an API, generate client SDKs from observed traffic, build API wrappers from HAR files, create typed clients from web service exploration, or keep an SDK in sync with a changing API. Also trigger when the user mentions "SDK generation", "API client from HAR", "reverse engineer API", "auto-generate SDK", "crawl API and build client", or any variation of turning observed HTTP traffic into usable code libraries.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/sdk-generator
SKILL.md
SDK Generator
An autonomous skill that discovers API surfaces from live websites or HAR archives, plans SDK functions with LLM-assisted review, generates typed SDKs in multiple languages with full test suites, validates everything end-to-end, and manages the entire lifecycle through Git — including continuous updates when the upstream API changes.
Quick Reference
| Phase | What Happens | Reference |
|---|---|---|
| Discovery | Crawl site or parse HAR to find endpoints | references/discovery.md |
| Planning | Design SDK functions, get LLM peer review | references/planning.md |
| Generation | Implement SDK code per language target | references/generation.md |
| Testing | Unit tests, mocks, e2e validation, auto-fix | references/testing.md |
| Git Workflow | Branching, commits, PRs, versioning | references/git-workflow.md |
| Update Cycle | Re-crawl, diff, patch, re-test | references/update-cycle.md |
Prerequisites
Before starting, verify the following tools are available:
# Required
git --version
python3 --version
node --version
npm --version
# Install if missing
pip install requests httpx pydantic pytest pytest-asyncio respx --break-system-packages
npm install -g typescript jest ts-jest @types/jest axios
# Optional: for browser-based login during authenticated discovery
pip install playwright --break-system-packages
playwright install chromium
Workflow Overview
Phase 0: Initialize Project
- Create the SDK repository structure (see
references/repo-structure.md) - Initialize Git with
mainbranch and proper.gitignore - Set up language-specific project scaffolding (pyproject.toml, package.json, etc.)
- Create initial commit:
chore: initialize SDK project scaffold
Phase 1: API Discovery
Read references/discovery.md and agents/discovery.md for the full procedure.
Two entry paths, same output:
Path A — Live Website:
- Accept a base URL from the user
- Resolve authentication credentials (see below)
- Use browser automation or HTTP crawling to navigate the site
- Intercept and record all API calls (XHR/fetch requests)
- Capture: method, URL pattern, headers, query params, request body, response body, status codes
- Identify authentication patterns (Bearer tokens, API keys, cookies, OAuth flows)
Path B — HAR Archive:
- Accept a .har file from the user
- Parse all entries, filtering to API-like requests (JSON responses, REST patterns)
- Extract the same data points as Path A
- Detect auth patterns from captured headers, then redact all sensitive values
- Group by logical endpoint (normalize URL path parameters)
Authentication: If the target site requires authentication, credentials can be
provided through multiple channels (see agents/discovery.md for full details):
| Method | Example |
|---|---|
| Inline in prompt | Crawl https://app.example.com with bearer token: "eyJ..." |
| Environment variables | SDK_GEN_AUTH_TOKEN, SDK_GEN_AUTH_COOKIE, SDK_GEN_AUTH_HEADER_NAME/VALUE |
| Browser login (Playwright) | Agent opens a browser, user or automation completes login, agent extracts session |
| MCP browser server | If available, use browser MCP tools for login and credential extraction |
For OAuth/SSO flows that require user interaction (consent screens, MFA), the agent launches a visible browser window and guides the user through the login. After login completes, session cookies and tokens are extracted automatically.
Inline credentials take precedence over env vars. Browser login is used as a fallback when no static credentials are available.
Output: An api-surface.json file containing every discovered endpoint with:
- Method + URL pattern (with path params identified like
/users/{id}) - Request/response schemas (inferred JSON schemas)
- Required headers and auth patterns (with credential values redacted)
- Observed status codes and error shapes
- Pagination patterns if detected
Phase 2: Function Planning
Read references/planning.md for the full procedure.
This is the most critical phase. Every API endpoint becomes a planned SDK function.
-
Generate the plan: For each endpoint in
api-surface.json, produce:- Function name (language-idiomatic:
snake_casefor Python,camelCasefor TS/JS) - Parameter list with types (inferred from request schema)
- Return type (inferred from response schema)
- Error handling strategy
- Whether it needs pagination support
- Mock/stub specification for testing
- Function name (language-idiomatic:
-
LLM Peer Review: The plan is reviewed by a second LLM call acting as a senior API design reviewer. The reviewer checks for:
- Naming consistency and idiomaticness
- Missing error cases
- Type safety gaps
- Pagination/retry patterns that should be included
- Authentication flow correctness
- Breaking the plan into logical resource groupings (e.g.,
users.*,projects.*)
The review produces a structured critique with
approve,suggest, orrejectverdicts per function. Allrejectitems must be addressed before proceeding.suggestitems should be addressed but can be deferred with justification. -
Finalize: Merge review feedback into the plan. Save as
sdk-plan.json. -
Git: Commit the plan on a feature branch:
git checkout -b feat/initial-sdk-plan git add api-surface.json sdk-plan.json git commit -m "docs: add API surface discovery and SDK function plan"
Phase 3: SDK Generation
Read references/generation.md for the full procedure.
For each target language, generate the SDK from the approved plan:
-
Models/Types: Generate typed data classes / interfaces from response schemas
-
Client Class: Base HTTP client with auth, retry, error handling
-
Resource Modules: Group functions by resource (users, projects, etc.)
-
Each Function: Implement according to the plan — typed params, return types, docstrings, error handling, pagination wrappers where needed
-
Mocks & Stubs: For every function, generate:
- A mock response factory (returns realistic fake data matching the schema)
- A request stub that validates the outgoing request shape
- A fixture file with sample payloads
-
Git: Each resource module is committed separately:
git add python/src/promptql/users.py python/tests/test_users.py python/tests/mocks/users.py git commit -m "feat(python): add users resource with tests and mocks"
Phase 4: Testing
Read references/testing.md for the full procedure.
Testing happens in two layers, and bugs are fixed automatically:
Layer 1 — Unit Tests (offline):
- Every SDK function has unit tests using mocks/stubs
- Tests validate: correct HTTP method/URL, proper serialization of params, correct deserialization of responses, error handling paths
- Run:
pytest python/tests/andnpx jestfor TypeScript - If any test fails → read the error → fix the code → re-run → repeat until green
Layer 2 — End-to-End Tests (if live endpoint available):
- For each function, make a real API call (if safe — GET endpoints, read-only operations)
- Validate response matches expected schema
- Capture any discrepancies as schema refinements
- Run:
pytest python/tests/e2e/with--e2eflag - If any e2e test fails → diagnose whether it's an SDK bug or a schema inaccuracy → fix accordingly → re-run → repeat until green
Auto-fix loop:
MAX_FIX_ATTEMPTS = 5
for attempt in range(MAX_FIX_ATTEMPTS):
result = run_tests()
if result.all_passed:
break
for failure in result.failures:
diagnose(failure)
apply_fix(failure)
git commit -m "fix: {description of what was fixed}"
If after MAX_FIX_ATTEMPTS tests still fail, create a GitHub issue or TODO comment and continue with remaining endpoints. Do not block the entire SDK on one stubborn test.
Git: After all tests pass:
git add .
git commit -m "test: all unit and e2e tests passing"
git checkout main
git merge feat/initial-sdk-plan --no-ff -m "feat: initial SDK release"
git tag v0.1.0
Phase 5: Update Cycle
Read references/update-cycle.md for the full procedure.
When the user triggers an update (or on a schedule):
- Re-discover: Run Phase 1 again, producing
api-surface-new.json - Diff: Compare against the existing
api-surface.json:- New endpoints → plan + review + generate + test (mini Phase 2-4)
- Changed endpoints (new fields, changed types) → update types + functions + tests
- Removed endpoints → deprecate functions, add
@deprecateddecorators, update tests
- Branch:
feat/api-update-YYYY-MM-DD - Plan new/changed functions with LLM review (same as Phase 2)
- Generate/update code with full test suite
- Run all tests (existing + new) — auto-fix loop
- Merge + tag: Bump version appropriately (minor for additions, major for breaking changes)
Multi-Language Support
The skill generates SDKs for these targets by default (user can customize):
| Language | Directory | Package Manager | Test Framework |
|---|---|---|---|
| Python | python/ |
pip / pyproject.toml | pytest |
| TypeScript | typescript/ |
npm / package.json | jest |
Additional languages can be added by creating a new generation template
in templates/ and adding the language config to sdk-plan.json.
Error Handling Philosophy
- Never block on a single failure. If one endpoint's tests can't be fixed after
MAX_FIX_ATTEMPTS, mark it as
status: brokenin the plan, commit what works, and move on. - Always commit working state. Every commit should leave the repo in a state where existing tests pass.
- Surface unknowns. If the discovery phase can't determine a type or pattern,
use the most permissive type (
Any/unknown) and add aTODOcomment.
Coordinator Responsibilities
The agent orchestrating this skill must:
- Follow phases in order — Discovery → Planning → Generation → Testing → Git finalize
- Never skip LLM review — The planning review catches design mistakes early
- Commit atomically — Each logical unit of work gets its own commit
- Run the full test suite before merging — No merge without green tests
- Preserve the API surface file — This is the source of truth for diffing on updates
- Use conventional commits —
feat:,fix:,test:,docs:,chore:prefixes - Tag releases — SemVer: patch for fixes, minor for new endpoints, major for breaking changes
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?