Skip to main content
These patterns work in Claude Code, Cursor, Codex, or any coding agent, whether or not it has MCP access. The agent’s training data goes stale the moment the API changes; a good prompt tells it what to build and where to check its own work against the live API instead of guessing from memory.

Give it the right context

Paste this and fill in the brackets. An agent that starts with this much context asks fewer clarifying questions and guesses at fewer fields.
Adjust the bracketed lines per task: a portfolio view needs several networks, not one; a debugging prompt needs an error body instead of an action. See AI coding tools to wire up the MCP doc tools and live doc sources referenced above.

Make it verify, not guess

Add whichever of these lines apply to the task. Each tells the agent to check something live instead of assuming it.
  • Fetch the live spec for the exact endpoint before writing code (https://api.yield.xyz/docs.json, or yield_get_api_spec if connected); do not reuse field names from an old answer or a training-data memory of the API.
  • Read mechanics.arguments.enter / .exit .fields[] from GET /v1/yields/{yieldId} instead of hardcoding arguments. See Yield metadata.
  • Confirm status.enter / status.exit on the yield before building an enter or exit action; a closed yield returns 412, not a validation error.
  • Iterate transactions[] by stepIndex and respect executionPattern (synchronous waits for each confirmation; batch bundles multiple operations into one transaction). asynchronous is also a declared value, but current actions return synchronous or batch. See Actions.
  • Submit the hash, or submit the signed transaction, exactly once per transaction: PUT /v1/transactions/{id}/submit-hash after you broadcast, or POST /v1/transactions/{id}/submit to have Yield.xyz broadcast. Never both for the same transaction.
  • Poll GET /v1/transactions/{id} or GET /v1/actions/{id} to a terminal status; don’t assume success right after a broadcast.
  • Read balances and pendingActions before a manage call. See Balances and positions.
  • Check network and provider availability for this project through discovery (GET /v1/networks, GET /v1/providers, GET /v1/yields) rather than assuming a network or protocol is enabled.

Prompt patterns

Discover yields, with pagination

Enter a position

Exit a position and claim a pending action

Portfolio balances across networks

Debug an API error

Review before anything signs

Never sign a generated transaction without inspecting it yourself. This applies whether the transaction came from a builder plugin, a one-off prompt, or code you wrote by hand. For generated code, check:
  • Every request goes to https://api.yield.xyz with x-api-key from an environment variable; no key literal in source.
  • Action arguments came from the yield’s schema, not copied from another yield or from memory.
  • Amounts are human-readable decimal strings, never wei.
  • transactions[] are processed in stepIndex order, and nothing modifies unsignedTransaction.
For any transaction an agent built, before you sign:
  • Inspect the decoded to address, amount, and network yourself; don’t trust a summary the agent wrote.
  • Confirm it targets the yield and action you asked for, not a different one.
  • Run a small test amount first, on a network where a mistake is cheap.
The full set of non-custodial rules an agent must follow, and the exact checks to run before a manage action, are in Guardrails.

Anti-patterns

  • Asking for “the best APY” with no network, asset, or risk scope: the agent will invent a ranking instead of querying one.
  • Letting the agent pick a yieldId from memory instead of discovering it from your project’s enabled yields.
  • Asking the agent to “fix” a failed transaction by editing the returned payload. Request a new action instead; a modified unsignedTransaction can send funds to the wrong place.

Next steps

AgentKit builder

Install the plugin that applies these patterns automatically while it writes your integration.

AI coding tools

Connect your agent to the live docs, spec, and MCP doc tools these prompts rely on.

Enter and exit flows

Build the same flow by hand, endpoint by endpoint, to check what an agent generated.

Guardrails

The non-custodial rules an agent or generated integration must follow.