Skip to main content
Glama

Commit repository files atomically

gh_commit_files
Destructive

Create or replace repository files in a single GitHub commit and conditionally advance a branch only when its current SHA matches the expected head. Prevents overwriting concurrent changes.

Instructions

Destructive write: create or replace bounded UTF-8 file contents in one Git commit and conditionally advance exactly one existing branch only when its head matches expected_head_sha. Ordinary write authorization and the content-commit fine gate are required. The branch advance uses one exact compare-and-swap attempt followed by authoritative ref readback; it cannot delete files, force-update the ref, or blindly retry an ambiguous update.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoYesGitHub repository name without the owner prefix.
filesYesComplete UTF-8 file replacements for the atomic commit.
ownerYesGitHub repository owner or organization login.
branchYesExisting branch to advance conditionally.
commit_messageYesGit commit message.
expected_head_shaYesExact branch head SHA required before the write.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNo
branchYes
messageYes
warningNo
tree_shaNo
commit_shaNo
request_idNo
ref_updatedNo
files_committedNo
write_completedYes
observed_head_shaNo
previous_head_shaYes
readback_attemptsNo
readback_completedYes
precondition_checkedYes
state_matches_requestedYes
Behavior5/5

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

The description goes well beyond the annotations (destructiveHint=true) by detailing the compare-and-swap mechanism, the inability to delete files or force-update, and the single retry policy. It also clarifies authorization requirements and the 'content-commit fine gate', providing rich behavioral context not available in annotations.

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

Conciseness5/5

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

Two sentences, front-loaded with the 'Destructive write' warning, and no wasted words. Every clause adds meaningful constraint or behavior, making it highly efficient.

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?

For a destructive write tool with an output schema and strong annotations, this description covers essential behavioral aspects: atomicity, conditional branch advance, auth requirements, and limitations (no delete, no force-update, no ambiguous retries). It is complete enough for an agent to invoke safely.

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

Parameters3/5

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

The input schema has 100% coverage with descriptive text for every parameter. The description adds no new parameter-specific semantics; it only restates the conditional advance using expected_head_sha, which is already in the schema. Given high schema coverage, the baseline of 3 is appropriate.

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?

The description states a specific verb ('create or replace'), resource ('repository files'), and precise behavior ('in one Git commit and conditionally advance exactly one existing branch only when its head matches expected_head_sha'). It clearly distinguishes from sibling write tools like gh_create_branch or gh_merge_pr by emphasizing atomicity and conditional branch advance.

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

Usage Guidelines3/5

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

The description implies usage via its destructive-write warning and conditional advance, but it does not explicitly state when to use this tool versus alternatives (e.g., creating a PR, creating a branch). No exclusions or alternative tool names are mentioned, so guidance is only implied.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fvanevski/gh_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server