Create and edit native Google Docs with goog docs.
Use target/debug/goog from the goog-cli repository, or cargo run --, because the development binary is the authoritative command surface.
Required workflow
- Decide the document's purpose, audience, content structure, and visual hierarchy before writing.
- Run
target/debug/goog auth listand record the active account before any live mutation. - Run
target/debug/goog docs --helpand the relevant nested--helpcommand before the first mutation. - Create or inspect the document.
- Prefer high-level
goog docscommands overbatch-update. - Use dry runs for supported edits, then apply the confirmed operation.
- Map the document again after structural edits because indexes and entry numbers can change.
- Open the finished native document at 100% zoom and inspect every page from top to bottom.
- Correct content, hierarchy, tables, spacing, page breaks, and formatting before delivery.
- Return the Google Docs URL and a short description of the finished result.
Read references/quality.md before creating a new document or substantially rewriting one. Read references/commands.md when selecting commands or location selectors.
Command selection
Use these surfaces first:
goog docs createfor a blank native document.goog docs getfor raw structure and revision metadata.goog docs mapfor readable content locations, headings, tables, and images.goog docs textfor search, insertion, and replacement.goog docs style applyfor text and paragraph styling.goog docs tablefor inserting and populating tables.goog docs image,break,footnote,header,footer,list-format, andnamed-rangefor their named document features.
Use goog docs batch-update only when no high-level command supports the required operation.
Keep any temporary JSON request body in task-local scratch space and remove it after verification.
Editing safety
- Accept a document ID or full Google Docs URL wherever the command supports either.
- Use the active account shown by
goog auth listunless the user specifies another authorized account. - Pass
--account EMAILwhen account selection must remain explicit across a multi-step task. - If authorization opens an account chooser, select only the recorded active or user-specified account.
- Never infer an account from browser order, a remembered identity, or unrelated open documents.
- If a command fails because the account is missing required scopes, run
goog auth loginonce and retry; do not expect the original command to pause and resume on its own. - Use
goog auth listfor the auth preflight and do not list unrelated Drive resources. - Inspect with
docs mapbefore targeting content. - Prefer semantic selectors such as
heading:,after-heading:,before-text:, or--textover raw indexes. - Run
--dry-run --jsonwhen the command supports it. - Use
--required-revision-idfor multi-step or potentially concurrent edits. - Capture revision IDs directly from command output and never retype or shorten them manually.
- Refresh the Document Map after any failed guarded write before retrying.
- Re-fetch the revision and remap after each structural change.
- Preserve the existing design during local edits unless the user asks for a redesign.
- Treat browser inspection as read-only QA and avoid editor keyboard shortcuts that could mutate content.
- Use an already authenticated native browser session for the recorded account when one is available.
- If no matching authenticated browser session is available, report visual QA as blocked instead of claiming the completion gate passed.
- Never expose scratch files, request bodies, or internal QA notes in the document.
Completion gate
Do not call the document finished until all of these are true:
- The requested content is complete and factually consistent.
- Heading levels form a sensible hierarchy.
- Tables are used for real row-and-column comparisons, not as generic page layout.
- Lists use native list formatting.
- No placeholder, instruction text, or duplicated content remains.
- Styles are consistent and readable.
- The document has been visually inspected at 100% zoom, including every page edge and any requested page-count limit.
- The live document has been fetched again after the last write.
- The final URL opens the intended native Google Doc.