Pythinker is an AI Agent system that runs tools (browser, terminal, files, search) in isolated Docker sandbox environments. FastAPI backend with Domain-Driven Design, Vue 3 frontend, Docker containers for task isolation.
Read instructions.md first — it defines the core behavioral contract (assumptions, simplicity, surgical changes, goal-driven execution).
These extend instructions.md with project-specific constraints:
- Reuse First: Search existing codebase before creating anything new — never duplicate logic, constants, or structure
- Self-Hosted First: Prioritize self-hosted, zero-cost, open-source solutions with no external dependencies
- Dependency Rule: Domain → Application → Infrastructure → Interfaces (inward only)
- Type Safety: Full type hints (Python) / strict mode (TypeScript); no
any - Context7 Validation: Validate new implementations against fetched Context7 MCP documentation before deployment
./dev.sh watch # Start stack with live file watch (recommended)
./dev.sh up -d # Start without watch
./dev.sh down -v # Stop and remove volumes
./dev.sh logs -f backend # Follow logscd backend && conda activate pythinker
ruff check . && ruff format --check . # Lint
ruff check --fix . && ruff format . # Auto-fix
pytest tests/path/to/test_file.py # Targeted tests (ALWAYS prefer this)
pytest -p no:cov -o addopts= tests/test_file.py # Single test without coverage
# NEVER run `pytest tests/` (full suite) unless explicitly askedcd frontend
bun run dev # Dev server (5173)
bun run lint # ESLint fix
bun run type-check # TypeScript check
bun run test:run # Single test run# Backend
cd backend && ruff check . && ruff format --check . && pytest tests/<relevant-dir-or-file>
# Frontend
cd frontend && bun run lint && bun run type-check- Split into multiple atomic commits grouped by logical concern
- Each commit must be independently revertable — one concern, one commit
- Format:
fix(scope)/feat(scope)/refactor(scope)/chore(scope)/docs(scope)/test(scope) - Stage files selectively with
git add <specific-files>— nevergit add .for multi-concern changesets
- domain/: Core business logic, models, services, abstract repositories
- application/: Use case orchestration, DTOs
- infrastructure/: MongoDB/Redis implementations, external adapters (LLM, browser, search)
- interfaces/api/: REST routes, request/response schemas
- core/: Config, sandbox manager, workflow manager
- pages/: Route components (ChatPage, HomePage)
- components/: UI components (ChatMessage, SandboxViewer, ToolPanel)
- composables/: Shared logic (useChat, useSession, useAgentEvents)
- api/: HTTP client with SSE support
- Event Sourcing: Session events in MongoDB
- SSE Streaming: Real-time events to frontend
- Sandbox Isolation: Docker containers with CDP screencast
- HTTPClientPool: Always use
HTTPClientPoolfor HTTP communication. Never createhttpx.AsyncClientdirectly. - APIKeyPool: Always use
APIKeyPoolfor external API providers. Never create direct API clients without key pool integration. - Pydantic v2:
@field_validatormethods must be@classmethod - Python environment: Always
conda activate pythinkerbefore running backend tests - Full implementations only: Never use placeholders (
// ... rest of code). If complex, output as much as possible and wait for "Continue". - Pre-existing errors: Never skip or work around pre-existing lint/type/test failures. Report and fix them, or flag to the user.
- Plan execution: Complete all phases — priority indicates order, not optionality.
- Skill activation: When hooks display a skill activation banner, invoke the recommended skill immediately.
Development uses Compose Watch for file sync + HMR. It syncs via Docker API (tar + cp), bypassing OrbStack's TCC bind-mount restriction. No polling required.
| Service | Port |
|---|---|
| Frontend | 5174 |
| Backend | 8000 |
| Sandbox API | 8083 |
| MongoDB | 27017 |
| Redis | 6379 |
| Qdrant | 6333/6334 |
- Python: 4-space indent,
snake_casefunctions,PascalCaseclasses - Vue/TS: 2-space indent,
PascalCasecomponents,useXcomposables - Linting: Ruff (backend), ESLint (frontend)
Architecture and subsystem docs (read on demand, not upfront):
- Engineering Instructions — Core behavioral contract
- Python Standards — Pydantic v2, FastAPI, async patterns
- Vue Standards — Composition API, Pinia, TypeScript
- HTTP Client Pooling — Connection pooling details
- Multi-API Key Management — Key rotation, failover
- Browser Architecture — CDP, Playwright, screencast
- Plotly Chart Best Practices — Chart implementation
- Replay & Sandbox — Screenshot replay, CDP screencast
- Deep Research Reliability — Summarization, search, report verification
- Copy
.env.exampleto.envfor local runs - MCP integration via
mcp.json.example - Docker socket mount:
-v /var/run/docker.sock:/var/run/docker.sock
Hooks in ~/.claude/settings.json enforce quality automatically (lint on edit, type-check on save, --no-verify blocking). Commands: /verify, /verify quick, /verify pre-pr, /de-sloppify, /learn, /evolve.