Google Docs
Use this guide for precise Google Docs reading, editing, and creation.
Read Path
- If you only know the doc title or title keywords, use
searchfirst instead of asking for a URL. - Prefer
get_documentfor Docs-native reads. It returns the raw document and tab content, and replaces the synthesizedget_document_textview that is being phased out. - Prefer
find_document_text_rangeover hand-picked indexes when you can anchor on exact text. - Use
get_document_paragraph_rangewhen you have an index inside a paragraph and need its full boundaries. - Use
get_document_tablesbefore editing or rebuilding table content. - If the doc has tabs, use
get_documentto identify the right tab and carrytab_idthrough follow-up reads. - Re-read after substantial edits so later writes use live indexes.
Workflow
- Read before writing.
- Identify the exact section, heading structure, paragraph boundaries, table locations, and current formatting.
- If the target is ambiguous, summarize the candidate section first and make the scope explicit in the response.
- For read-only answers, quote or closely paraphrase the specific retrieved line or paragraph from
get_documentthat supports the answer so the response stays visibly grounded in the document.
- Find live indexes.
- Use
find_document_text_rangewhen you can anchor on exact text. - Use
get_documentwhen you need to inspect the current body, tab content, or nearby structure before resolving ranges. - Use
get_document_paragraph_rangewhen you need a single paragraph's range around an index. - Do not guess offsets after prior writes.
- After many edits, call
get_documentagain before the next batch.
- Build a
batch_update_document.
- All document changes go through
batch_update_document. - IMPORTANT:
batch_update_document.requestsmust be an array of structured request objects. Do not JSON-stringify Docs API requests. batch_update_document.write_controlmust also be an object, and not a JSON-stringified string.- Requests execute in order, so sequence dependent edits deliberately.
- For concurrency-sensitive writes, prefer
write_controlwith the latestrevisionId. Set eitherrequiredRevisionIdortargetRevisionId, never both.
- Preserve Docs-native formatting.
- Use heading levels and paragraph styles to organize the document.
- Build lists with inserted text plus Docs list or paragraph styling. Do not fake bullets or numbering with literal
-,*, or1.characters alone. - Do not add blank paragraphs for spacing. Use styles instead.
- Do not leave the document unformatted unless the user explicitly asks.
- Verify the write.
- After finishing all edits, call
get_documentone more time. - Confirm the text landed in the intended place and indexes still line up before ending.
Allowed batch_update_document Request Types
- Text:
replaceAllText,insertText,deleteContentRange,replaceNamedRangeContent - Text and paragraph formatting:
updateTextStyle,updateParagraphStyle,createParagraphBullets,deleteParagraphBullets - Named ranges:
createNamedRange,deleteNamedRange - Images and embedded objects:
insertInlineImage,replaceImage,deletePositionedObject - Tables:
insertTable,insertTableRow,insertTableColumn,deleteTableRow,deleteTableColumn,updateTableColumnProperties,updateTableCellStyle,updateTableRowStyle,mergeTableCells,unmergeTableCells,pinTableHeaderRows - Document layout and structure:
updateDocumentStyle,updateSectionStyle,insertPageBreak,insertSectionBreak - Headers, footers, and notes:
createHeader,deleteHeader,createFooter,deleteFooter,createFootnote - Tabs:
addDocumentTab,deleteTab,updateDocumentTabProperties - People:
insertPerson
Write Rules
- Preserve existing headings, styles, links, dates, and table structure when editing unless the user asks to change them.
- Use multiple heading levels to organize a doc unless the user instructs otherwise.
- Treat large rewrites, deletions, tab changes, layout changes, and table restructuring as explicit actions.
- When similar headings or repeated text exist, identify the exact target section before editing.
Read-Only Answers
- When the user only asked to read, summarize, or answer from the doc, prefer the lightest read path that still keeps the answer grounded in the raw document response.
- Support the answer with a short quoted phrase or a close paraphrase from the retrieved text instead of giving an ungrounded conclusion.
Fallback
If document content or write tools are unavailable, say that Google Docs access or tooling is missing and ask the user to reconnect or clarify the target document.