A Next.js template for building applications that serve AI agents first, humans second. Authentication uses fishnet-auth -- a reverse CAPTCHA that verifies callers are AI agents by having them solve reasoning tasks.
# 1. Install dependencies
npm install
# 2. Set up environment variables
cp .env.example .env.local
# Edit .env.local and set a strong FISHNET_AUTH_SECRET
# 3. Start the dev server
npm run devVisit http://localhost:3000
- Agent requests a challenge:
GET /api/agent-auth?name=AgentName - Server returns reasoning tasks (reverse strings, sort arrays, etc.)
- Agent solves tasks and submits answers:
POST /api/agent-auth - Server verifies answers and issues a bearer token
- Agent uses the token for all subsequent API calls
No API keys to manage. No LLM cost on the server. Agents prove intelligence on their own.
Agents discover your service via the standard skill.md endpoint:
curl http://localhost:3000/.well-known/skill.mdsrc/
app/
.well-known/skill.md/route.ts # RFC 8615 compliant discovery endpoint
skill.md/route.ts # Alternative skill.md endpoint
api/
agent-auth/ # fishnet-auth handlers (GET challenge, POST solve)
[[...fishnet-auth]]/route.ts
protected/route.ts # Example protected endpoint
health/route.ts # Health check
sessions/ # Demo session management
join/route.ts
[sessionId]/state/route.ts
test/route.ts # Auth test endpoint
demo/solve/route.ts # Demo solver endpoint
demo/fishnet/page.tsx # Interactive auth demo UI
page.tsx # Landing page
lib/
fishnet.ts # fishnet-auth configuration
.well-known/skill.md # Static skill documentation
public/skill-content.md # Skill content served by routes
- fishnet-auth -- Reverse CAPTCHA authentication. Agents solve reasoning tasks to prove intelligence.
- skill.md endpoints -- Both
/.well-known/skill.mdand/skill.mdroutes for agent discovery. - Agent-first UI -- Landing page separates agent and developer paths.
- Skill prompt template --
skill-prompt.mdgenerates yourskill.mddocs via LLM. - Demo endpoints -- Working session management and auth flow to test with immediately.
- End-to-end test script --
test-anthropic.shruns the full auth flow using Claude as the solver. See TESTING.md for details.
- Update
public/skill-content.mdwith your API documentation - Replace demo session endpoints with your actual API routes
- Adjust fishnet-auth difficulty in
src/lib/fishnet.ts - Add a real database to replace the in-memory demo storage
- Use
skill-prompt.mdto regenerate yourskill.mdwhen your API changes
| Variable | Required | Description |
|---|---|---|
FISHNET_AUTH_SECRET |
Yes | Secret used to sign fishnet-auth tokens. Generate a strong random string. |
NEXT_PUBLIC_BASE_URL |
No | Base URL for the app. Defaults to http://localhost:3000. |
ANTHROPIC_API_KEY |
No | Anthropic API key. Only needed for running test-anthropic.sh. Get one at console.anthropic.com. |
Works with any Next.js deployment platform (Vercel, Netlify, self-hosted, etc.).
Before deploying:
- Set
FISHNET_AUTH_SECRETto a strong random value - Set
NEXT_PUBLIC_BASE_URLto your production URL - Update the Base URL in
public/skill-content.md - Replace in-memory storage with a persistent database
- Add rate limiting for production traffic