agentleFS
VercelKnown publishervercel/next.js/turbopack/AGENTS.md

next.js / turbopack

AGENTS.md144k starsChanged 7 months agoMITView on GitHub

Turbopack is a general-purpose bundler that is built and designed for Next.js, but is not necessarily Next.js-specific. Keep Next.js concepts out of it. These apply to all Rust code in this directory tree. For building, testing, snapshot updates, and benchmarking, use $rust-turbopack. These rules apply throughout this directory tree when developing with turbo_tasks:

Trending

Less talk lately.about the whole repository

Dec 2025: 4 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 3 mentionsApr 2026: 2 mentionsMay 2026: 4 mentionsJun 2026: 4 mentionsJul 2026: 3 mentionsAug 2026: 2 mentionsSep 2026: 3 mentionsOct 2026: 3 mentionsNov 2026: 1 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the vercel/next.js repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about vercel/next.js

The biggest 5 of 92 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 92

Talked about on Bluesky, GitHub and Hacker News (92 times).

On Bluesky · 50

45 more on Bluesky

On GitHub · 26

21 more on GitHub

On Hacker News · 16

11 more on Hacker News

The file

We split this AGENTS.md into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run cargo fmt rather than ordering imports by hand: it uses ASCII order (uppercase before lowercase).

    line 11
  2. Very specific:

    Avoid adding new super:: imports except in inline mod blocks (e.g.

    line 12
  3. Distinctive:

    Keep task cache keys narrow: pass only the inputs the task needs.

    line 19
  4. Very specific:

    Avoid .cell() and Vc::cell() unless you know the current function is already called by functions with fine-grained cache keys.

    line 20
  5. Very specific:

    When task inputs need to be cells to preserve fine-grained caching, arrange for them to already be cells returned by …

    line 22
  6. Very specific:

    Do not blindly introduce "interning" task functions that only wrap values, such as Vec<T> -> Vc<Vec<T>>.

    line 23
  7. Distinctive:

    Put maps containing information for a large part of the build (for example, a map from modules to analysis results) into separate cells.

    line 25
  8. Very specific:

    Read keyed cells through keyed access, such as map.get(&key).await?, so invalidation depends only on the entries actually read.

    line 26
  9. Distinctive:

    When changing task boundaries, check the intended invalidation behavior.

    line 29

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Turbopack Development Guide

Turbopack is a general-purpose bundler that is built and designed for Next.js, but is not necessarily Next.js-specific. Keep Next.js concepts out of it.

  • Do NOT mention Next.js config options (e.g. anything under next.config.js, experimental.*, or other NextConfig fields) inside turbopack/ code, comments, or docs. Refer to Turbopack's own options/inputs instead, and let the Next.js (in packages/next/) do the translation from Next.js config to Turbopack options. (This only applies to turbopack/ — the Next.js-specific crates in crates/ and packages/next/ may reference Next.js config options.)

Rust conventions

These apply to all Rust code in this directory tree. For building, testing, snapshot updates, and benchmarking, use $rust-turbopack.

  • Run cargo fmt rather than ordering imports by hand: it uses ASCII order (uppercase before lowercase).
  • Avoid adding new super:: imports except in inline mod blocks (e.g. mod tests { ... }). Prefer crate::-rooted paths, which keep imports consistent and easier to grep for.
  • In JavaScript generated with Rust format!, escape literal braces as {{ and }}.

turbo_tasks caching and invalidation

These rules apply throughout this directory tree when developing with turbo_tasks:

  • Keep task cache keys narrow: pass only the inputs the task needs. Avoid build-wide state or large collections when a per-module or per-entry input would suffice.
  • Avoid .cell() and Vc::cell() unless you know the current function is already called by functions with fine-grained cache keys. Inspect the callers and task boundaries before creating cells.
  • Pass booleans, enums, and similar small values directly as TaskInput where appropriate instead of wrapping them in cells.
  • When task inputs need to be cells to preserve fine-grained caching, arrange for them to already be cells returned by #[turbo_tasks::function] functions.
  • Do not blindly introduce "interning" task functions that only wrap values, such as Vec<T> -> Vc<Vec<T>>. Only add such a task when you are certain it is beneficial in that particular situation.
  • Existing .cell() calls or wrapping tasks are not automatically good precedent. Verify their caller and cache-key assumptions before copying the pattern.
  • Put maps containing information for a large part of the build (for example, a map from modules to analysis results) into separate cells. Use cell = "keyed" on their value types, for example #[turbo_tasks::value(transparent, cell = "keyed")] for a map wrapper.
  • Read keyed cells through keyed access, such as map.get(&key).await?, so invalidation depends only on the entries actually read. Awaiting the entire map and then looking up a key creates a dependency on the whole map instead.
  • When a task reads many keys of the same keyed cell, use let map = map.keyed_reader().await?; and then the synchronous map.get(&key) / map.contains_key(&key). It reads the cell once and, when the KeyedReadRef is dropped, narrows the dependency to the accessed keys in one batch. The KeyedReadRef (and the keyed_reader() future) must be dropped within the task execution that called keyed_reader(): don't return, store, leak, or move them to other threads or tasks. Otherwise completing the task execution panics, which aborts the process.
  • When a task only needs a cell's value in some cases, and only finds out in synchronous code, use let value = vc.lazy_reader().await?; and access it with value.get(). When the LazyReadRef is dropped without get() ever being called, the read is canceled: the task no longer depends on the cell through it. The same lifetime rules as for KeyedReadRef apply.
  • When changing task boundaries, check the intended invalidation behavior. An unrelated module change should not invalidate consumers of unchanged keyed entries; correct output alone does not demonstrate good cache granularity.
  • Cell equality must include every observable distinction: comparison can retain the old value when the new value compares equal. In particular, IndexSet has deterministic iteration order but order-insensitive equality. Use Vec or an order-sensitive comparison when order is semantic or another cell stores positional indices into the collection; otherwise a reorder can leave old data paired with new indices even after recomputation settles.
  • A #[turbo_tasks::value_impl] block should contain task functions. Put plain helpers in free functions.
  • Task functions receive clones of their inputs. Don't infer the capacity of a stored input from the value inside the function.
  • In #[turbo_tasks::function] functions, if an argument needs to be resolved unconditionally, accept ResolvedVc<T> instead of accepting Vc<T> and calling .to_resolved().await? on it. The task macro automatically resolves arguments declared as ResolvedVc<T>, so callers do not need to manually resolve them before passing them in.

Eventual consistency

  • Reads of separate cells can observe different executions during recomputation, even when the cells are produced by the same task or referenced through ResolvedVc. Do not assume a parent cell and its child/index cells form an atomic snapshot.
  • For cross-cell indices and lookups, handle transient mismatches with bail! or other Result::Err returns. Do not use panicking indexing, unwrap/expect or assertions.
  • Bounds checks prevent panics, not torn reads: an in-range index can still select the wrong value from another execution, for example leading to unexpected enum variants.

Turbopack

These rules apply specifically to the turbopack-* crates and wherever they are used.

  • AssetContext identity directly influences module identity. Avoid creating a slightly different context for a single module or import: the same source can become distinct modules under different contexts, potentially producing duplicate modules with colliding module IDs.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.