# V4 security foundations

> V4 security foundations is an open-source agent skill for developer tools. Security checklists and vulnerability patterns for building Uniswap v4 hooks safely. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/Uniswap/uniswap-ai/tree/main/packages/plugins/uniswap-hooks/skills/v4-security-foundations
- **Repository:** https://github.com/uniswap/uniswap-ai
- **GitHub stars:** 236
- **License:** MIT
- **Skill name:** v4-security-foundations
- **Collection:** https://github.com/Uniswap/uniswap-ai
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill guides an agent through writing Uniswap v4 hooks with a security-first approach. It lays out a threat model covering caller verification, sender identity and router context, and reentrancy, then rates each of the 14 hook permission flags by risk level. Particular attention goes to the beforeSwapReturnDelta permission, with an explanation of the NoOp rug pull pattern and a short list of checks to run before using such a hook.

The guide also covers delta accounting through the PoolManager (take, settle and sync ordering), access control patterns that restrict callbacks to the PoolManager, and hazards from non-standard tokens such as fee-on-transfer and rebasing assets. It includes gas budget targets per callback, common gas pitfalls, and Foundry commands for gas profiling. A scoring system maps a hook's permissions, external calls, state, upgradability and token handling to a recommended audit tier.

The skill ships a base hook template with all permissions disabled by default, plus reference files for the template, a vulnerabilities catalog and a detailed audit checklist. It is written for Solidity developers working with v4-core and v4-periphery, and it runs no scripts of its own.

## When your agent uses it

> Security-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap", "afterSwap", or asks about V4 hook best practices, vulnerabilities, or audit requirements.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/Uniswap/uniswap-ai/tree/HEAD/packages/plugins/uniswap-hooks/skills/v4-security-foundations)
- [Asks for: Read, Glob, Grep, WebFetch, Task(subagent_type:Explore)](https://github.com/Uniswap/uniswap-ai/blob/HEAD/packages/plugins/uniswap-hooks/skills/v4-security-foundations/SKILL.md)
- [License: MIT](https://github.com/Uniswap/uniswap-ai/tree/HEAD/packages/plugins/uniswap-hooks/skills/v4-security-foundations)

## Features

- **Permission risk matrix:** Rates each of the 14 v4 hook permission flags by risk level with notes on what can go wrong.
- **NoOp attack guidance:** Explains the beforeSwapReturnDelta attack pattern and the checks to run before trusting such a hook.
- **Delta accounting rules:** Describes PoolManager credit and debit settlement with the correct sync, transfer and settle order.
- **Caller and router checks:** Shows how to restrict callbacks to the PoolManager and handle the sender parameter for router allowlisting.
- **Gas budget targets:** Lists target and ceiling gas figures per hook callback and common gas pitfalls with Foundry profiling commands.
- **Audit tier scoring:** Scores a hook's risk across several categories and recommends the audit level for the result.

## Good for

- Review a Uniswap v4 hook for access control mistakes before deployment
- Check whether a hook that returns swap deltas is safe to use
- Write a base v4 hook contract with permissions disabled by default
- Estimate how much audit coverage a planned v4 hook needs
- Profile gas usage of beforeSwap and afterSwap callbacks

## Install

### Claude Code

This skill ships in the `uniswap-hooks` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add Uniswap/uniswap-ai
/plugin install uniswap-hooks@uniswap-ai
```

Or copy only this skill to `~/.claude/skills/v4-security-foundations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/Uniswap/uniswap-ai.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/v4-security-foundations &&
cp -R "$tmp/packages/plugins/uniswap-hooks/skills/v4-security-foundations" ~/.claude/skills/v4-security-foundations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/v4-security-foundations` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/v4-security-foundations` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/Uniswap/uniswap-ai.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/v4-security-foundations &&
cp -R "$tmp/packages/plugins/uniswap-hooks/skills/v4-security-foundations" ~/.agents/skills/v4-security-foundations &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/v4-security-foundations` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/v4-security-foundations` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/Uniswap/uniswap-ai.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/v4-security-foundations &&
cp -R "$tmp/packages/plugins/uniswap-hooks/skills/v4-security-foundations" ~/.cursor/skills/v4-security-foundations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/v4-security-foundations` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/Uniswap/uniswap-ai.git --path packages/plugins/uniswap-hooks/skills/v4-security-foundations
```

Or copy the folder to `~/.gemini/skills/v4-security-foundations` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/v4-security-foundations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/Uniswap/uniswap-ai.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/v4-security-foundations &&
cp -R "$tmp/packages/plugins/uniswap-hooks/skills/v4-security-foundations" ~/.copilot/skills/v4-security-foundations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/v4-security-foundations` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/Uniswap/uniswap-ai.git
```

Then copy `uniswap-ai/packages/plugins/uniswap-hooks/skills/v4-security-foundations` into your agent's skills folder as `v4-security-foundations`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does V4 security foundations trigger on?

It is meant to load when the user mentions terms such as v4 hooks, hook security, PoolManager, beforeSwap or afterSwap, or asks about hook best practices, vulnerabilities or audit requirements.

### Which clients does V4 security foundations work with?

It is packaged as a Claude Code plugin marketplace entry (uniswap-ai), so it is tied to Claude Code.

### Does V4 security foundations run any scripts?

No. The skill folder contains no scripts. It provides written guidance, a Solidity template and reference documents.

### What tools does V4 security foundations allow the agent to use?

It lists Read, Glob, Grep, WebFetch and a Task subagent of type Explore.

### What license applies?

The skill is released under the MIT license.

### How do I install V4 security foundations in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/v4-security-foundations to use it in all your projects, or to .claude/skills/v4-security-foundations in one project. Or install the uniswap-hooks plugin, which includes it: /plugin marketplace add Uniswap/uniswap-ai, then /plugin install uniswap-hooks@uniswap-ai.

### Does V4 security foundations run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use V4 security foundations?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to V4 security foundations?

The closest alternatives to V4 security foundations are Uniswap v4 hook access control, V4 hook generator, V4 SDK integration, Permissioned pools issuer and Permissioned pools deployer.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Uniswap v4 hook access control](https://ai-powered.com/skills/uniswap-v4-hook-access-control): Uniswap v4 hook access control is an open-source agent skill for security.
- [V4 hook generator](https://ai-powered.com/skills/v4-hook-generator): V4 hook generator is an open-source agent skill for developer tools.
- [V4 SDK integration](https://ai-powered.com/skills/v4-sdk-integration): V4 SDK integration is an open-source agent skill for developer tools.
- [Permissioned pools issuer](https://ai-powered.com/skills/permissioned-pools-issuer): Permissioned pools issuer is an open-source agent skill for developer tools.
- [Permissioned pools deployer](https://ai-powered.com/skills/permissioned-pools-deployer): Permissioned pools deployer is an open-source agent skill for developer tools.
- [Writing hooks](https://ai-powered.com/skills/writing-hooks-xiaolai): Writing hooks is an open-source agent skill for developer tools.
- [Moodle hooks API](https://ai-powered.com/skills/moodle-hooks-api): Moodle hooks API is an open-source agent skill for developer tools.
- [Permissioned pools configurator](https://ai-powered.com/skills/permissioned-pools-configurator): Permissioned pools configurator is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/v4-security-foundations
