Skip to main content
Glama

Write a config file with a git checkpoint

git_safe_write_with_checkpoint
Idempotent

Write a config file after committing a checkpoint of the prior state, so each overwrite keeps a git rollback point.

Instructions

Write one config file after committing a checkpoint of the prior state.

Stages and commits every uncommitted change under /config as a checkpoint commit (only when the tree is dirty), then calls the same write_config_file logic files_write_config_file uses for relative_path/content, and finally stages and commits that change with commit_message (or a default message) if the write succeeded.

Use when: overwriting a config file while keeping a git-based rollback point, unlike a plain overwrite. Not for: a write without a checkpoint — use files_write_config_file; ESPHome device YAML — use esphome_write_config. Returns: dict — the underlying write result ({"success": True, "path": ...} or {"success": False, "error": ...}), plus git_sha/ git_message when the new-content commit was made. Errors: raises RuntimeError (from _repo()) when no git repo exists — run git_init_config first; returns {"success": False, "error": ...} unchanged when YAML validation fails, in which case the checkpoint commit of the prior dirty state (if any) still happened, but no new-content commit is made. Limits: does not reload Home Assistant; same file-extension and location limits as files_write_config_file.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "relative_path": "<relative_path>",
      "content": "<content>"
    },
    "name": "git_safe_write_with_checkpoint"
  }
}

Input Schema

NameRequiredDescriptionDefault
contentYesFull text to write as the file's new content, replacing whatever was there before.
relative_pathYesPath to the file relative to the HA config directory to write, e.g. 'automations.yaml'. Same extension and location limits as `files_write_config_file`.
commit_messageNoCommit message for the new-content commit. Omit to use a default 'chore: update <relative_path>' message.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.25.1
    • addedInput schema / properties / commit_message / description
      Added value: +"Commit message for the new-content commit. Omit to use a default 'chore: update <relative_path>' message."
    • addedInput schema / properties / content / description
      Added value: +"Full text to write as the file's new content, replacing whatever was there before."
    • addedInput schema / properties / relative_path / description
      Added value: +"Path to the file relative to the HA config directory to write, e.g. 'automations.yaml'. Same extension and location limits as `files_write_config_file`."
  2. First observedv0.3.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare the safety profile (readOnlyHint=false, destructiveHint=false, idempotentHint=true); the description adds real behavioral detail beyond that — the two-phase ordering (checkpoint commit of dirty tree, then write, then commit), the conditional 'only when the tree is dirty'/'if the write succeeded', the exact error surfaces (`RuntimeError` when `_repo()` finds no repo), and the partial-failure case where a YAML validation failure leaves the checkpoint commit but no new-content commit. This is exactly the side-effect disclosure a mutation tool needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the action, then cleanly sectioned into Use when / Not for / Returns / Errors / Limits — easy to scan for the relevant fact. Minor wordiness in the phrase 'calls the same `write_config_file` logic `files_write_config_file` uses' keeps it just under top marks.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Even though an output schema exists (so return values need not be spelled out), the description goes further by documenting the return shape, the error paths, the partial-failure state after a failed validation, and the 'does not reload Home Assistant' limit. Nothing an agent needs to invoke or recover from this tool is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description still adds meaning beyond the schema by tying `commit_message` to the success condition ('with `commit_message` ... if the write succeeded') and by noting the underlying write logic is the same `files_write_config_file` logic for `relative_path`/`content`, so extension/location limits carry over.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Write one config file after committing a checkpoint of the prior state') and explicitly contrasts with `files_write_config_file` and `esphome_write_config` — an agent can distinguish it from siblings without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'Use when' (overwriting while keeping a git rollback point) and 'Not for' clauses that name the exact alternative tools for the non-checkpoint write and for ESPHome YAML. It also states the prerequisite ('run `git_init_config` first') when no repo exists.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools