# Working in a dohc workspace

dohc keeps files, Markdown documents, structured Collections, automations, chat, and small web apps in one local-first workspace with History and Versions. Every user action runs through the same operations in the desktop app, the `dohc` CLI, and the `dohc` MCP server.

## Before your first call

1. Through MCP, `dohc_dataset`, `dohc_collection_access`, and `dohc_publish_app` fill in `workspaceId` for the workspace the server serves. The CLI needs it: read it from the `dohc://workspace/info` resource, `dohc_list_workspaces`, or `workspaceId` in `.dohc/manifest.json` at the workspace root. Never guess `"local"`.
2. Keep the dohc desktop app open for writes, Collections, apps, chat, and Versions.
3. For Markdown files (`.md`), use `dohc_create_document`, `dohc_read_document`, and `dohc_edit_document`. `dohc_write_file` refuses Markdown documents because live documents own their text.
4. For drawings (`.excalidraw`), use `dohc_create_drawing`, `dohc_read_drawing`, and `dohc_edit_drawing`. An open canvas shows each edit at once.

## Core building tools

The desktop MCP server registers over 75 tools, most of them for sync recovery, live-document quarantine, and sharing administration. Start with these core building tools:

| Goal | Primary MCP tool | CLI equivalent |
| --- | --- | --- |
| Check workspace role and live sync status | `dohc_workspace_status` | `dohc workspace status` |
| Recall context across pages, Collections, records, and chat | `dohc_search_workspace` | `dohc workspace search <query>` |
| Explore files | `dohc_list_files`, `dohc_read_file`, `dohc_search_files` | (use workspace files directly) |
| Write non-Markdown files (code, YAML, JSON) | `dohc_write_file` | (use workspace files directly) |
| Create, read, and edit Markdown documents | `dohc_create_document`, `dohc_read_document`, `dohc_edit_document` | `dohc document create\|read\|edit` |
| Create, read, and edit drawings | `dohc_create_drawing`, `dohc_read_drawing`, `dohc_edit_drawing` | `dohc drawing create|read|edit` |
| Work with document Collections (`collection.yaml`) | `dohc_query_collection`, `dohc_create_record`, `dohc_set_record_fields` | `dohc document set-fields` |
| Create, approve, migrate, and invoke transactional Collections (`dataset.json`) | `dohc_dataset` | `dohc dataset <verb> '<JSON>'` |
| Scaffold, stage, verify, and publish web apps (`app.publish.json`) | `dohc_create_app`, `dohc_publish_app` (in a workspace you own, `verifyFrontend` runs the app; `readiness` shows what a workspace app gives each member) | `dohc app <verb> '<JSON>'` |
| Import CSV/JSON and query SQLite | `dohc_import_data`, `dohc_query_database` | (MCP only) |
| Check and change Collection automations (`automations.yaml`) | `dohc_list_automations`, then edit `automations.yaml` with `dohc_write_file`. In a workspace shared with you at Edit, `dohc_switch_automation` turns one on or off | `dohc automation list\|switch` |
| Let a website form or another service add records to a Collection | In a synced workspace you own: `dohc_read_automation_host`, `dohc_use_server_for_automations`, then `dohc_create_incoming_webhook`. `dohc_list_incoming_webhooks` before you retry, and `dohc_update_incoming_webhook`, `dohc_rotate_incoming_webhook`, or `dohc_delete_incoming_webhook` to manage one. See [references/automations.md](https://dohc.computer/docs/skill/automations) | `dohc automation host\|use-server`, `dohc webhook list\|create\|update\|rotate\|delete` |
| Post or reply in Groups and file comments | `dohc_list_groups`, `dohc_start_group_chat`, `dohc_start_file_chat`, `dohc_reply_to_chat` | `dohc chat groups\|post\|reply` |
| Try multi-file workspace drafts in a Version (not for app iteration) | `dohc_create_version`, `dohc_compare_version`, `dohc_merge_version` | `dohc version create\|compare\|merge` |

## Choose the right data model

- **Document Collection (`collection.yaml` + `.md` records)**: Best for notes with typed properties (trip plans, tasks, specs) where each record also has a rich Markdown body.
- **Transactional Collection (`dataset.json` + SQLite + operations)**: Best for structured records, multi-table relations, capacity or business rules, public forms, and dynamic apps. Apps bind to approved operations on these Collections; apps have no separate private database.
- **Visible SQLite file (`dohc_import_data` + `dohc_query_database`)**: Best for quick one-off CSV/JSON imports and read-only `SELECT` analysis.

## Give each page and app an icon

When you create a page or an app, give it one emoji that fits it. Explorer and Home show it in place of the generic glyph, so people can find work at a glance.

- **Page:** after `dohc_create_document`, call `dohc_set_record_fields` with `{ "recordPath": "<page>.md", "fields": { "icon": "🧭" } }`. It works on any page, not only Collection records. CLI: `dohc document set-fields <page>.md --field icon=🧭`. If you write the Markdown file yourself, start it with `---
icon: 🧭
---`.
- **App:** put `"icon": "🧭"` in the app folder's `dohc.json`, or create `{ "icon": "🧭" }` when it has none. Changing it doesn't ask for the app to be approved again unless its `app.publish.json` lists `dohc.json` among its inputs. Don't add `icon` to `app.publish.json`, which refuses unknown keys.
- **Collection:** a Collection can't take an icon yet. Don't add `icon` to `collection.yaml` or `dataset.json`. The records in a document Collection are pages, so they can.

## Detailed references

Read the matching reference before authoring schemas, apps, or automations:

- [references/collections-and-datasets.md](https://dohc.computer/docs/skill/collections): `collection.yaml` syntax, `dataset.json` (`formatVersion` 1 and 2) invariants, `dohc_dataset` action fields, custom `backend.ts` operations, schema migrations, bound-app drift checks, and public relation choices.
- [references/apps-and-publishing.md](https://dohc.computer/docs/skill/apps): `app.publish.json` format (optional `inputs`/`packageMap`, named `operations`, multi-Collection `datasets`), built-in `@dohc/app-kit`, `dohc-app-channel` protocol, unified `stage`/`approveStaged`, local approval, and share-link publishing.
- [references/automations.md](https://dohc.computer/docs/skill/automations): `automations.yaml` schema, triggers, steps, formulas vs. conditions, and message templates.

## Common pitfalls

- **Workspace role vs. folder name ("Personal")**: A "Personal app" is a private local app inside a workspace someone else owns (a workspace you joined). It has nothing to do with an owned workspace whose folder is named "Personal". Check `dohc_workspace_status` or `dohc workspace status` (`role: "owner"` vs. `"joined"` or `"shared-view"`, plus live `sync.state` and `sync.caughtUp`).
- **`dohc_dataset` path field name**: `action: "prepare"` takes `descriptorPath`. Collection-scoped actions (`describe`, `invoke`, `prepareSchemaChange`, `prepareMigration`, `askToApply`, `prepareRelationChoices`, `createForm`, `history`, `permissions`, `lifecycle`, `archive`, `restore`, `deletePreview`, `delete`, `export`, `upload`, `file`, etc.) take `datasetPath`. Workspace-scoped and preparation actions (`list`, `create`, `approve`, `discard`, `approveMigration`, `discardMigration`, `migrationPreviewPage`, `cancelInvoke`, and recovery actions) omit both. Always pass the path ending in `dataset.json` (for example `"tracker/dataset.json"`), never the folder alone and never `datasetId`.
- **Approval arguments**: `dohc_dataset` `approve` takes `{ action: "approve", workspaceId, preparationId, revisionSha256 }` (read `revision.revisionSha256` from `prepare`; omit `datasetPath` and `sourceDigest`). `approveMigration` takes `{ action: "approveMigration", workspaceId, preparationId, revisionSha256, approvalDigest }` (omit `datasetPath`).
- **Bound apps after Collection migrations**: Migration previews (`prepareSchemaChange`, `prepareMigration`, `prepareRelationChoices`, `prepareHistoryRestore`) and `dataset permissions` list connected local and share-link apps in `boundApps` with `status` (`"compatible"`, `"needs-refresh"`, or `"incompatible"`). Omit `revision` and `revisionSha256` in `app.publish.json` so `prepareLocal`, `prepare`, or `stage` pins the current approved revision automatically. If an older app still pins `revision` and `revisionSha256` in `app.publish.json`, remove those two lines once before re-preparing and approving it. When editing a local app and its Collections together, use `dohc_publish_app` `stage` -> `approveStaged`.
- **Keep dohc chat conversations in dohc**: Keep updates and questions for a dohc chat request in that thread, not your host tool's replies or question box. Send ordinary replies for normal and final text; pass a work report (`--work` in CLI, `work` in Desktop MCP) only to update the thread's Work card, repeating `--link` / `url` on linked cards so the link stays. CLI: `dohc chat reply` (`--needs-decision` and repeated `--option "<choice>"` for choices) and `dohc chat show <thread> --peek` (or `dohc chat watch` only when polling rather than receiving forwarded messages). Desktop MCP: `dohc_reply_to_chat` (`needsDecision`, `options`) and `dohc_read_chat` (plus `dohc_wait_for_messages` when polling an owned workspace). Personal MCP (`dohc-personal`): `dohc_post_channel` / `dohc_post_discussion` and `dohc_read_channel`, `dohc_read_discussion`, or `dohc_wait_for_messages`.
- **File comments vs. Group posts**: To comment on a file, use `dohc_start_file_chat` (not `dohc_start_group_chat`). To check existing discussions on a file first, use `dohc_list_file_chats`.
- **Drawings**: Read before you edit, and pass each element's `version` as `expectedVersion`. A refusal means someone changed it: read again and retry. Send `requestId` so a retry never applies twice. Undo Run in History skips a drawing an agent created and any drawing open in an editor.
- **Iterating on apps**: Do not use a workspace Version to build or test app changes. Apps on non-Main versions run as read-only previews and cannot approve Collection changes. For small edits, update the app in place: dohc keeps up to 3 earlier approved local versions for rollback (`listLocal` -> `reviewReactivation` -> `approve`). For a side-by-side rewrite, create a sibling app folder pointing at the same Collection and add new Collection operations instead of breaking existing ones. See [references/apps-and-publishing.md](https://dohc.computer/docs/skill/apps).
- **Versions**: `dohc_create_version` creates a copy for multi-file workspace drafts and switches the workspace folder to it immediately. Edit files, run `dohc_compare_version`, then merge with `dohc_merge_version`.
- **Secrets and sharing**: Never include owner-only read operations in a public share-link app's `operations`/`operationIds`. Never read or copy secret files (`.env*`) into workspace apps or databases.
