Add addConditionalFormatting tool (BooleanRule)#81
Merged
a-bonus merged 1 commit intoa-bonus:mainfrom Mar 15, 2026
Merged
Conversation
Adds a new `addConditionalFormatting` tool that appends a BooleanRule conditional format rule to one or more ranges in a spreadsheet. Applies a format (background color, bold, text color, etc.) when cells meet a specified condition. Supported condition types: - NUMBER_GREATER, NUMBER_GREATER_THAN_EQ, NUMBER_LESS, NUMBER_LESS_THAN_EQ - NUMBER_EQ, NUMBER_NOT_EQ - NUMBER_BETWEEN, NUMBER_NOT_BETWEEN (requires two condition values) - BLANK, NOT_BLANK (no condition values) - CUSTOM_FORMULA (e.g. "=$A1>$B1") Supported format options: backgroundColor, bold, italic, strikethrough, underline, foregroundColor, fontSize. Not supported: GradientRule (continuous color scale) — this is a separate rule type in the Sheets API and would be a separate tool. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
addConditionalFormattingtool that appends a BooleanRule conditional format rule to one or more ranges in a spreadsheet viabatchUpdate.What's supported
Condition types:
NUMBER_GREATER,NUMBER_GREATER_THAN_EQ,NUMBER_LESS,NUMBER_LESS_THAN_EQ— single value comparisons (e.g.conditionValues: ["40"])NUMBER_EQ,NUMBER_NOT_EQ— equality comparisonsNUMBER_BETWEEN,NUMBER_NOT_BETWEEN— requires exactly two values (lower bound first)BLANK,NOT_BLANK— no condition valuesCUSTOM_FORMULA— arbitrary formula string (e.g."=$A1>$B1")Format options:
backgroundColor(hex),bold,italic,strikethrough,underline,foregroundColor(hex),fontSizeOther:
sheetName(optional, defaults to first sheet),ranges(array of A1 notation strings, min 1)What's not supported
GradientRuletype for continuous color scales (min/mid/max). This tool only implementsBooleanRule. GradientRule would be a separate tool.deleteConditionalFormatting(not yet implemented) to remove rules before re-adding.TEXT_CONTAINS,TEXT_NOT_CONTAINS,TEXT_STARTS_WITH,TEXT_ENDS_WITH,TEXT_EQare valid Sheets API condition types but not exposed here. Can be added if needed.DATE_EQ,DATE_BEFORE,DATE_AFTER, etc. — not currently exposed.Validation
Zod
.refine()validates that the correct number ofconditionValuesis provided per condition type:BLANK/NOT_BLANKNUMBER_BETWEEN/NUMBER_NOT_BETWEENImplementation notes
addConditionalFormatRulehelper ingoogleSheetsApiHelpers.tsformatCellsand other formatting toolsparseA1ToGridRangeto convert A1 notation toSchema$GridRangeobjectsTest plan
NUMBER_GREATERrule withbackgroundColor— verify cells exceeding threshold turn the expected colorCUSTOM_FORMULArule — verify formula-based highlighting worksBLANKrule (no conditionValues) — verify it doesn't reject the callNUMBER_BETWEENrule with two values — verify range highlighting works🤖 Generated with Claude Code