A local-first AI website generator: describe the site you want, and CodeFox builds it in a live Sandpack preview, editing real project files under ~/.codefox-local/projects. Built with Next.js 15, Bun, and the Vercel AI SDK.
- Split View Interface: Chat on the left (40%), iframe preview on the right (60%)
- AI-Powered Chat: Powered by Claude Sonnet 4.5 via OpenRouter API
- Smart URL Opening: AI can open websites directly in the iframe viewer
- Geek Theme: Dark theme with orange accents (#ff6b35)
- Resizable Panels: Drag the separator to adjust panel sizes
- Streaming Responses: Real-time AI responses with SSE
- Markdown Support: Rich text formatting and code highlighting
- Responsive Design: Works on desktop and mobile
-
Framework: Next.js 15 (App Router)
-
Runtime: Bun
-
Language: TypeScript
-
Styling: Tailwind CSS 4
-
AI SDK: Vercel AI SDK v7
-
Supported engines (auto-detected in this order, first match wins):
- Claude Code — uses your local
claudeCLI login (subscription, no API key), default when installed and logged in - Codex — uses your local
codexCLI login - OpenRouter — API fallback, needs
OPENROUTER_API_KEY
Force a specific engine with
CODEFOX_ENGINE=claude|codex|openrouter. The local engines run through@ai-sdk/harnessrooted at the project directory, so the agent edits your project files directly with its own coding tools. - Claude Code — uses your local
-
Icons: Lucide React
-
Markdown: react-markdown + react-syntax-highlighter
# Clone the repository
git clone <your-repo-url>
cd codefox-local
# Install dependencies
bun install
# Setup environment variables
cp .env.example .env.local
# Edit .env.local and add your OpenRouter API keyWith a logged-in claude or codex CLI on your PATH, no configuration is needed — the engine is detected automatically. Otherwise create a .env.local:
# Optional: force an engine instead of auto-detection (claude | codex | openrouter)
CODEFOX_ENGINE=
# Required only for the OpenRouter engine
OPENROUTER_API_KEY=your_openrouter_api_key_here
# OpenRouter model (harness engines use the CLI's default model)
NEXT_PUBLIC_DEFAULT_MODEL=anthropic/claude-sonnet-4.5
NEXT_PUBLIC_APP_NAME=CodeFox LocalGet an OpenRouter API key from: https://openrouter.ai/ — project title generation also uses OpenRouter and is skipped without a key.
# Development mode
bun run dev
# Production build
bun run build
# Start production server
bun run startOpen http://localhost:3000 in your browser.
The AI assistant can open websites using a special marker format:
User: "Open Google"
AI: "Sure! [OPEN_URL:https://www.google.com]"
The frontend automatically detects [OPEN_URL:...] markers and opens the URL in the iframe viewer.
- MainLayout: Resizable split-pane layout
- ChatContainer: Chat interface with messages and input
- IframeContainer: Web preview with URL controls
- ChatMessage: Individual message with markdown rendering
- API Route:
/api/chat- Handles streaming AI responses
The app uses a custom dark theme with orange accents. Main colors:
- Background:
#0a0a0a - Primary (Orange):
#ff6b35 - Gray Scale: Various shades from
#0a0a0ato#fafafa
Customize colors in app/globals.css.
- 设计文档 - 完整的技术设计和架构说明
- AI SDK v5 迁移指南 - AI SDK v5 迁移详情和 API 变更
codefox-local/
├── app/
│ ├── api/chat/route.ts # AI chat API endpoint
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Main page
│ └── globals.css # Global styles
├── components/
│ ├── chat/ # Chat components
│ ├── iframe/ # iframe components
│ └── layout/ # Layout components
├── lib/
│ └── utils.ts # Utility functions
├── types/
│ ├── chat.ts # Chat type definitions
│ └── iframe.ts # iframe type definitions
└── public/ # Static assets
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
- Built with Next.js
- Powered by Claude AI
- API via OpenRouter
- UI components inspired by shadcn/ui
Made with 💚 by CodeFox