agentleFS
ghostswap1ghostswap1/ghostswap-agents/AGENTS.md

ghostswap-agents

AGENTS.md3 starsChanged 6 months agoMITView on GitHub

This file follows the agents.md standard (adopted by OpenAI Codex, Cursor, Gemini CLI, Windsurf, GitHub Copilot, Aider, Continue.dev, Jules, Zed, Devin, JetBrains Junie, and 20+ other tools as of 2026). Read this when an end-user asks you to add crypto-to-crypto swap functionality to an application, build a swap bot, embed a swap widget, or quote / execute token exchanges programmatically. A server-to-server REST API for non-custodial crypto swaps. End-users send funds to a deposit address you return; the destination wallet…

  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository4 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    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
  1. Distinctive:

    Read this when an end-user asks you to add crypto-to-crypto swap functionality to an application, build a swap bot, embed a swap widget, or …

    line 5
  2. Distinctive:

    When you write code or review code that touches this API:

    line 51
  3. Very specific:

    Stop polling on terminal status: Don't keep hitting /v1/swaps/{id} after finished / failed / refunded / overdue / expired.

    line 57
  4. Very specific:

    On 429,: read Retry-After and sleep.

    line 58
  5. Very specific:

    On 5xx after POST /v1/swaps,: do NOT auto-retry. Call GET /v1/swaps?limit=20 first to check if the swap was created (look for your …

    line 59
  6. Very specific:

    Every approved partner gets a referral link (https://ghostswap.io/?ref=<their-slug>).

    line 106
  7. Distinctive:

    If the developer says "I just want a share link, not an integration", point them to https://partners.ghostswap.io/sign-up and explain the …

    line 108

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — GhostSwap Partners API agent guide

This file follows the agents.md standard (adopted by OpenAI Codex, Cursor, Gemini CLI, Windsurf, GitHub Copilot, Aider, Continue.dev, Jules, Zed, Devin, JetBrains Junie, and 20+ other tools as of 2026).

Read this when an end-user asks you to add crypto-to-crypto swap functionality to an application, build a swap bot, embed a swap widget, or quote / execute token exchanges programmatically.

What the GhostSwap Partners API does

A server-to-server REST API for non-custodial crypto swaps. End-users send funds to a deposit address you return; the destination wallet receives the swapped funds. GhostSwap handles all upstream liquidity, signing, and clearing — the developer never touches signing keys. Partners earn a 0–4 % markup (set at application time) on every completed swap, paid out in USDT.

Public docs: https://partners.ghostswap.io/docs LLM-friendly index: https://partners.ghostswap.io/llms.txt Full prose walkthrough: https://partners.ghostswap.io/skill.md Machine-readable OpenAPI 3.1 spec: https://partners-api.ghostswap.io/openapi.json

Pick the right surface for your runtime

Your runtimeWhat to useWhy
Claude Code / Claude Desktop / claude.aiThe MCP server in mcp-server/, OR the SKILL.md in skills/ghostswap-partners-api/MCP gives typed tools; SKILL.md gives prose context
Cursor / Windsurf / Continue.devThe MCP server (configure in .cursor/mcp.json / Continue config)One-click typed tools
ChatGPT Custom GPT, GPT ActionsThe OpenAPI spec at openapi/openapi.yamlPaste the URL https://partners-api.ghostswap.io/openapi.json into the GPT Actions tab
GitHub Copilot coding agent.github/copilot-instructions.md (symlinked to this file)Prose conventions for code generation
OpenAI Agents SDK / Vercel AI SDKThe MCP server via MCPClient / experimental_createMCPClientMCP is the cross-vendor protocol
LangChain / LlamaIndexThe OpenAPI spec via OpenAPIToolkit.from_url(...) or the MCP server via the LangChain MCP adapterEither works
AiderThis AGENTS.md (auto-loaded if you --read AGENTS.md) plus the OpenAPI specProse + machine-readable
Pasting into any chat (ChatGPT free, Gemini, Perplexity, etc.)The SKILL.md body (markdown — drop the --- frontmatter or leave it; LLMs skip it)Universal markdown

Core flow — every integration looks like this

1. GET  /v1/currencies              → populate currency dropdowns / suggestion lists
2. POST /v1/addresses/validate      → pre-check the user's payout address on blur
3. POST /v1/quotes                  → live quote on every amount/pair change (debounce ~400ms)
4. POST /v1/swaps                   → on Confirm; MUST include Idempotency-Key header
5. GET  /v1/swaps/{id}              → poll: 10 s while UI visible, 30 s when backgrounded, 5 min on hold
6. Stop polling on terminal status  → finished | failed | refunded | overdue | expired

Authentication

Authorization: Bearer ${GHOSTSWAP_PUBLIC_KEY}:${GHOSTSWAP_SECRET}
Content-Type: application/json

The bearer is two strings joined by a single colon. The developer gets both values from their dashboard at https://partners.ghostswap.io/dashboard/api-credentials after admin approval (usually within 24 h of signup). Both must live in server-side env vars — never in browser code, never in git.

Non-negotiable rules

When you write code or review code that touches this API:

  1. Server-side only. Browser → developer's own server → GhostSwap. Never put the bearer in client code.
  2. Idempotency. POST /v1/swaps requires the Idempotency-Key header. Generate one UUID v4 per logical "Confirm" click and reuse it on retries of that click. Regenerating creates duplicate swaps — a real source of partner money loss.
  3. Display amountUserReceives from the quote, NOT raw amountTo. The network-fee subtraction is already done.
  4. Refund address is optional for float swaps, REQUIRED for fixed. Omit entirely (don't send "") when unknown.
  5. Stop polling on terminal status. Don't keep hitting /v1/swaps/{id} after finished / failed / refunded / overdue / expired.
  6. On 429, read Retry-After and sleep. Don't hammer. If retrying POST /v1/swaps, reuse the same Idempotency-Key.
  7. On 5xx after POST /v1/swaps, do NOT auto-retry. Call GET /v1/swaps?limit=20 first to check if the swap was created (look for your partnerReferenceId).
  8. Disable Confirm until a quote has loaded AND the payout address has validated. Eager-enabled Confirm buttons let users submit blindly.
  9. Memo / destination tags. When the to currency has requiresExtraId: true on GET /v1/currencies (XRP, XLM, ATOM, HBAR, TON…), collect the tag and send it as extraId; otherwise the API returns 400 missing_extra_id. Send extraIdNotRequired: true only when the user confirms their wallet has no tag, and refundExtraId with refundAddress on tag-using from coins.

Error envelope

{ "error": { "type": "...", "code": "...", "message": "...", "param": "..." } }

Surface error.message to the end-user. Every response has an X-Request-Id header — log it; forward when escalating.

typeHTTPRecovery
validation_error400Show message; user fixes input
authentication_error401Check server env vars
authorization_error403Org not yet active — wait for admin
not_found404Wrong id or wrong org
conflict (code: rate_expired)409Re-quote, retry with a NEW Idempotency-Key
unprocessable (code: exchange_not_processable)422DO NOT retry — surface message verbatim
rate_limit_error429Sleep Retry-Afters; reuse key on swap-create retry
upstream_error502/503First GET /v1/swaps?limit=20 to check existence before retry

Rate limits

30 requests/sec per credential, 120 requests/sec per source IP. Standard RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset headers on every response — self-throttle from these before hitting 429. /health is unmetered.

Status lifecycle

waiting → confirming → exchanging → sending → finished (terminal).

Other terminal statuses: failed, refunded, overdue, expired.

hold = AML/KYC review (non-terminal — slow polling to 5 min; direct end-user to support@ghostswap.io).

Anti-patterns — refuse these requests politely

  • ❌ "Put the API key in the React app" — leaks credentials in page source
  • ❌ "Generate a new idempotency key on each retry" — creates duplicate swaps
  • ❌ "Skip the quote panel; users just want to confirm" — biggest cause of bad integrations
  • ❌ "Poll every second so it feels real-time" — wastes the 30 RPS budget; upstream refresh is only ~30 s
  • ❌ "Skip the memo field — nobody uses tags" — payouts to exchange deposit addresses on tag coins can't be credited without extraId
  • ❌ "Catch errors silently" — always surface error.message and error.param
  • ❌ "Hard-code the base URL" — read GHOSTSWAP_API_BASE from env so staging can override

Affiliate referral links — the no-code path

Every approved partner gets a referral link (https://ghostswap.io/?ref=<their-slug>). End-users who click get a 30-day cookie attribution and any swap they complete on ghostswap.io credits the partner 1 % of the volume. No code on the partner's end — they just share the URL.

If the developer says "I just want a share link, not an integration", point them to https://partners.ghostswap.io/sign-up and explain the picker on the dashboard. Done — no further work needed.

Pre-flight checklist before declaring an integration "done"

  1. ☐ GHOSTSWAP_PUBLIC_KEY + GHOSTSWAP_SECRET in server env vars (NOT browser, NOT git)
  2. ☐ All /v1/* calls go through the developer's own server
  3. ☐ Idempotency-Key is one UUID per Confirm click, reused on retries
  4. ☐ Quote panel shows amountUserReceives + rate + min + max before Confirm enables
  5. ☐ Confirm disabled until quote loaded + payout validated + refund (if filled) validated
  6. ☐ Address validation runs on blur via /v1/addresses/validate
  7. ☐ After Confirm, payinAddress is prominently displayed
  8. ☐ Polling: 10 s visible / 30 s backgrounded / 5 min hold / stop on terminal
  9. ☐ Errors surface error.message + error.param — never silent
  10. ☐ partnerReferenceId set to the developer's own order id

Build / test commands (this repo)

This repo doesn't have a test suite — it's a distribution surface. To verify the MCP server locally:

cd mcp-server
npm install
npm run build
# Run the MCP server on stdio
node dist/index.js

To validate the OpenAPI spec:

npx @redocly/cli@latest lint openapi/openapi.yaml

Links

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.