router-act

router-act is a skill for Claude Code, Codex from vercel/next.js. It costs 71 tokens per session (2,864 once invoked), scanned A, original, MIT.

A testing method for Next.js router behavior that controls and checks internal requests during prefetching and navigation. Prefetching means loading a page's data before the user opens it; end-to-end tests check the whole running application.

In plain words
What is it for?
It is for writing end-to-end tests of client navigation, link prefetching, segment caching, and the responses returned by those requests.
Why use it?
It makes router tests less dependent on exact request counts and timing, reducing flaky results. It can also verify that navigation data comes from the client cache when appropriate.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/vercel/next.js/router-act
Any agent
npx skills add vercel/next.js --skill router-act
Clone the repo
git clone --depth 1 https://github.com/vercel/next.js

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 router-act

README.md
[![agentmods](https://agentmods.dev/badge/skills/vercel/next.js/router-act.svg)](https://agentmods.dev/skills/vercel/next.js/router-act)
Your own site
<a href="https://agentmods.dev/skills/vercel/next.js/router-act"><img src="https://agentmods.dev/badge/skills/vercel/next.js/router-act.svg" alt="Measured on agentmods" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,864 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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 $0.00071 $0.02864
Opus 5 $0.00036 $0.01432
Sonnet 5 $0.00014 $0.00573
Haiku 4.5 $0.00007 $0.00286

Measured 3d ago against content hash 3745edc85736, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

router-act 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 3d ago.

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.

.agents/skills/router-act/SKILL.md · 293 lines

How it starts

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

Router Act Testing

Use this skill when writing or modifying tests that involve prefetch requests, client router navigations, or the segment cache. The createRouterAct utility from test/lib/router-act.ts lets you assert on prefetch and navigation responses in an end-to-end way without coupling to the exact number of requests or the protocol details. This is why most client router-related tests use this pattern.

When NOT to Use act

Don't bother with act if you don't need to instrument the network responses — either to control their timing or to assert on what's included in them. If all you're doing is waiting for some part of the UI to appear after a navigation, regular Playwright helpers like browser.elementById(), browser.elementByCss(), and browser.waitForElementByCss() are sufficient.

Core Principles

  1. Use LinkAccordion to control when prefetches happen. Never let links be visible outside an act scope.
  2. Prefer 'no-requests' whenever the data should be served from cache. This is the strongest assertion — it proves the cache is working.
  3. Avoid retry/polling timers. The act utility exists specifically to replace inherently flaky patterns like retry() loops or setTimeout waits for network activity. If you find yourself wanting to poll, you're probably not using act correctly.
  4. Avoid the block feature. It's prone to false negatives. Prefer includes and 'no-requests' assertions instead.

Act API

Config Options

// Assert NO router requests are made (data served from cache).
// Prefer this whenever possible — it's the strongest assertion.
await act(async () => { ... }, 'no-requests')

// Expect at least one response containing this substring
await act(async () => { ... }, { includes: 'Page content' })

// Expect multiple responses (checked in order)
await act(async () => { ... }, [
  { includes: 'First response' },
  { includes: 'Second response' },
])

// Assert the same content appears in two separate responses
await act(async () => { ... }, [
  { includes: 'Repeated content' },
  { includes: 'Repeated content' },
])

// Expect at least one request, don't assert on content
await act(async () => { ... })

Read the full file on GitHub · 293 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. 3d ago First seen · 293 lines · 71 tokens per session scan A 3745edc85736

Subscribe to this mod's changes

router-act is a skill published in the GitHub repository vercel/next.js (142,020 stars, last pushed 3d ago), licensed MIT. It adds 71 tokens to every session and 2,864 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

testing

Test Radix NG primitives across every layer and pick the RIGHT one for a change: Vitest unit (zoneless), jest-axe a11y, Playwright browser regression (apps/visual-regression), SSR (apps/radix-ssr-testing), and perf benches (apps/radix-perf-testing). Enforces the rule that layout / positioning / part-visibility /…

radix-ng/primitives · 184 tokens

create-db-component

Creates a new DB UX Design System component with Mitosis source, SCSS, typed model, and Playwright tests.

db-ux-design-system/core-web · 29 tokens

test-component

Runs, analyzes, and fixes Playwright and accessibility tests for a specific DB UX component.

db-ux-design-system/core-web · 21 tokens

use-agent-browser-for-airi

Test AIRI display-model imports with agent-browser across stage-tamagotchi Electron, stage-web, and stage-pocket mobile web layouts. Use when uploading and verifying contributor-supplied Live2D ZIP, VRM, or MMD ZIP/PMX/PMD files through AIRI's model selector, including onboarding bypass, format-specific import…

moeru-ai/airi · 87 tokens

agui-dotnet-cross-language-tests

Author cross-language interop tests that verify the AG-UI .NET SDK is wire-compatible with the TypeScript SDK — a Vitest TS client driving a C# CrossLanguage.TestServer over HTTP, both directions, including protobuf byte-parity against @ag-ui/proto. USE FOR: adding or modifying cross-language interop coverage…

ag-ui-protocol/ag-ui · 146 tokens

cli-e2e-testcase-writer

Use when adding or updating Go CLI E2E coverage for one tests/clie2e/{domain} domain of the compiled lark-cli, especially when the work requires live --help or schema exploration, scenario-based clie2e.RunCmd workflows, and per-domain coverage.md maintenance.

larksuite/cli · 78 tokens