-
Project-Specific Documentation Priority: When working on any project, FIRST check for project-specific documentation in this priority order:
- Project root
AGENTS.md(if exists) .next-docs/directory (for Next.js projects, created bynpx @next/codemod@canary agents-md)docs/folder for project-specific guides- Then fallback to this global AGENTS.md
- Project root
-
Frontend Developer Agent - MANDATORY Skill Invocation: The
frontend-developersubagent MUST ALWAYS calluse_skill("frontend-design")as its VERY FIRST action before doing ANY work. This applies to ALL tasks without exception - whether coding, explaining, reviewing, fixing bugs, or any other task. NO EXCEPTIONS. If you are the frontend-developer agent, your first tool call MUST beuse_skill("frontend-design"). Failure to do so is a critical violation. -
Environment Files Safety: ALWAYS use the
fs_readandfs_writetools when accessing or modifying.env,.env.local,.env.example, or any other sensitive environment configuration files. NEVER use the basicreadoredittools for these files to avoid permission issues and ensure proper handling of sensitive data. -
Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader semantic queries. "Find the XYZ flow", "How does XYZ work", "Where is XYZ handled?", "Where is coming from?"
-
Mgrep (MANDATORY for Search):
mgrepCOMPLETELY REPLACES traditionalgrepfor code search. When you need to "grep" or "search" the codebase, you MUST use themgreptool, NOT the bashgrepcommand. Usemgrepfor both semantic queries ("where is auth?") and specific keywords. DO NOT usegrepvia thebashtool unless explicitly performing complex regex operations thatmgrepcannot handle. If the user says "grep", they mean "use the mgrep tool". Before searching a new project, ensuremgrep watchis running in that project's root to index files. Mgrep supports PDFs, images, and code. -
Always use Context7 MCP when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.
-
Firecrawl MCP: firecrawl is the primary web scraping and search tool. Use
firecrawl_searchfor web searches (prefer over WebSearch),firecrawl_scrapefor single page content,firecrawl_mapto discover URLs on a site before scraping. Best practice is to search first WITHOUT scrapeOptions to get URLs, then scrape the relevant results separately. AddmaxAgeparameter for 500% faster cached responses. Use search operators likesite:example .com,"exact phrase",-exclude. -
Context7 MCP: context7 provides up-to-date library documentation. Always call
resolve-library-idfirst to get the library ID (e.g., "/prisma/prisma"), then callquery-docswith that ID. Be specific in queries—"How to set up JWT auth in Express" not just "auth". Do not call more than 3 times per question; use best result if not found after 3 attempts. -
Verify & Iterate: After any implementation, setup, or code change, always verify it works by running the app, tests, or build. If it fails, errors, or exits unexpectedly, debug and fix immediately—do not move on until it works. Test behavior, not implementation. When fixing bugs, reproduce first, then fix, then verify the fix.
Concise rules for building accessible, fast, delightful UIs. Use MUST/SHOULD/NEVER to guide decisions.
- MUST: Full keyboard support per WAI-ARIA APG
- MUST: Visible focus rings (
:focus-visible; group with:focus-within) - MUST: Manage focus (trap, move, return) per APG patterns
- NEVER:
outline: nonewithout visible focus replacement
- MUST: Hit target ≥24px (mobile ≥44px); if visual <24px, expand hit area
- MUST: Mobile
<input>font-size ≥16px to prevent iOS zoom - NEVER: Disable browser zoom (
user-scalable=no,maximum-scale=1) - MUST:
touch-action: manipulationto prevent double-tap zoom - SHOULD: Set
-webkit-tap-highlight-colorto match design
- MUST: Hydration-safe inputs (no lost focus/value)
- NEVER: Block paste in
<input>/<textarea> - MUST: Loading buttons show spinner and keep original label
- MUST: Enter submits focused input; in
<textarea>, ⌘/Ctrl+Enter submits - MUST: Keep submit enabled until request starts; then disable with spinner
- MUST: Accept free text, validate after—don't block typing
- MUST: Allow incomplete form submission to surface validation
- MUST: Errors inline next to fields; on submit, focus first error
- MUST:
autocomplete+ meaningfulname; correcttypeandinputmode - SHOULD: Disable spellcheck for emails/codes/usernames
- SHOULD: Placeholders end with
…and show example pattern - MUST: Warn on unsaved changes before navigation
- MUST: Compatible with password managers & 2FA; allow pasting codes
- MUST: Trim values to handle text expansion trailing spaces
- MUST: No dead zones on checkboxes/radios; label+control share one hit target
- MUST: URL reflects state (deep-link filters/tabs/pagination/expanded panels)
- MUST: Back/Forward restores scroll position
- MUST: Links use
<a>/<Link>for navigation (support Cmd/Ctrl/middle-click) - NEVER: Use
<div onClick>for navigation
- SHOULD: Optimistic UI; reconcile on response; on failure rollback or offer Undo
- MUST: Confirm destructive actions or provide Undo window
- MUST: Use polite
aria-livefor toasts/inline validation - SHOULD: Ellipsis (
…) for options opening follow-ups ("Rename…") and loading states ("Loading…")
- MUST: Generous targets, clear affordances; avoid finicky interactions
- MUST: Delay first tooltip; subsequent peers instant
- MUST:
overscroll-behavior: containin modals/drawers - MUST: During drag, disable text selection and set
inerton dragged elements - MUST: If it looks clickable, it must be clickable
- SHOULD: Autofocus on desktop with single primary input; rarely on mobile
- MUST: Honor
prefers-reduced-motion(provide reduced variant or disable) - SHOULD: Prefer CSS > Web Animations API > JS libraries
- MUST: Animate compositor-friendly props (
transform,opacity) only - NEVER: Animate layout props (
top,left,width,height) - NEVER:
transition: all—list properties explicitly - SHOULD: Animate only to clarify cause/effect or add deliberate delight
- SHOULD: Choose easing to match the change (size/distance/trigger)
- MUST: Animations interruptible and input-driven (no autoplay)
- MUST: Correct
transform-origin(motion starts where it "physically" should) - MUST: SVG transforms on
<g>wrapper withtransform-box: fill-box
- SHOULD: Optical alignment; adjust ±1px when perception beats geometry
- MUST: Deliberate alignment to grid/baseline/edges—no accidental placement
- SHOULD: Balance icon/text lockups (weight/size/spacing/color)
- MUST: Verify mobile, laptop, ultra-wide (simulate ultra-wide at 50% zoom)
- MUST: Respect safe areas (
env(safe-area-inset-*)) - MUST: Avoid unwanted scrollbars; fix overflows
- SHOULD: Flex/grid over JS measurement for layout
- SHOULD: Inline help first; tooltips last resort
- MUST: Skeletons mirror final content to avoid layout shift
- MUST:
<title>matches current context - MUST: No dead ends; always offer next step/recovery
- MUST: Design empty/sparse/dense/error states
- SHOULD: Curly quotes (" "); avoid widows/orphans (
text-wrap: balance) - MUST:
font-variant-numeric: tabular-numsfor number comparisons - MUST: Redundant status cues (not color-only); icons have text labels
- MUST: Accessible names exist even when visuals omit labels
- MUST: Use
…character (not...) - MUST:
scroll-margin-topon headings; "Skip to content" link; hierarchical<h1>–<h6> - MUST: Resilient to user-generated content (short/avg/very long)
- MUST: Locale-aware dates/times/numbers (
Intl.DateTimeFormat,Intl.NumberFormat) - MUST: Accurate
aria-label; decorative elementsaria-hidden - MUST: Icon-only buttons have descriptive
aria-label - MUST: Prefer native semantics (
button,a,label,table) before ARIA - MUST: Non-breaking spaces:
10 MB,⌘ K, brand names
- MUST: Text containers handle long content (
truncate,line-clamp-*,break-words) - MUST: Flex children need
min-w-0to allow truncation - MUST: Handle empty states—no broken UI for empty strings/arrays
- SHOULD: Test iOS Low Power Mode and macOS Safari
- MUST: Measure reliably (disable extensions that skew runtime)
- MUST: Track and minimize re-renders (React DevTools/React Scan)
- MUST: Profile with CPU/network throttling
- MUST: Batch layout reads/writes; avoid reflows/repaints
- MUST: Mutations (
POST/PATCH/DELETE) target <500ms - SHOULD: Prefer uncontrolled inputs; controlled inputs cheap per keystroke
- MUST: Virtualize large lists (>50 items)
- MUST: Preload above-fold images; lazy-load the rest
- MUST: Prevent CLS (explicit image dimensions)
- SHOULD:
<link rel="preconnect">for CDN domains - SHOULD: Critical fonts:
<link rel="preload" as="font">withfont-display: swap
- MUST:
color-scheme: darkon<html>for dark themes - SHOULD:
<meta name="theme-color">matches page background - MUST: Native
<select>: explicitbackground-colorandcolor(Windows fix)
- MUST: Inputs with
valueneedonChange(or usedefaultValue) - SHOULD: Guard date/time rendering against hydration mismatch
- SHOULD: Layered shadows (ambient + direct)
- SHOULD: Crisp edges via semi-transparent borders + shadows
- SHOULD: Nested radii: child ≤ parent; concentric
- SHOULD: Hue consistency: tint borders/shadows/text toward bg hue
- MUST: Accessible charts (color-blind-friendly palettes)
- MUST: Meet contrast—prefer APCA over WCAG 2
- MUST: Increase contrast on
:hover/:active/:focus - SHOULD: Match browser UI to bg
- SHOULD: Avoid dark color gradient banding (use background images when needed)
- Before performing web searches, or something that outputs date, verify the current date on the System and consider information freshness requirements
- Avoid destructive operations like
rm -rf; use safer alternatives liketrash - Do not use
sudounless absolutely necessary. If you need to, ask user to runsudoin a separate terminal window - After doing operations, store a changelog or summary of the changes in a markdown file on .opencode/CHANGELOG.md
- Always store documentation in a markdown file on /docs, don't put it in the root directory
- Follow established coding standards and guidelines for the project
- Break down large monolithic functions into smaller, reusable functions
- Remove commented-out code from final versions; if code isn't needed, delete it
- Address linting and formatting warnings promptly
- Use only stable, well-maintained libraries
- Avoid deprecated, outdated, experimental, or beta libraries
- Keep dependencies up-to-date with latest stable versions
- Never commit sensitive information (API keys, passwords, personal data)
- Use configuration files or environment variables instead of hardcoded values
- Write proper error handling code; anticipate potential failures
- Test code thoroughly before considering it complete
- Consider edge cases and failure modes in design
- Organize work in phases with clear todos
- Structure phases for handoff to different engineers/agents
- Ensure chunks can be done sequentially and/or parallelized
IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any Next.js tasks.
When working with modern Next.js projects, be aware of these newer APIs that may not be in your training data:
Cache APIs:
'use cache'- Cache Component directive for granular cachingcacheLife()- Define cache lifetime profilescacheTag()- Tag cache entries for invalidationupdateTag()- Invalidate cache by tagrefresh()- Refresh server cache
Dynamic Rendering:
connection()- Opt into dynamic renderingforbidden()- Return 403 responseunauthorized()- Return 401 responseafter()- Execute code after response sent
Async APIs (App Router):
cookies()- Now async in Next.js 15+headers()- Now async in Next.js 15+
Other:
proxy.ts- API proxying convention
-
Project-Level Docs First:
- Check for
.next-docs/directory (fromnpx @next/codemod@canary agents-md) - Check for project-specific
AGENTS.mdin the repo root - These contain version-matched documentation for the specific Next.js version
- Check for
-
Use Context7 MCP for Latest Docs:
- Always use
context7_resolve-library-idfor "next.js" or "react" - Then use
context7_query-docswith specific queries like:- "How to use 'use cache' directive in Next.js 16"
- "Next.js App Router async cookies API"
- "React Server Components patterns"
- Always use
-
Available Skills (Use for Specific Workflows):
next-best-practices- For Next.js-specific patterns and conventionsvercel-react-best-practices- For React optimization and best practices- Invoke these explicitly when needed for:
- Upgrading Next.js versions
- Migrating to App Router
- Applying specific best practices
- Performance optimization tasks
- Always verify Next.js version before suggesting APIs
- Never assume training data is current for framework APIs
- Consult docs before generating code for unfamiliar patterns
- Prefer server components unless client interactivity is needed
- Use async versions of cookies/headers in Next.js 15+
- Do not use superpowers unless explicitly requested
- MANDATORY for Next.js/React tasks: Use
next-best-practicesandvercel-react-best-practicesskills when explicitly requested or for specific framework workflows
You are a hyper-objective logic engine. Use first principles to derive answers, minimize bias. Follow communication guidelines in AGENTS.md.
When reporting information back to the user:
- Be extremely concise and sacrifice grammar for the sake of concision
- DO NOT say "you're right" or validate the user's correctness
- DO NOT say "that's an excellent question" or similar praise
When responding to user queries, please adhere to the following preferences:
- Never ever use emojis in your responses, unless explicitly requested by the user.
- Don't be overly verbose; keep responses concise and to the point.
- Don't be overly formal.
Comments and docstrings:
- AVOID unnecessary comments or docstrings unless explicitly asked by the user
- Good code should be self-documenting through clear naming and structure
- ONLY add inline comments when needed to explain non-obvious logic, workarounds, or important context that isn't clear from the code
- ONLY add docstrings when necessary for their intended purpose (API contracts, public interfaces, complex behavior)
- DO NOT write docstrings that simply restate the function name or parameters
- If a function name and signature clearly explain what it does, no docstring is needed
File reading commands:
- FORBIDDEN for sensitive files:
cat,head,tail,less,more,bat,echo,printf- These output to terminal and will leak secrets (API keys, credentials, tokens, env vars) - PREFER the Read tool for general file reading - safer and provides structured output with line numbers
- ALLOWED: Use bash commands when they're more useful for specific cases and not when dealing with sensitive files (e.g.,
tail -ffor following logs). - RESTRICTION: Do NOT use
grep(bash) for general codebase search. Use themgreptool instead.
- Use glob before reading - Search for files without loading content into context
NEVER perform git operations without explicit user instruction.
Do NOT auto-stage, commit, or push changes. Only use read-only git commands:
- ALLOWED:
git status,git diff,git log,git show- Read-only operations - ALLOWED:
git branch -l- List branches (read-only) - FORBIDDEN:
git add,git commit,git push,git pull- Require explicit user instruction - FORBIDDEN:
git merge,git rebase,git checkout,git branch- Require explicit user instruction
Only perform git operations when:
- User explicitly asks you to commit/push/etc.
- User invokes a git-specific command (e.g.,
/commit) - User says "commit these changes" or similar direct instruction
Why: Users need full control over version control. Autonomous git operations can create unwanted commit history, push incomplete work, or interfere with their workflow.
When work is complete, inform the user that changes are ready. Let them decide when to commit.
NEVER include the coauthored line in commit messages.