apitap
CLAUDE.md127 starsChanged 6 months agoApache-2.0View on GitHub
When asked to fetch data from a website, always check for existing skill files first: The replay path is the fast path. It calls APIs directly over HTTP — no browser, no Playwright, no Chrome. Don't open a browser if a skill file already exists. ApiTap intercepts web API traffic via browser, generates portable "skill files," and replays APIs without a browser. Two distinct runtime paths: Capture path (requires Playwright): Replay path (zero dependencies, stdlib node:http):
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- SKILL.mdSkill
- apitapSkill
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
When asked to fetch data from a website, always check for existing skill files first:
- Very specific: line 10
If it exists → use apitap replay <domain> <endpoint-id> (no browser needed)
- Very specific: line 11
If no skill file → try apitap read <url> first (text extraction, no browser)
- Very specific: line 12
Only use apitap capture or apitap browse as a last resort (requires browser)
- Very specific: line 82
All imports use .js extension (NodeNext requirement): import { foo } from './bar.js'.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Using ApiTap as an MCP Tool
When asked to fetch data from a website, always check for existing skill files first:
apitap show <domain>— check if a skill file already exists- If it exists → use
apitap replay <domain> <endpoint-id>(no browser needed) - If no skill file → try
apitap read <url>first (text extraction, no browser) - Only use
apitap captureorapitap browseas a last resort (requires browser)
The replay path is the fast path. It calls APIs directly over HTTP — no browser, no Playwright, no Chrome. Don't open a browser if a skill file already exists.
Commands
npm test # Run all tests (~721, Node built-in runner + tsx)
node --import tsx --test test/path/to/test.ts # Run a single test file
npm run typecheck # Type check (tsc --noEmit)
npm run build # Compile to dist/
npx tsx src/cli.ts <command> [args] # Run CLI from sourceArchitecture
ApiTap intercepts web API traffic via browser, generates portable "skill files," and replays APIs without a browser. Two distinct runtime paths:
Capture path (requires Playwright):
Browser → CDP listener (monitor.ts) → filter.ts → SkillGenerator → skill.json on diskReplay path (zero dependencies, stdlib node:http):
Skill file → replay/engine.ts → net/transport.ts pinnedFetch() → JSON responseModule Map
src/capture/— Browser-side interception.monitor.tsis the Playwright CDP listener.session.tswraps monitor into a stateful interactive session (used by MCPcapture_start/capture_interact/capture_finish).filter.tsscores requests to separate API calls from noise.parameterize.tsconverts/users/123→/users/:id.src/skill/— Skill file lifecycle.generator.tsgroups captured exchanges, deduplicates bymethod + parameterizedPath, extracts auth/pagination/body templates.store.tsreads/writes~/.apitap/skills/<domain>.json.signing.tsprovides HMAC-SHA256 integrity.ssrf.tsvalidates URLs against private IP ranges.src/replay/—engine.tssubstitutes params, injects auth from encrypted storage, validates URLs via SSRF checks, and callstransport.fetch()(src/net/transport.ts). Auth comes fromAuthManager, never from the skill file itself.src/net/—transport.ts:pinnedFetch(), a fetch-compatible client over node:http(s) whose DNS lookup rejects private addresses at connect time (closes DNS rebinding), never follows redirects, never pools sockets.fetchFollowing()adds fetch-style redirect following where every hop is re-checked and Authorization/Cookie are dropped on cross-origin hops. Every outbound HTTP call goes through here: replay, OAuth refresh, verifier, spec importers (GitHub/APIs.guru/SwaggerHub), and (viasafeFetch) read/peek/discovery.src/discovery/— Browser-free API detection.frameworks.tsdetects WordPress/Next.js/Shopify from HTML/headers.openapi.tsprobes for specs.probes.tschecks common API paths.index.tsorchestrates all three in parallel.src/read/— Text-mode content extraction. Site-specific decoders (Reddit, YouTube, Wikipedia, HN, Twitter, Grokipedia, DeepWiki) indecoders/. Falls back to generic HTML extraction inextract.ts.peek.tsdoes HEAD-only triage.src/auth/—manager.tsstores/retrieves encrypted credentials (AES-256-GCM).refresh.tshandles browser-based token refresh.handoff.tsopens a visible browser for human login.oauth-refresh.tshandles OAuth refresh_token flows.src/orchestration/—browse.tsis the high-level "just get me the data" pipeline (cache → disk → discover → replay).cache.tsis an in-memory session cache for the MCP server.src/cli.ts— Hand-rolled arg parser, all CLI commands. No framework (no yargs/commander).src/mcp.ts— MCP server (12 tools) using@modelcontextprotocol/sdk. All responses from external APIs are wrapped withuntrusted: truemetadata.src/plugin.ts— Lightweight non-MCP plugin interface (search + replay + batch tools).src/serve.ts— Serves a single skill file as a dedicated MCP server where each endpoint becomes its own tool.
Key Design Decisions
- CLI is the API: agents use the same commands humans do.
--jsonon every command for machine output. That covers failures too — every error exit goes throughfailCli()insrc/cli.ts, which prints{success: false, error, usage?, hint?}to stdout under--jsonwhile keeping the human line on stderr. Keeperrorshort enough to surface alone — long guidance goes inhint, which reaches both channels. Add new error exits viafailCli, never a bareconsole.error+process.exit.apitap serveis the one exception: its stdout is the MCP transport, so it passesstream: 'stderr'and the human line is suppressed to keep that stream parseable. - Skill files are the central artifact: JSON at
~/.apitap/skills/<domain>.jsonwith version, endpoints, auth config, provenance, and HMAC signature. - Auth is never in skill files: credentials live in separate encrypted storage. Skill files only contain
[stored]placeholders. - SSRF defense is multi-layered: validated at import, at replay, per redirect hop, and — the enforcement point — inside the connection's own DNS lookup (
validatingLookup), so the checked address is the connected address. Private IPs, cloud metadata, localhost all blocked. Never add a new outbound call that pre-checks DNS and then calls globalfetch(hostname): that re-resolves and reopens rebinding. Usetransport.fetch/safeFetch. - Generator deduplication: keyed on
method + parameterizedPath. For POST bodies, duplicate bodies stored inexchangeBodiesmap for cross-request diffing duringtoSkillFile(). - ESM-only:
"type": "module"with.jsextensions in imports (even for .ts source files, required by NodeNext resolution).
Security Model
- Signing threat model: Skill file HMAC-SHA256 signatures protect against external attackers and file corruption, not same-user processes. Any process running as the same user can derive the signing key from
/etc/machine-id+~/.apitap/install-salt. This follows the standard Unix security model where same-user processes share a trust boundary. APITAP_MACHINE_IDenv var: Testing-only override for the machine ID used in key derivation. Never set in production.- Auth encryption: Credentials in
~/.apitap/auth.encuse AES-256-GCM with per-install random salt and 100K PBKDF2-SHA512 iterations. Fresh random IV per encryption. File permissions0o600, directory0o700.
Testing Conventions
- Tests mirror
src/structure undertest/(e.g.,src/capture/filter.ts→test/capture/filter.test.ts). - Uses Node's built-in
node:testwithdescribe/it/assert. No Jest, no Mocha. - E2E tests in
test/e2e/spin up local HTTP servers for capture→replay round-trips. - Security tests in
test/security/cover SSRF, path traversal, header injection, DNS rebinding, redirect attacks. - Outbound HTTP goes through
transport.fetch— stub that (transport.fetch = stub), notglobalThis.fetch, which reaches none of the replay, OAuth, verifier or importer paths. - MCP tests in
test/mcp/test the MCP server tools end-to-end.
TypeScript
- Strict mode. Target ES2022, module NodeNext.
- All imports use
.jsextension (NodeNext requirement):import { foo } from './bar.js'. - Core types in
src/types.ts:CapturedExchange,SkillFile,SkillEndpoint,StoredAuth,Replayability,DiscoveryResult.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

