virtual-worker
AGENTS.md0 starsChanged 29 days agoApache-2.0View on GitHub
Instructions for AI coding agents (and humans) working in this repository. Virtual Worker is an open-source, local-first platform for running autonomous AI workers: agents with a persona, tools, skills, memory, a task board, schedules and guardrails, served by a local model by default. A React app talks to a FastAPI backend that is also an OpenAI-compatible gateway in front of any model server (llama.cpp, MLX, Ollama, vLLM, or a remote provider). Nothing leaves the machine unless the user explicitly connects…
- Installs packages
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,117 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository61 other files it gives its agents.
- Contact DeduperSkill
- Csv CleanerSkill
- Expense CategorizerSkill
- Invoice ProcessorSkill
- Json WranglerSkill
- Log AnalyzerSkill
- Pdf ExtractorSkill
- Report Chart BuilderSkill
- Spreadsheet AnalyzerSkill
- Survey SummarizerSkill
- delegate-agentSkill
- Approval Request TriageSkill
- Backup RunnerSkill
- Channel BroadcastSkill
- Dependency AuditorSkill
- Memory KeeperSkill
- Repo OnboarderSkill
- Scheduled Job DoctorSkill
- Web Form FillerSkill
- Web ScraperSkill
- Website MonitorSkill
- Brain Dump To TasksSkill
- Calendar Day PlannerSkill
- Daily BriefingSkill
- Email TriageSkill
- Follow Up TrackerSkill
- Meeting MinutesSkill
- Recurring Digest SetupSkill
- Standup ReporterSkill
- Task Board GroomerSkill
- Weekly ReviewSkill
- Arxiv Paper ScannerSkill
- Comparison MatrixSkill
- Competitor WatchSkill
- Deep Research BriefSkill
- Fact CheckerSkill
- News DigestSkill
- People Company BriefSkill
- Product Price ScoutSkill
- Stock Price CheckerSkill
- Trending Topic DigestSkill
- Senior Software EngineerSkill
- Skill CreatorSkill
- Social CommentsSkill
- Social CoreSkill
- Social DMSkill
- Social EngageSkill
- Social HealthSkill
- Social InsightSkill
- Social ProspectSkill
- Social WatchSkill
- Blog Post WriterSkill
- Documentation WriterSkill
- Email DrafterSkill
- Executive SummarySkill
- Press Release WriterSkill
- Proposal WriterSkill
- Release Notes WriterSkill
- Social Media RepurposerSkill
- Tone RewriterSkill
- The first 60 shown.
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 135
One run entry point: Every surface (chat route, worker, scheduler, triggers, inbox flow-back, chat channels) calls …
- Very specific: line 185
All state lives under VW_HOME (default ~/.virtual-worker.
- Distinctive: line 227
Never push directly to
main: Every feature or fix starts in its own git worktree on a branch cut from main, so the main checkout stays … - Very specific: line 238
After the PR is merged: git worktree remove ../vw-wt-<slug> and git branch -d feat/<scope>-<desc>.
- Very specific: line 240
PRs target
main, never another feature branch: Do not stack PRs. If a second feature needs the first one, wait for the first to merge, … - Very specific: line 250
Keep every PR complete: tests, docs (in-app Docs, README, ARCHITECTURE when the architecture changes), and a CHANGELOG entry under …
- Very specific: line 260
Add backend tests under backend/tests/test_*.py.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Virtual Worker
Instructions for AI coding agents (and humans) working in this repository.
Virtual Worker is an open-source, local-first platform for running autonomous AI workers: agents with a persona, tools, skills, memory, a task board, schedules and guardrails, served by a local model by default. A React app talks to a FastAPI backend that is also an OpenAI-compatible gateway in front of any model server (llama.cpp, MLX, Ollama, vLLM, or a remote provider). Nothing leaves the machine unless the user explicitly connects something. The product plan is
docs/PRD.md.
Repository structure
virtual-worker/
├── backend/ # FastAPI app (Python) — the gateway + all /api routes
│ ├── app.py # entry point: registers routers, starts background loops
│ ├── config.py # env + paths (VW_HOME, upstream, model map, …)
│ ├── routes/ # one module per API surface (agents, hub, chat, …)
│ ├── storage/ # SQLite-backed stores (app.db) + the settings file
│ ├── agent/ # the agent harness — runner.stream_run() → compose() → loop.run(); tools, worker,
│ │ # scheduler, triggers, inbox (flow-back), crusher (context compression), wiki,
│ │ # browser_control, skill_factory, team, vision_helper, doc_tools, …
│ ├── channels/ # chat-channel plugins: base contract, manager, whatsapp/ (+ Node bridge), telegram, discord, slack
│ ├── harness/ # coding harnesses: base.py (jobs, settings), claude_code.py, codex.py, commands.py (/code, /codex)
│ ├── vw_cli.py # `./vw` service mode: detached supervisor, auto-restart, built UI
│ ├── runtime/ # managed model server + engine management
│ ├── gateway/ # protocol translators (Anthropic / Responses / Gemini) + providers.py /
│ │ # egress.py / pricing.py (BYOK external models normalized to one chunk shape)
│ ├── connectors/ # stub (portal connectors are not part of this build)
│ ├── middleware/ # api_debug (trace capture) + team_auth (optional auth)
│ └── tests/ # pytest suite (test_*.py)
├── frontend/ # React + Vite + TypeScript + Tailwind v4
│ └── src/
│ ├── App.tsx # app shell: sidebar nav + routed content pane
│ ├── features/<name>/<name>-page.tsx # one folder per screen
│ ├── lib/ # api.ts (apiJson/apiPost/apiFetch), auth.tsx
│ ├── assets/ # icon.svg, logo.svg
│ └── index.css # the @theme design tokens (palette + fonts)
├── docs/ # PRD.md (product plan), ARCHITECTURE.md, INSTALL.md
├── desktop/ # Electron shell + PyInstaller spec for the packaged app
├── browser-extension/ # Chrome companion: groups agent tabs when attached to the user's Chrome
├── registry-scaffold/ # starter repo layout for a git-backed template registry
├── samples/ # example skill packs
├── dev.sh # bootstrap-on-first-run + start backend + frontend (hot reload)
├── vw # service control: start | stop | restart | status | logs
└── setup.sh # idempotent installer (venv, npm, llama.cpp, mlx)Build & dev commands
./dev.sh # hot-reload dev profile
# web → http://localhost:5173
# api → http://127.0.0.1:8889 (OpenAPI docs: /docs)
# model → http://127.0.0.1:8081/v1 (backend-managed)
./vw start # always-on service: built UI + API on one port, auto-restart
# app → http://127.0.0.1:8888 (model server on :8080)
./vw status | logs -f | restart | stopDev and service use different default ports so both can run side by side
(./vw → 8888/8080, ./dev.sh → 5173/8889/8081; override with BACKEND_PORT,
LLAMA_PORT, FRONTEND_PORT, VW_PORT). Each also gets its own data dir
(./data for dev, ~/.virtual-worker for the service). Service mode is
backend/vw_cli.py: a detached supervisor (pid file <VW_HOME>/service.json,
log <VW_HOME>/logs/service.log) that runs uvicorn without --reload and
serves frontend/dist from the backend (VW_SERVE_UI=1).
Prerequisites it can't install: uv, Node/npm, Homebrew (for llama.cpp).
Re-run the installer any time with ./setup.sh. Skip MLX with VW_SKIP_MLX=1.
Backend (Python, FastAPI)
cd backend
.venv/bin/uvicorn app:app --host 127.0.0.1 --port 8889 --reload # run (dev port)
.venv/bin/python -m pytest -q # all tests
.venv/bin/python -m pytest -q tests/test_scheduler.py # one fileThe venv is created by setup.sh with uv; deps are in requirements.txt.
No new dependency without a clear reason. The core leans on stdlib + httpx +
fastapi and stays dependency-light; integrations belong behind plugin interfaces.
Frontend (React + Vite + TS)
cd frontend
npm install
BACKEND_PORT=8889 npm run dev # Vite dev server (proxies /api, /v1, /v1beta → BACKEND_PORT)
npm run build # tsc --noEmit && vite build — MUST pass before a PR
npm run typecheck # tsc --noEmit onlyArchitecture (backend)
inbound (browser / coding agents / later: chat channels)
→ ApiDebugMiddleware (tees a bounded copy of every model call → app.db)
→ TeamAuthMiddleware (no-op in solo mode; gates /api when team mode is on)
→ gateway translators (/v1/messages · /v1/responses · /v1beta/… → OpenAI shape)
→ routes/* (the /api surface)
→ agent.compose(agent) → registry {name:{schema, fn}} → agent.loop.run(...)
→ runtime.llama_manager (managed model server) ─httpx─▶ upstream (:8080)- Evaluation suites (
storage/eval_store.py+runtime/eval_runner.py+routes/eval.py, PRD §8.14): suites of cases with four scorers (exact, rubric, tool, judge); runs activate each model viallama_managerand restore the previous one; the runner's_activate/_wait_healthy/_chat_completion/_judge_completion/_rss_bytes/ _restoreare monkeypatch seams, so tests never load a model. Only one run at a time. - Fine-tuning (
runtime/finetune_manager.py+runtime/mlx_shim.py+routes/finetune.py, PRD §8.15): MLX LoRA jobs (one at a time) run in the MLX engine's interpreter through the memory-capping shim, stream loss over SSE, and fuse into<VW_HOME>/models/<name>(served viallama_manager). Datasets are uploaded JSONL or built from chat feedback. State is<VW_HOME>/finetune/{datasets,jobs}resolved at call time; tests swap the trainer interpreter (_mlx_python) for a fake script, so no MLX is needed. - Coding harnesses (
harness/, PRD §8.13):base.pyholds the adapter contract, settings, theJobrecord and subprocess supervision;claude_code.pyreads~/.claude/sessions(live registry) +~/.claude/projects/*/*.jsonl(transcripts) and runsclaude -p --output-format stream-json(a live session is--fork-sessioned);codex.pyreads~/.codex/sessions/**/rollout-*.jsonland runscodex exec --json(result via-o). Surfaces:agent/harness_tools.py(code_*with aharnessarg, gated byguardrails.codingHarness),harness/commands.py(/code,/codex; results flow back viamanager.send),routes/harness.py, Settings card. New sessions only underallowedRoots.VW_CLAUDE_HOME/BIN,VW_CODEX_HOME/BINoverride paths. To add a harness: implement theAdapterprotocol,base.register()it, import it in commands. - Document tools (
agent/doc_tools.py):document_read/document_infofor PDF (pypdf), docx/xlsx/pptx (stdlib zip + xml), CSV and text. Always composed; paths must be under the working folder or<VW_HOME>/channels(where chat attachments land). Output is chunked withoffset/pages/sheet. - Delivery kinds (
agent/delivery.py):in_app,desktop,webhook(URL allow-list),chat(<accountId>:<conversation>),email(SMTP target with anallowToallow-list; password write-only underdeliveryTargetSecrets). Every send is audited indeliveries. - One run entry point. Every surface (chat route, worker, scheduler, triggers,
inbox flow-back, chat channels) calls
agent/runner.py:stream_run(), which resolves the model target (local or a BYOK provider viagateway/providers.py:resolve_target), composes the system prompt + tool registry, wires MCP servers, and drivesloop.runwith the agent's guardrail knobs.execute_run()collects(text, error, run_id). - Agent tools are assembled per run in
agent/compose.pyas a registry{name: {"schema": <openai fn schema>, "fn": <async callable>}}, then passed toagent/loop.py:run(). Per-agent tool factories follow one pattern (seemake_memory_tools,make_schedule_tools,make_kb_tools,make_custom_tools,make_team_tools,make_deliver_tool). To add a tool, write a factory and wire it incompose(). - Always-on background loops, started in
app.py's startup hook: the scheduler (agent/scheduler.py), the trigger engine (agent/triggers.py), the board worker (agent/worker.py, opt-in autonomous task execution with a verify pass), the channel manager, and the maintenance loop (runtime/maintenance.py: retention pruning + WAL checkpoint + the opt-in scheduled backup snapshot, hourly). Loops are best-effort: log errors, never crash. - Security baseline (
app.py): CORS local-origins-only (+VW_CORS_ORIGINS),TrustedHostMiddleware(+VW_ALLOWED_HOSTS), httpx logging quieted and a_RedactFilterscrubbing tokens from log lines; webhook paths bypass the team-mode cookie gate because they carry their own proof (HMAC / unguessable token). Keep every new inbound endpoint under that rule. SeeSECURITY.md. - Team mode (
middleware/team_auth.py): when enabled, every/apicall needs a session; mutating calls must meet the role floor in_ROLE_POLICY(longest prefix wins, defaultmember; installation-wide config/secrets areadmin); every mutating call is written toaudit_log(storage/audit_store.py). A new admin-only route must be added to_ROLE_POLICYor it defaults to member. - Stores (
storage/*_store.py) all openapp.dbthe same way: a_conn()withPRAGMA journal_mode=WAL+row_factory=sqlite3.Row, ISO timestamps, athreading.Lock, andcamelCasedicts out. Mirror an existing store when adding one, and register any new route inapp.py. - Chat channels (
backend/channels/, PRD §8.6):base.pyis the plugin contract (ChannelAdapter+InboundMessage+registry);manager.pyis the shared spine (dedup → policy → resolve agent → per-conversation FIFO/debounce → slash commands → history from the chat session →execute_turnwith timeout/typing → strip reasoning → persist → chunk + send → delivery audit). Adapters only move messages. WhatsApp ships two:whatsapp/linked.pyspawns the Node sidecar inwhatsapp/bridge/(Baileys, JSON lines over stdio, restarted with backoff) andwhatsapp/cloud.pyis the official webhook (routes/channels.pyhosts/api/channels/webhook/{kind}/{account}). Telegram (telegram.py) is pure httpx long polling (getUpdates), the model for any Bot-API-style transport.channels/builtin.pyimports every adapter so it registers. Accounts/bindings/dedup/pairing live instorage/chat_channel_store.py; secrets go tosettings.jsonunderchatChannelSecretsand are never returned. To add a channel: subclassChannelAdapter, decorate with@registry.register, import it inchannels/whatsapp/__init__.py-style fromapp.py's startup, add tests with a fake adapter (seetests/test_channel_manager.py).
Configuration & data (local-first)
All state lives under VW_HOME (default ~/.virtual-worker; dev.sh sets it to
./data). The SQLite db is app.db; app settings are settings.json.
| Env var | Default | Purpose |
VW_HOME | ~/.virtual-worker | data dir (db, settings, logs, pid) |
VW_UPSTREAM_URL | http://127.0.0.1:8080 | OpenAI-compatible model server; setting it disables managed mode |
VW_MANAGED_LLAMA | 1 | backend starts/stops/switches the model server |
VW_MODEL_MAP / VW_DEFAULT_MODEL | – | map vendor model ids → your local model |
VW_GATEWAY_KEY | – | require a static key on the gateway |
VW_DEBUG_CAPTURE | 1 | capture model calls into the trace store |
VW_SKIP_MLX | 0 | skip the MLX engines on Apple Silicon |
VW_WARMUP_AGENTS | 1 | after a model is activated, prefill the prompt cache for this many recently used agents (0 = off) |
LLAMA_* / MLX_* | – | engine binaries, port, ctx, GPU layers |
HF_TOKEN | – | gated/private Hugging Face repos |
VW_ALLOWED_HOSTS / VW_CORS_ORIGINS | – | extra Host names / browser origins (local ones are always allowed) |
VW_*_RETENTION_DAYS, VW_TRACE_MAX_RUNS | 30/90/90/7/14 | maintenance-loop retention (traces, activity, deliveries, chat dedup, media) |
VW_NODE_BIN | node | Node binary for the WhatsApp bridge sidecar |
VW_WHATSAPP_MAX_MEDIA_BYTES | 25 MB | cap on a received WhatsApp attachment |
API gateway tokens are sk-vw-<hex> (only a SHA-256 hash is stored). The gateway is
open until the first token is minted, then a valid token is required.
Conventions
- Python: standard library style; type hints; small focused modules. Errors are best-effort in background loops (log, never crash the loop).
- TypeScript/React: functional components + hooks;
constoverlet; camelCase vars, PascalCase types. Data fetching goes through@/lib/api. One screen = onefeatures/<name>/folder. - Styling: Tailwind v4 with the
@themetokens insrc/index.css. Use the tokens (bg-primary,text-ink,bg-base,border-pressed, …), don't hard-code hex. - Local-first is a hard constraint. Any network egress (web fetch, remote MCP, webhook delivery, remote upstream, chat channel) must be explicit and opt-in.
- Secrets are write-only: stored once, never echoed to the UI, redacted from logs and traces.
- No company-specific code. Integrations ship as generic, configurable plugins.
- Commits: conventional —
feat:,fix:,chore:,docs:, with an optional scope such asfeat(channels):.
Workflow — one worktree per feature, PRs always against main
- Never push directly to
main. Every feature or fix starts in its own git worktree on a branch cut frommain, so the main checkout stays clean and several features can be worked on side by side without switching branches:
After the PR is merged:git fetch origin git worktree add ../vw-wt-<slug> -b feat/<scope>-<desc> origin/main cd ../vw-wt-<slug> # … work, commit … git push -u origin feat/<scope>-<desc> gh pr create --base main --title "feat: …" --body "…"git worktree remove ../vw-wt-<slug>andgit branch -d feat/<scope>-<desc>. - PRs target
main, never another feature branch. Do not stack PRs. If a second feature needs the first one, wait for the first to merge, then rebase or mergeorigin/maininto the second worktree and resolve conflicts there. (A PR based on a feature branch is merged into that branch when the base merges first, andmainnever receives it.) - Each worktree has its own
backend/.venvandfrontend/node_modules: run./setup.shonce in a new worktree, or symlink them from the main checkout (ln -s ../../virtual-worker/backend/.venv backend/.venv) when dependencies are unchanged. Use a distinctVW_HOME(or the default./data, which is per worktree) so two worktrees never share a database. - Keep every PR complete: tests, docs (in-app Docs, README, ARCHITECTURE when the
architecture changes), and a CHANGELOG entry under
[Unreleased].
Testing — gate every change
A change isn't done until both pass:
cd backend && .venv/bin/python -m pytest -q # backend
cd frontend && npm run build # tsc --noEmit && vite build- Add backend tests under
backend/tests/test_*.py. Isolate stores bymonkeypatch.setattr(config, "APP_HOME", tmp_path)(seetests/test_scheduler.py). - Make tests hermetic: monkeypatch model activation / chat completion / embeddings so no real model is loaded.
scripts/smoke_onboarding.pydrives the first-run wizard in headless Chromium (Playwright) against a started service.- For a real end-to-end check with a local model (activation → chat tool call → board
worker → channel webhook turn), run
scripts/smoke_live.pyagainst a started service (usage in its docstring). It is not part of CI.
Where to read more
docs/ARCHITECTURE.md— the full backend/frontend architecture, run path, data model.docs/PRD.md— the product plan: concepts, requirements, milestones, open decisions.- In-app Docs (the Docs tab) — end-user documentation for every screen.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

