llm-trading-agent-security

llm-trading-agent-security is a skill for Claude Code, Codex from nklofy/code-agent-skills. It costs 41 tokens per session (1,086 once invoked), scanned A, a copy of llm-trading-agent-security, Apache-2.0.

Security guidance for AI trading agents that can control wallets or send financial transactions. It covers prompt injection, spending limits, transaction simulation, execution cutoffs, and key handling.

In plain words
What is it for?
Use it when building or auditing trading bots, transaction-signing agents, wallet systems, order placement, token swaps, or treasury operations.
Why use it?
It reduces the risk that malicious instructions, unsafe tool calls, or faulty decisions will cause an agent to lose or move assets.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building or auditing trading bots, transaction-signing agents, wallet systems, order placement, token swaps, or treasury operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nklofy/code-agent-skills/llm-trading-agent-security
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.

Any agent
npx skills add nklofy/code-agent-skills --skill llm-trading-agent-security
Clone the repo
git clone --depth 1 https://github.com/nklofy/code-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for llm-trading-agent-security

README.md
[![agentmods](https://agentmods.dev/badge/skills/nklofy/code-agent-skills/llm-trading-agent-security/github.svg)](https://agentmods.dev/skills/nklofy/code-agent-skills/llm-trading-agent-security)
Your own site
<a href="https://agentmods.dev/skills/nklofy/code-agent-skills/llm-trading-agent-security"><img src="https://agentmods.dev/badge/skills/nklofy/code-agent-skills/llm-trading-agent-security/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for llm-trading-agent-security

Your own site · 80×15
<a href="https://agentmods.dev/skills/nklofy/code-agent-skills/llm-trading-agent-security"><img src="https://agentmods.dev/badge/skills/nklofy/code-agent-skills/llm-trading-agent-security.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,086 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 97% copy Near-identical to another mod 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.1 $0.00041 $0.01086
Opus 5 $0.00020 $0.00543
Sonnet 5 $0.00008 $0.00217
Haiku 4.5 $0.00004 $0.00109

Measured 6d ago against content hash 7e78ba37dddd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

llm-trading-agent-security 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 6d 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.

Origin

This is a copy

97% identical to llm-trading-agent-security — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

affaan-m-ECC/llm-trading-agent-security/SKILL.md · 148 lines

How it starts

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

LLM Trading Agent Security

Autonomous trading agents have a harsher threat model than normal LLM apps: an injection or bad tool path can turn directly into asset loss.

When to Use

  • Building an AI agent that signs and sends transactions
  • Auditing a trading bot or on-chain execution assistant
  • Designing wallet key management for an agent
  • Giving an LLM access to order placement, swaps, or treasury operations

How It Works

Layer the defenses. No single check is enough. Treat prompt hygiene, spend policy, simulation, execution limits, and wallet isolation as independent controls.

Examples

Treat prompt injection as a financial attack

import re

INJECTION_PATTERNS = [
    r'ignore (previous|all) instructions',
    r'new (task|directive|instruction)',
    r'system prompt',
    r'send .{0,50} to 0x[0-9a-fA-F]{40}',
    r'transfer .{0,50} to',
    r'approve .{0,50} for',
]

def sanitize_onchain_data(text: str) -> str:
    for pattern in INJECTION_PATTERNS:
        if re.search(pattern, text, re.IGNORECASE):
            raise ValueError(f"Potential prompt injection: {text[:100]}")
    return text

Do not blindly inject token names, pair labels, webhooks, or social feeds into an execution-capable prompt.

Hard spend limits

from decimal import Decimal

MAX_SINGLE_TX_USD = Decimal("500")
MAX_DAILY_SPEND_USD = Decimal("2000")

class SpendLimitError(Exception):
    pass

class SpendLimitGuard:
    def check_and_record(self, usd_amount: Decimal) -> None:
        if usd_amount > MAX_SINGLE_TX_USD:
            raise SpendLimitError(f"Single tx ${usd_amount} exceeds max ${MAX_SINGLE_TX_USD}")

        daily = self._get_24h_spend()
        if daily + usd_amount > MAX_DAILY_SPEND_USD:
            raise SpendLimitError(f"Daily limit: ${daily} + ${usd_amount} > ${MAX_DAILY_SPEND_USD}")

        self._record_spend(usd_amount)

Simulate before sending

class SlippageError(Exception):
    pass

async def safe_execute(self, tx: dict, expected_min_out: int | None = None) -> str:
    sim_result = await self.w3.eth.call(tx)

    if expected_min_out is None:
        raise ValueError("min_amount_out is required before send")

    actual_out = decode_uint256(sim_result)
    if actual_out < expected_min_out:
        raise SlippageError(f"Simulation: {actual_out} < {expected_min_out}")

    signed = self.account.sign_transaction(tx)
    return await self.w3.eth.send_raw_transaction(signed.raw_transaction)

Read the full file on GitHub · 148 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. 6d ago First seen · 148 lines · 41 tokens per session scan A 7e78ba37dddd

Subscribe to this mod's changes

llm-trading-agent-security is a skill published in the GitHub repository nklofy/code-agent-skills (18 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 41 tokens to every session and 1,086 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to llm-trading-agent-security, differing in 3 lines, and is treated as a copy.

Related

Other skills, from other repositories