main

Coding rules for integrating the GhostSwap Partners API, which provides non-custodial cryptocurrency swaps. They cover authentication, retry-safe requests, polling, and error handling.

In plain words
What is it for?
Use them when writing server-side code for GhostSwap quotes, swaps, retries, status checks, and displaying the amount a user receives.
Why use it?
They help prevent unsafe credential exposure and duplicate swaps when building crypto-conversion features.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ghostswap1/ghostswap-agents/main
Clone the repo
git clone --depth 1 https://github.com/ghostswap1/ghostswap-agents

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 682 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00682
Opus 5 $0.00000 $0.00341
Sonnet 5 $0.00000 $0.00136
Haiku 4.5 $0.00000 $0.00068

Measured 2d ago against content hash 8d8dd7f5dc41, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

main scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/main.mdc · 54 lines

How it starts

The opening of the file, as written. The whole thing — 54 lines — stays where its author put it; the contents beside it link to each section on GitHub.

GhostSwap Partners API — Cursor project rules

Apply these rules whenever you generate or edit code that calls the GhostSwap Partners API.

Authoritative references (always consult before writing API code)

  • @../../AGENTS.md — cross-tool conventions, the 6-step workflow, anti-patterns
  • @../../skills/ghostswap-partners-api/SKILL.md — full Claude Skill body, includes a minimal Node.js reference proxy
  • @../../openapi/openapi.yaml — typed request/response shapes for every endpoint
  • @../../mcp-server/src/index.ts — MCP tool definitions if you want typed tool access

Non-negotiables (these are the rules that prevent real bugs)

  1. Server-side only. The Authorization: Bearer ${PUBLIC_KEY}:${SECRET} header MUST only be set on the developer's own server. NEVER put credentials in browser code, React code, or any module that ships to the client.

  2. POST /v1/swaps requires an Idempotency-Key header (UUID v4). Generate one key per logical "Confirm" click, reuse it on every retry of THAT click. Regenerating creates duplicate swaps. Reset the key only after success.

  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. When unknown, omit the field — never send an empty string.

  5. Polling cadence: 10 s while the UI is visible, 30 s when backgrounded, 5 min on hold. Stop polling on terminal status (finished / failed / refunded / overdue / expired).

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

  7. Read the base URL from GHOSTSWAP_API_BASE env. Don't hard-code https://partners-api.ghostswap.io in your code.

Error envelope (always handle it)

type ApiError = {
  error: {
    type: 'validation_error' | 'authentication_error' | 'rate_limit_error' | 'conflict' | 'unprocessable' | 'upstream_error' | string;
    code: string;
    message: string;
    param?: string;
  };
};

Read the full file on GitHub · 54 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 54 lines · 0 tokens per session scan A 8d8dd7f5dc41

Subscribe to this mod's changes

main is a cursor rule published in the GitHub repository ghostswap1/ghostswap-agents (3 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 682 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.