# CLAUDE.md - uniswap-hooks Plugin

> This plugin provides AI-powered, security-first assistance for creating Uniswap v4 hooks.

- Skill: `tools-only/claude-md-uniswap-hooks-plugin` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/claude-md-uniswap-hooks-plugin`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/claude-md-uniswap-hooks-plugin/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/claude-md-uniswap-hooks-plugin

---

# CLAUDE.md - uniswap-hooks Plugin

## Overview

This plugin provides AI-powered, security-first assistance for creating Uniswap v4 hooks. It helps developers design, implement, and test custom hooks for the Uniswap V4 protocol with a strong emphasis on security best practices.

## Plugin Components

### Skills (./skills/)

- **v4-security-foundations**: Security-first guide for v4 hook development (NoOp attacks, delta accounting, access control, audit checklists)

## Uniswap v4 Hooks Architecture

Hooks are smart contracts that can intercept and modify pool actions at specific points:

### Hook Callbacks

| Callback                | When Called           | Use Case                  |
| ----------------------- | --------------------- | ------------------------- |
| `beforeInitialize`      | Before pool creation  | Validate pool parameters  |
| `afterInitialize`       | After pool creation   | Set up hook state         |
| `beforeAddLiquidity`    | Before LP deposit     | Custom fee logic          |
| `afterAddLiquidity`     | After LP deposit      | Update rewards            |
| `beforeRemoveLiquidity` | Before LP withdrawal  | Lock periods              |
| `afterRemoveLiquidity`  | After LP withdrawal   | Distribute rewards        |
| `beforeSwap`            | Before swap execution | Price oracles, routing    |
| `afterSwap`             | After swap execution  | MEV protection, analytics |
| `beforeDonate`          | Before donation       | Access control            |
| `afterDonate`           | After donation        | Track donations           |

### Hook Flags

Hooks declare which callbacks they implement via flags:

```solidity
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
    return Hooks.Permissions({
        beforeInitialize: false,
        afterInitialize: true,
        beforeAddLiquidity: false,
        afterAddLiquidity: false,
        beforeRemoveLiquidity: false,
        afterRemoveLiquidity: false,
        beforeSwap: true,
        afterSwap: true,
        beforeDonate: false,
        afterDonate: false,
        beforeSwapReturnDelta: false,
        afterSwapReturnDelta: false,
        afterAddLiquidityReturnDelta: false,
        afterRemoveLiquidityReturnDelta: false
    });
}
```

## Development Guidelines

### Hook Address Requirements

v4 hooks must have specific address patterns where the last 14 bits encode which callbacks are enabled. Use the hook miner to find valid addresses.

### State Management

- Use transient storage for temporary data within a transaction
- Consider gas costs when storing persistent state
- Leverage PoolManager's singleton pattern

### Security Considerations

- Validate all inputs in hook callbacks
- Be aware of reentrancy risks
- Consider MEV implications of hook logic
- Test edge cases with extreme tick ranges

## File Structure

```text
uniswap-hooks/
├── .claude-plugin/
│   └── plugin.json
├── skills/
│   └── v4-security-foundations/
│       ├── SKILL.md
│       └── references/
│           ├── audit-checklist.md
│           ├── base-hook-template.md
│           └── vulnerabilities-catalog.md
├── project.json
├── package.json
├── CLAUDE.md
└── README.md
```

## Related Resources

- [Uniswap v4 Core](https://github.com/Uniswap/v4-core)
- [v4 Periphery](https://github.com/Uniswap/v4-periphery)
- [Hook Examples](https://github.com/Uniswap/v4-periphery/tree/main/src/lens)

