OpenCode setup for Next.js: skills, tools and security checks
3 min readAI Agents · Next.js · Developer Tools · Guides
A coding agent is only as good as the instructions and tools around it. This is my setup list for OpenCode on a Next.js project: agent skills, docs lookup, testing, security and shipping checks. Every block is meant to be copied. Run the commands from your project root.
Before you start
You need a recent Node.js. The skills CLI currently asks for 22.20 or newer. Skills are third-party instructions that your agent will follow, so read each SKILL.md before trusting it. Install what you need, not everything.
node -v
npx skills listFrontend and UI skills
Design direction, UI review, accessibility and shadcn/ui.
npx skills add anthropics/skills --skill frontend-design -a opencode
npx skills add nextlevelbuilder/ui-ux-pro-max-skill --skill ui-ux-pro-max -a opencode
npx skills add vercel-labs/agent-skills --skill web-design-guidelines -a opencode
npx skills add addyosmani/agent-skills --skill frontend-ui-engineering -a opencode
npx skills add addyosmani/agent-skills --skill accessibility-engineering -a opencode
npx skills add shadcn/ui --skill shadcn -a opencodeReact and Next.js skills
The two Vercel skills are named vercel-react-best-practices and vercel-composition-patterns. The shorter folder names fail with a no matching skills error.
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices -a opencode
npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns -a opencode
npx skills add vercel/next.js -a opencode
npx skills add sickn33/agentic-awesome-skills --skill nextjs-app-router-patterns -a opencode
npx skills add wshobson/agents --skill react-state-management -a opencode
npx skills add millionco/react-doctor --skill react-doctor -a opencodeTesting and code quality
npx skills add anthropics/skills --skill webapp-testing -a opencode
npx skills add Heyvhuang/copybook-skills -a opencode
npx skills add addyosmani/agent-skills --skill code-review-and-quality -a opencode
npx skills add addyosmani/agent-skills --skill debugging-and-error-recovery -a opencode
npx skills add addyosmani/agent-skills --skill git-workflow-and-versioning -a opencode
npx skills add addyosmani/agent-skills --skill api-and-interface-design -a opencodeSecurity, SEO and production skills
npx skills add addyosmani/agent-skills --skill security-and-hardening -a opencode
npx skills add laguagu/claude-code-nextjs-skills --skill nextjs-seo -a opencode
npx skills add faisalinfinity/nextjs-production-skill --skill nextjs-ship-ready -a opencode
npx skills add addyosmani/agent-skills --skill performance-optimization -a opencodeContext7 for current docs
Context7 gives the agent up-to-date library documentation. Pick one of these two routes. Option one is the setup command:
npx ctx7 setup --opencodeOption two is the plugin. The command below is for OpenCode v2; on v1 use opencode plugin @upstash/context7-opencode. Restart OpenCode after installing.
opencode plugin add @upstash/context7-opencode
opencode mcp auth context7Playwright and browser automation
Playwright is for tests you keep in the repo. agent-browser lets an agent drive a browser from the terminal. On Linux, add --with-deps to the Playwright install if system libraries are missing.
npm init playwright@latest
npx playwright install
npm install -g agent-browser
agent-browser installLighthouse for performance and SEO
Replace the domain with yours. Audit a production build, not the dev server.
npm install -g lighthouse
lighthouse https://your-domain.com --view
lighthouse https://your-domain.com --output htmlA global AGENTS.md for security rules
OpenCode reads global rules from ~/.config/opencode/AGENTS.md. Note the file name: AGENTS.md, not Agent.md. Paste this in.
# Security Engineering Rules
Follow secure development practices for every feature.
1. Never expose API keys, tokens, passwords or secrets in frontend code.
2. Store secrets in environment variables.
3. Validate all user input on the server.
4. Use authentication and authorization checks on every protected API.
5. Prevent SQL injection, XSS, CSRF and SSRF.
6. Apply rate limiting to sensitive endpoints.
7. Use secure session and cookie configurations.
8. Never trust client-side role or permission checks.
9. Protect Server Actions and Route Handlers.
10. Use least-privilege database permissions.
11. Audit dependencies and check for known vulnerabilities.
12. Run Gitleaks before committing.
13. Scan Docker images and dependencies before production.
14. Never claim a security test passed without running it.
15. Report vulnerabilities by severity: Critical, High, Medium, Low.
Before deployment:
- Run npm audit.
- Run Gitleaks.
- Run Semgrep.
- Run Trivy.
- Run OWASP ZAP against authorized test environments.
- Verify authentication, authorization and API security.
- Review environment variables and production configuration.Scans before you deploy
Install Gitleaks, Semgrep and Trivy first using their official instructions. Run OWASP ZAP only against systems you are authorised to test.
npm audit
gitleaks git .
semgrep scan --config auto
trivy fs .NjordScan is an extra scanner for Next.js, React and Vite apps. Version 2.0 is in beta, so --pre is required.
python3 -m venv .venv && source .venv/bin/activate
pip install --pre njordscan
njordscan scan .Where it bites
- Too many skills - overlapping advice can confuse the agent and use up context.
- Third-party content - skills change upstream. Review them, and again after
npx skills update. - Large collections - some repos hold many skills, so keep the
--skillflag. - Scanners - a clean report is not proof that the app is secure.
Start small: the frontend, React and security skills, then add the rest when a real task needs them.

Written by
Shihab Hossain — Full-Stack Developer
I build thoughtful digital products from Bangladesh — fast web experiences with Next.js, Android apps with Flutter, and the infrastructure behind them.
Work with me