This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an AI-powered wiki system with a FastAPI backend and React frontend. The system combines traditional wiki functionality with:
- AI Chat Assistant: Real-time AI assistance via WebSocket for wiki content
- Collaborative Threads: Shared workspaces where users and AI collaborate on wiki changes
- Git-Native Workflow: All changes tracked in git, threads work on branches (
thread/<name>-<hash>)
- Framework: FastAPI with WebSocket support for real-time communication
- Storage: Git-based wiki storage with GitWiki class (no database needed)
- AI Integration: OpenRouter API with wiki-specific tools (read/edit/find/list pages)
- Real-time: WebSocket endpoints for chat and live updates
- Session Management: Unified SessionManager handles main chat + thread sessions
- Thread System: Collaborative threads on git branches (
thread/<name>-<hash>) - Tool System: Composable tools via ToolBuilder (read/edit/thread-info)
- Framework: React 19 with TypeScript and Vite
- Styling: TailwindCSS v3.4.0 + Shadcn UI components (uses CSS variables in HSL format)
- UI Components: Shadcn UI with Prompt Kit for chat interface
- Layout: 3-panel resizable design (left: page tree, center: content/thread review, right: chat/threads)
- No routing - uses context-based state management for panel modes
- Right panel: Tabs for Chat/Threads switcher
- Center panel: Dynamic page view or thread changes review mode
- Real-time: WebSocket client for live communication
- State Management: React Context API with useReducer
rightPanelMode: 'chat' | 'threads'centerPanelMode: 'page' | 'thread-review'selectedThread: Current thread being reviewed
- Git Integration: Branch selector, branch creation/deletion
- Custom Scrollbars:
.custom-scrollbarand.chat-scrollbarclasses for consistent styling
Requires uv - fast Python package manager
make setup # Install Python + Node dependencies (first time only)
make run # Start both backend and frontendOther commands:
make backend- Start backend only (port 8000)make frontend- Start frontend only (port 5173)make clean- Remove .venv and node_modulesmake test- Run pytestmake haiku-tester- Run browser UI tests with Claude haiku
Windows: Install make via choco install make (requires Chocolatey)
├── CLAUDE.md # This file - project instructions
├── Makefile # Build commands (setup, run, clean, haiku-tester)
├── tests/ # Test infrastructure (Docker, haiku-tester)
├── backend/ # Python FastAPI backend
│ ├── main.py # FastAPI app entry point
│ ├── pyproject.toml # Python dependencies (uv)
│ ├── storage/ # Git-based wiki storage (GitWiki)
│ ├── ai/ # AI integration
│ │ ├── prompts.py # System prompts (ASSISTANT_PROMPT, THREAD_PROMPT)
│ │ ├── tools.py # WikiTool + ToolBuilder (composable tool sets)
│ │ └── adapters/ # LLM adapters (Claude SDK, OpenRouter)
│ ├── threads/ # Thread system (autonomous workers)
│ │ ├── thread.py # Thread, ThreadStatus, ThreadMessage
│ │ ├── accept_result.py # AcceptResult enum
│ │ └── git_operations.py # Git branch helpers
│ ├── agents/ # Agent execution
│ │ └── executor.py # AgentExecutor (LLM conversation loop)
│ ├── api/ # API layer
│ │ └── session_manager.py # SessionManager (WebSocket + sessions)
│ ├── scripts/ # Utility scripts
│ └── tests/ # Backend tests
└── frontend/ # React TypeScript frontend
├── src/
│ ├── components/
│ │ ├── layout/ # MainLayout, LeftPanel, CenterPanel, RightPanel
│ │ ├── chat/ # ChatInterface with StickToBottom scrolling
│ │ ├── pages/ # PageTree, PageItem
│ │ ├── git/ # BranchSwitcher with tags/delete
│ │ ├── agents/ # AgentPanel, PRReviewPanel, DiffViewer
│ │ └── ui/ # Shadcn UI components
│ ├── hooks/ # Custom React hooks
│ ├── contexts/ # AppContext with agent/PR state
│ ├── services/ # WebSocket, agents-api
│ ├── types/ # TypeScript type definitions (Agent, PullRequest, etc.)
│ └── utils/ # Utility functions
├── package.json # Node.js dependencies
└── vite.config.ts # Vite configuration
- Storage: Git-based with GitWiki class - all content in
Sviter-wiki/git submodule - WebSocket: Real-time communication on
/ws/{client_id}endpoint via SessionManager - Session Types:
- Main session: Read-only assistant with spawn_thread/list_threads tools
- Thread session: Collaborative workspace with read/edit/thread-info tools
- Thread Workflow:
- User creates thread via pink "Start thread" button with first message
- Threads work on branches:
thread/<name>-<hash> - Status is free-form string (AI uses set_thread_status to update)
- Accept merges to main (no reject button - just keep discussing)
- Git APIs:
/api/git/branches,/api/git/checkout,/api/git/diff, etc. - CORS: Configured for frontend connections
- No Routing: Context-based state management, no react-router-dom
- Panel Modes:
- Right panel: Chat/Threads tabs (
rightPanelMode) - Center panel: Page view or thread review (
centerPanelMode)
- Right panel: Chat/Threads tabs (
- WebSocket Integration: Automatic connection and reconnection to backend
- Page Management: Create, edit, view, delete pages with real-time sync
- Git Integration:
- Branch selector with branch creation/deletion
- Checkout branches with page reload
- Thread Management:
- Pink "Start thread" button creates new thread with user's message
- Thread selector shows git branch icon for threads
- Threads show free-form status text (set by AI)
- Click thread to view changes in center panel
- Accept button merges to main (no reject - just keep discussing)
- Markdown Support: Simple markdown parser for content rendering
- Error Handling: Error boundaries and loading states
- Keyboard Shortcuts: Ctrl+E (toggle edit), Escape (exit edit)
- Shadcn Components:
- MUST use Tailwind CSS v3.4.0 (NOT v4) - v4 is incompatible
- Components copied to
src/components/ui/(not npm packages) - Styling uses CSS variables in
src/index.css(format:--primary: 222.2 47.4% 11.2%) - Custom scrollbars defined in
src/index.csswith.custom-scrollbarand.chat-scrollbar
- Chat Interface:
- Uses Prompt Kit components (Message, PromptInput, etc.)
- Auto-scroll enabled via ChatContainer's StickToBottom component
- Proper flex layout with
min-h-0for scrolling - User messages: right-aligned with
bg-primarystyling - AI responses: left-aligned, markdown rendered
fastapi- Web frameworkuvicorn- ASGI serverwebsockets- WebSocket supportanthropic- Claude SDK for AI integrationgitpython- Git operationspytest- Testing framework
reactv19 - UI frameworktypescript- Type safetyvite- Build tooltailwindcssv3.4.0 - Styling (CRITICAL: must be v3, NOT v4)@radix-ui/*- Primitives for Shadcn componentsuse-stick-to-bottom- Auto-scroll for chatlucide-react- Icons@types/*- TypeScript definitions
- First time setup:
make setup - Run both servers:
make run - Agentic Testing: Use Claude for Chrome to test the application autonomously
Uses Claude haiku model with Chrome MCP to perform visual UI testing. Tests run in Docker containers for isolation.
make haiku-tester # Run all browser testsRequirements:
- Chrome with Claude extension installed and connected
- Docker for container management
- API key in
tests/.env(for AI chat tests in containers)
Test structure:
tests/
├── docker-compose.yml # Test containers config
├── Dockerfile.backend # Backend image for tests
├── .env # API keys (gitignored)
├── .env.example # Example env file
├── conftest.py # Pytest fixtures (testcontainers)
├── fixtures/wiki/ # Minimal test wiki pages
└── haiku-tester/ # Browser test files
└── test_views.py # UI tests (views, chat, navigation)
Note: Local development uses Claude subscription login. Docker containers require explicit ANTHROPIC_API_KEY since OAuth doesn't work in containers.
- Port Configuration: Backend on 8000, Frontend on 5173
- WebSocket URL: Frontend connects to
ws://localhost:8000/ws/ - Git Repository: Wiki content stored in
Sviter-wiki/submodule (https://github.com/honix/Sviter-wiki) - No Routing: Application uses context-based state, NOT react-router-dom
- Flexbox Scrolling: Use
min-h-0on flex children to enable proper scrolling - Real-time Features: Full bidirectional communication between frontend and backend
E2E tests use Playwright with a mock LLM adapter (no API calls needed).
CLI (local with Docker):
make e2e # Run all E2E tests in Docker
make e2e-clean # Clean up containersfrontend/e2e/app.spec.ts- Basic app tests (panels, page tree)frontend/e2e/user-journey.spec.ts- Full workflow (chat → thread → accept → verify)
Playwright auto-captures screenshots/videos on failure. Check:
frontend/test-results/- Screenshots, videos, tracesnpx playwright show-trace <trace.zip>- Interactive trace viewer
For manual debugging:
await page.screenshot({ path: 'debug.png' })- Branch creation: Thread branches created when user clicks "Start thread"
- Live page updates: Pages appear in tree as threads edit them (via
page_updatedWebSocket messages) - Branch cleanup: Accepted branches merged to main, worktree removed
thread_created/thread_updated- Thread lifecycle and status changespage_updated- Real-time page tree updates during thread executionassistant_message/tool_call/tool_result- Streaming conversation
- React 18 batching workaround: Use refs (
reloadFunctionsRefin AppContext) to call reload functions from WebSocket callbacks with empty deps - System prompt bubble: Full width styling in ChatInterface