affaan-m avatar

Llm Trading Agent Security

If you're building an AI agent that can actually send transactions or move money, this gives you a layered defense checklist. It covers prompt injection detection tuned for wallet addresses and transfer commands, hard spend caps with daily limits, mandatory pre-send simulation with slippage checks, circuit breakers that halt on drawdown, and wallet isolation patterns. The examples are Python but the ideas port anywhere. The core insight is right: no single control is enough when a bad LLM output can drain funds. Treat every piece of external data as hostile, simulate before you sign, and keep the agent's keys separate from your treasury.

skills.sh installs
3.6K
GitHub stars
229.1K
last updated
Jul 14, 2026

Install

$ npx -y skills add affaan-m/everything-claude-code --skill llm-trading-agent-security --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/affaan-m/everything-claude-code
Categories
Security, AI & Agent Building, Finance & Trading
First seen
May 16, 2026

More from affaan-m/everything-claude-code

All 256

Recommended

More Security
1affaan-m avatardefi-amm-securityaffaan-m/everything-claude-codedefi amm security3.5Kskills.sh installs
2boshu2 avatarsecurityboshu2/agentopsRun authorized repository security scans for1.4Kskills.sh installs
3uniswap avatarv4-security-foundationsuniswap/uniswap-aiSecurity-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap", "afterSwap", or asks about V4 hook 1.2Kskills.sh installs
4ruvnet avataragent-authenticationruvnet/rufloAgent skill for authentication - invoke with $agent-authentication1.1Kskills.sh installs
5davila7 avatarsenior-securitydavila7/claude-code-templatesComprehensive security engineering skill for application security, penetration testing, security architecture, and compliance auditing. Includes security assess987skills.sh installs
6aradotso avatarslowmist-agent-security-frameworkaradotso/security-skillsslowmist agent security framework955skills.sh installs