Design hook

From onfire7777/universal-ai-skills-library · View interactive version

Design hook is an AI agent skill from the GitHub repository onfire7777/universal-ai-skills-library. Design a Uniswap V4 hook architecture without code generation. Use when user wants to plan a hook, understand which callbacks to use, or review an architecture before building. Returns a design document, not code.

How to use this skill

Skill file

Design Hook

Overview

Designs a Uniswap V4 hook architecture without generating code. Delegates to the hook-builder agent in design-only mode to produce a comprehensive design document covering: which callbacks are needed, hook flag requirements, state management approach, gas estimates, security considerations, and architecture decisions. Use this to plan before building, or to evaluate feasibility.

When to Use

Activate when the user asks:

Parameters

| Parameter | Required | Default | Description |

| --- | --- | --- | --- |

| behavior | Yes | -- | Hook behavior description (e.g., "limit orders", "dynamic fees", "oracle pricing") |

| constraints | No | -- | Gas budget, security requirements, or specific design constraints |

| integrations | No | -- | External systems the hook needs to interact with (oracles, governance, staking) |

Workflow

  1. Extract parameters from the user's request: identify the hook behavior, constraints, and any external integrations.
  1. Delegate to hook-builder in design-only mode: Invoke Task(subagent_type:hook-builder) with explicit instruction to produce a design document only -- no code generation, no file writes. The hook-builder will:
  1. Present the design document to the user covering:

Output Format

Present a structured design document:

V4 Hook Design: Dynamic Fee Hook

  Callbacks Required:
    - beforeSwap: Read volatility oracle, calculate dynamic fee
    - beforeInitialize: Set initial fee parameters and oracle address

  Hook Flags: BEFORE_SWAP_FLAG | BEFORE_INITIALIZE_FLAG
  Bitmask: 0x2080

  State Management:
    - volatilityOracle: IVolatilityOracle (immutable, set in constructor)
    - baseFee: uint24 (configurable by owner)
    - maxFee: uint24 (cap to prevent excessive fees)
    - feeMultiplier: uint24 (scales with volatility)

  Gas Estimates:
    beforeSwap: ~30,000 gas (oracle read + fee calculation)
    beforeInitialize: ~25,000 gas (one-time setup)

  Security Considerations:
    - Oracle manipulation: Use TWAP, not spot price
    - Fee cap: Enforce maxFee to protect traders
    - Owner control: Fee parameters updatable by owner only

  Architecture Decisions:
    - Using beforeSwap (not afterSwap) to set fee before execution
    - External oracle for volatility data rather than on-chain calculation
    - Fee bounded between baseFee and maxFee for predictability

  Alternative Approaches:
    - On-chain volatility calculation (higher gas, no oracle dependency)
    - Fixed fee tiers with governance voting (simpler, less responsive)

Important Notes

Error Handling

| Error | User-Facing Message | Suggested Action |

| --- | --- | --- |

| VAGUE_REQUIREMENTS | "Need more detail about the desired hook behavior." | Describe specific behavior (e.g., "limit orders that execute at tick boundaries") |

| UNSUPPORTED_CALLBACK | "V4 does not support the requested callback." | Review available V4 callbacks and adjust requirements |

| INFEASIBLE_DESIGN | "This hook design is not feasible with current V4 capabilities." | Simplify requirements or consider alternative approaches |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.