defi-amm-security

defi-amm-security is a skill for Claude Code, Codex from unrealandychan/clean-code-skill. It costs 64 tokens per session (1,244 once invoked), scanned A, a copy of defi-amm-security, MIT.

A security checklist and pattern guide for Solidity contracts that run automated market makers (AMMs), liquidity pools, and token swaps.

In plain words
What is it for?
Use it when writing or auditing deposit, withdrawal, mint, burn, and swap functions in decentralised finance contracts.
Why use it?
It helps spot common flaws such as reentrancy, oracle manipulation, unsafe integer math, weak admin controls, and attacks that change pool balances or share values.

Skill for Claude CodeCodex

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

Good fit Use it when writing or auditing deposit, withdrawal, mint, burn, and swap functions in decentralised finance contracts.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/unrealandychan/clean-code-skill/defi-amm-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 unrealandychan/clean-code-skill --skill defi-amm-security
Clone the repo
git clone --depth 1 https://github.com/unrealandychan/clean-code-skill

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 defi-amm-security

README.md
[![agentmods](https://agentmods.dev/badge/skills/unrealandychan/clean-code-skill/defi-amm-security/github.svg)](https://agentmods.dev/skills/unrealandychan/clean-code-skill/defi-amm-security)
Your own site
<a href="https://agentmods.dev/skills/unrealandychan/clean-code-skill/defi-amm-security"><img src="https://agentmods.dev/badge/skills/unrealandychan/clean-code-skill/defi-amm-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 defi-amm-security

Your own site · 80×15
<a href="https://agentmods.dev/skills/unrealandychan/clean-code-skill/defi-amm-security"><img src="https://agentmods.dev/badge/skills/unrealandychan/clean-code-skill/defi-amm-security.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,244 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 86% 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.00064 $0.01244
Opus 5 $0.00032 $0.00622
Sonnet 5 $0.00013 $0.00249
Haiku 4.5 $0.00006 $0.00124

Measured today against content hash 06f662a81b1f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

defi-amm-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 today.

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

86% identical to defi-amm-security — 29 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.

skills/ecc/defi-amm-security/SKILL.md · 168 lines

How it starts

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

DeFi AMM Security

Critical vulnerability patterns and hardened implementations for Solidity AMM contracts, LP vaults, and swap functions.

When to Use

  • Writing or auditing a Solidity AMM or liquidity-pool contract
  • Implementing swap, deposit, withdraw, mint, or burn flows that hold token balances
  • Reviewing any contract that uses token.balanceOf(address(this)) in share or reserve math
  • Adding fee setters, pausers, oracle updates, or other admin functions to a DeFi protocol

How It Works

Use this as a checklist-plus-pattern library. Review every user entrypoint against the categories below and prefer the hardened examples over hand-rolled variants.

Execution Safety

The shell commands in this skill are local audit examples. Run them only in a trusted checkout or disposable sandbox, and do not splice untrusted contract names, paths, RPC URLs, private keys, or user-supplied flags into shell commands. Ask before installing tools or running long fuzzing/static-analysis jobs that may consume significant local or paid resources.

Never include secrets, private keys, seed phrases, API tokens, or mainnet signing credentials in command examples, logs, or reports.

Examples

Reentrancy: enforce CEI order

Vulnerable:

function withdraw(uint256 amount) external {
    require(balances[msg.sender] >= amount);
    token.transfer(msg.sender, amount);
    balances[msg.sender] -= amount;
}

Safe:

import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

using SafeERC20 for IERC20;

function withdraw(uint256 amount) external nonReentrant {
    require(balances[msg.sender] >= amount, "Insufficient");
    balances[msg.sender] -= amount;
    token.safeTransfer(msg.sender, amount);
}

Do not write your own guard when a hardened library exists.

Donation or inflation attacks

Using token.balanceOf(address(this)) directly for share math lets attackers manipulate the denominator by sending tokens to the contract outside the intended path.

Read the full file on GitHub · 168 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. today First seen · 168 lines · 64 tokens per session scan A 06f662a81b1f

Subscribe to this mod's changes

defi-amm-security is a skill published in the GitHub repository unrealandychan/clean-code-skill (6 stars, last pushed yesterday), licensed MIT. It adds 64 tokens to every session and 1,244 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 86% identical to defi-amm-security, differing in 29 lines, and is treated as a copy.

Related

Other skills, from other repositories

signature-replay

Signature replay attacks — missing nonces, missing chain ID, ecrecover zero address, signature malleability, cross-chain replay.

PurpleAILAB/Decepticon · 31 tokens

official-sui-skills

Pointer to the official Mysten Labs skills for building on Sui — language fundamentals, object model, PTBs, SDKs, publishing, upgrades, frontend integration, accessing on-chain data. Maintained upstream at github.com/MystenLabs/skills; pinned to the same ref the audit catalog derives from (see…

MystenLabs/sui · 116 tokens

crypto-market-rank

Crypto market rankings and leaderboards. Query trending tokens, top searched tokens, Binance Alpha tokens, tokenized stocks, social hype sentiment ranks, smart money inflow token rankings, top meme token rankings from Pulse launchpad, and top trader PnL leaderboards. Use this skill when users ask about token rankings…

tradecatlabs/tradecat-public · 85 tokens

trading-signal

Subscribe and retrieve on-chain Smart Money signals. Monitor trading activities of smart money addresses, including buy/sell signals, trigger price, current price, max gain, and exit rate. Use this skill when users are looking for investment opportunities — smart money signals can serve as valuable references for…

tradecatlabs/tradecat-public · 64 tokens

bridge

Cross-chain token transfers using Wormhole and CCTP.

alsk1992/CloddsBot · 13 tokens

onchainkit

Build onchain apps with Coinbase's OnchainKit React components - wallets, swaps, NFTs, payments.

alsk1992/CloddsBot · 24 tokens