Next Cache Mutation Gate

    1

    Stop stale UIs and cross-user cache leaks after Next.js mutations.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Next Cache Mutation Gate

    Example session with this skill installed

    Audit my updateOrgName Server Action. It updates the DB but the dashboard header still shows the old name until I refresh the whole page. How do I fix the stale cache?

    • Read your context and instructions
    • Compiled the next cache mutation

    I have audited the updateOrgName action and the dashboard rendering logic. The stale state is caused by a missing invalidation call in the Server Action and a lack of specific tags in the cached query.

    Cache inventory

    • getOrgData: unstable_cache | tags: ['org-data'] | Shared across all orgs (Risk).
    • updateOrgName: Server Action | Write: db.org.update | No revalidation found.

    Audit Findings and Patch

    ComponentFindingSeverityEvidence
    Mutation InvalidateMissing revalidateTagMajorAction completes but getOrgData cache remains hit.
    Cache Key ScopeGlobal tag used for tenant dataBlockerrevalidateTag('org-data') would purge all orgs.

    Hardening Patch

    // 1. Define granular tags
    export const tags = {
      orgData: (orgId: string) => `org:${orgId}:data`,
    } as const;
    
    // 2. Update cached read
    export function getOrgData(orgId: string) {
      return unstable_cache(
        async () => db.org.findUnique({ where: { id: orgId } }),
        [`org-data-${orgId}`],
        { tags: [tags.orgData(orgId)] }
      )();
    }
    
    // 3. Fix the mutation
    export async function updateOrgName(orgId: string, name: string) {
      const user = await auth();
      if (!user) throw new Error("Unauthorized");
      
      await db.org.update({ where: { id: orgId }, data: { name } });
      
      // Invalidate specific tenant tag
      revalidateTag(tags.orgData(orgId));
    }
    

    Residual risks

    Client Cache: Ensure the frontend calls router.refresh() if the layout doesn't automatically reflect the RSC change.

    • Edge Lag: If using a multi-region database, the revalidation might fire before the replica is consistent.

    Next steps

    • Move tag definitions to a centralized lib/cache-tags.ts.
    • Update the dashboard layout to use the new getOrgData(orgId) function.
    • Verify that updating Org A does not trigger a cache miss for Org B.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Stop stale UIs and cross-user cache leaks after Next.js mutations. Audits App Router Data Cache, Full Route Cache, and unstable_cache around writes. Returns Cache inventory, Gate findings, Hardening patch, and Residual risks. Covers missing revalidateTag/Path, personalized data cached globally, and weak cache keys. Includes checklist, patterns, anti-patterns, and a bad-to-good profile update example. Complements Server Action AuthZ and Zod Contract Sync; does not replace authorization.

    Focuses on Next.js server-side caching. Does not replace authorization logic. Does not manage external CDN purges or browser-level caching.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 21 days ago

    Permissions

    Network Access
    Listed21 days ago

    What's inside

    Frequently Asked Questions

    This skill audits Next.js App Router applications to identify stale UI states and critical security vulnerabilities, such as private user data being accidentally cached and served to other users.

    It is specifically built for Next.js 13+ using the App Router, including full support for Server Actions, `unstable_cache`, and the Data Cache layer.

    No, this skill focuses on the internal Next.js server-side cache; you should still maintain standard server-side authorization checks and session management.

    The skill scans your fetch configurations and Server Actions to ensure every data mutation is paired with the correct `revalidateTag` or `revalidatePath` call.

    You receive the specialized AI agent logic, a framework for identifying cache surfaces, and a library of hardening patterns for tag-based invalidation.

    Yes, it identifies inefficient global revalidation calls and provides specific code patches to refactor them into granular, high-performance tag structures.

    New in Frontend & Web Apps