Skip to content

docs(skills): add COOKBOOK.md for gws-docs with tab and formatting recipes#421

Open
bishnubista wants to merge 3 commits intogoogleworkspace:mainfrom
bishnubista:docs/skill-cookbook-pattern
Open

docs(skills): add COOKBOOK.md for gws-docs with tab and formatting recipes#421
bishnubista wants to merge 3 commits intogoogleworkspace:mainfrom
bishnubista:docs/skill-cookbook-pattern

Conversation

@bishnubista
Copy link

@bishnubista bishnubista commented Mar 12, 2026

Summary

  • Adds a COOKBOOK.md file alongside the auto-generated SKILL.md in skills/gws-docs/
  • Documents non-obvious Google Docs API patterns that are hard to discover from gws schema output alone
  • Establishes a pattern other skills can adopt for hand-written recipes

Motivation

SKILL.md files are auto-generated by gws generate-skills and list API methods. However, some services have usage patterns that require trial-and-error to discover:

  • Tab operations: addDocumentTab (not createTab), includeTabsContent for reading, tabId in location/range objects
  • Formatted content: the insert-then-style pattern with insertText + updateParagraphStyle
  • +write limitations: no tab targeting, plain text only

By placing recipes in a separate COOKBOOK.md, they survive gws generate-skills regeneration while remaining co-located and discoverable.

What's included

Section Recipes
Working with Tabs Read, create, write to, rename, delete tabs
Formatted Content Insert-then-style pattern, heading styles, bold/italic
Request Types Complete reference table of valid batchUpdate requests
+write Limitations Workarounds for tab and formatting gaps

Test plan

  • Verify gws generate-skills does not overwrite or conflict with COOKBOOK.md
  • Verify recipes work against a live Google Doc with multiple tabs

Closes #420

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: e2f2c51

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-cla
Copy link

google-cla bot commented Mar 12, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the gws-docs skill documentation by introducing a COOKBOOK.md file. This new resource provides practical, hand-written recipes for navigating non-obvious Google Docs API patterns, such as managing document tabs and inserting formatted content, which are not adequately covered by the auto-generated API reference. The addition aims to improve developer experience by offering clear guidance and establishing a replicable documentation structure for other skills.

Highlights

  • New Documentation File: Introduced COOKBOOK.md in skills/gws-docs/ to provide practical recipes for Google Docs API usage, complementing the auto-generated SKILL.md.
  • Google Docs API Patterns: Documented complex API patterns for managing tabs (reading, creating, writing, renaming, deleting) and inserting formatted content (insert-then-style, paragraph styles, bold/italic).
  • +write Helper Limitations: Clarified limitations of the docs +write helper, specifically its lack of tab support and plain text-only output, and provided batchUpdate workarounds.
  • Documentation Pattern: Established a new documentation pattern for hand-written recipes that can be adopted by other skills, ensuring discoverability and persistence through auto-generation.
Changelog
  • skills/gws-docs/COOKBOOK.md
    • Created a new documentation file detailing Google Docs API patterns.
    • Included recipes for tab operations (read, create, write, rename, delete).
    • Provided guidance on inserting formatted content using batchUpdate.
    • Documented limitations of the +write helper and offered workarounds.
    • Listed valid batchUpdate request types for quick reference.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a COOKBOOK.md for the gws-docs skill, providing valuable, hand-written recipes for common but non-obvious API patterns. The documentation is well-structured and covers important topics like tab manipulation and formatted content insertion. I have found one area where an example could be improved for clarity and correctness. Overall, this is a great addition that will significantly help users of this skill.

Comment on lines +134 to +144
Use `updateTextStyle` with a character range:

```bash
{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The example for applying bold/italic is incomplete and misleading. It shows a JSON snippet inside a bash code block, which is not executable. To provide a clear and correct example, this should be a full gws command, similar to other examples in this document.

Suggested change
Use `updateTextStyle` with a character range:
```bash
{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}
```
Use `updateTextStyle` with a character range to apply styles like bold or italic.
```bash
gws docs documents batchUpdate \
--params '{"documentId": "DOC_ID"}' \
--json '{
"requests": [{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}]
}'

…cipes

SKILL.md files are auto-generated by `gws generate-skills` and cannot
hold hand-written guidance. This adds a COOKBOOK.md alongside gws-docs
SKILL.md with practical recipes for:

- Tab operations (read, create, write, rename, delete)
- Formatted content insertion (headings, bold/italic, styles)
- Valid batchUpdate request types reference
- `+write` helper limitations and workarounds

Closes googleworkspace#420
@bishnubista bishnubista force-pushed the docs/skill-cookbook-pattern branch from 7a4a40a to 1d9a24e Compare March 12, 2026 01:57
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a COOKBOOK.md for the gws-docs skill, providing useful recipes for common Google Docs API tasks. The documentation is well-structured and covers important topics like tab management and formatted text insertion. My review includes suggestions to correct an off-by-one error in a range calculation and to improve the consistency of an example, ensuring the recipes are clear and accurate for users.

Comment on lines +113 to +119
{
"updateParagraphStyle": {
"paragraphStyle": {"namedStyleType": "HEADING_1"},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "namedStyleType"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The endIndex for updateParagraphStyle appears to be off-by-one. The text for the first paragraph is My Heading\n, which has a length of 11 characters and occupies indices 1 through 11. Since the endIndex in a Google Docs API range is exclusive, it should be 12 to cover the entire paragraph including the newline character. An incorrect range can be confusing and lead to subtle bugs in user scripts.

For reference, the text being formatted is My Heading\n from line 109.

Suggested change
{
"updateParagraphStyle": {
"paragraphStyle": {"namedStyleType": "HEADING_1"},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "namedStyleType"
}
}
{
"updateParagraphStyle": {
"paragraphStyle": {"namedStyleType": "HEADING_1"},
"range": {"startIndex": 1, "endIndex": 12, "tabId": "TAB_ID"},
"fields": "namedStyleType"
}
}

Comment on lines +136 to +144
```bash
{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This example for updateTextStyle is confusing and inconsistent with other examples in the document. It's presented as a bash code block but contains only a JSON object, not a runnable command. To improve clarity and consistency, it would be better to provide a full gws command, similar to the other examples.

Suggested change
```bash
{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}
```
gws docs documents batchUpdate \
--params '{"documentId": "DOC_ID"}' \
--json '{
"requests": [{
"updateTextStyle": {
"textStyle": {"bold": true},
"range": {"startIndex": 1, "endIndex": 11, "tabId": "TAB_ID"},
"fields": "bold"
}
}]
}'

- Fix off-by-one: updateParagraphStyle endIndex 11→12 (exclusive, must
  include the trailing newline of "My Heading\n")
- Make bold/italic example a full runnable gws command instead of a bare
  JSON snippet in a bash code block
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a COOKBOOK.md file to document common API patterns for the gws-docs skill. The new file covers tab operations, content formatting, and limitations of the +write helper. My review focuses on the correctness of the provided recipes. I have one suggestion to clarify an instruction for applying multiple text styles to prevent potential user confusion. Otherwise, the provided examples appear correct.

}'
```

Replace `"bold": true` with `"italic": true` for italic, or combine both with `"fields": "bold,italic"`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The instruction for combining text styles is incomplete and could mislead users. It mentions updating the fields mask to "bold,italic" but omits that the textStyle object must also contain both properties. An API call with mismatched textStyle and fields will not work as expected, causing confusion. To ensure the recipe is accurate, I suggest clarifying that both parts of the request need to be updated.

Suggested change
Replace `"bold": true` with `"italic": true` for italic, or combine both with `"fields": "bold,italic"`.
Replace `"bold": true` with `"italic": true` for italic, or combine both by setting `"textStyle": {"bold": true, "italic": true}` and `"fields": "bold,italic"`.

…ields

Address Gemini review: the previous wording only mentioned updating the
fields mask but omitted that the textStyle object must also contain both
properties for the API call to work correctly.
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a COOKBOOK.md file for the gws-docs skill, providing hand-written recipes for common Google Docs API patterns that are not immediately obvious from the auto-generated skill documentation. The cookbook covers working with tabs, inserting formatted content, and explains the limitations of the +write helper. The documentation is clear, well-structured, and the examples provided are accurate. The review did not identify any issues requiring changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(skills): add COOKBOOK.md pattern for hand-written recipes alongside generated SKILL.md

2 participants