Skip to main content
Glama

auto_commit_changes

Automatically commit AI-generated changes to your repository with a clear commit message. Optionally specify files or amend the latest session commit for streamlined version control.

Instructions

Automatically commit AI-made changes with tracking

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesCommit message
filesNoSpecific files to commit
amendSessionNoAmend to current session commit

Implementation Reference

  • Main handler for auto_commit_changes tool. Checks git repo, checks for changes, stages files, creates commit with [AI] prefix, and returns success/failure.
    async autoCommitChanges(options: AutoCommitOptions): Promise<ToolResult> {
      try {
        const { message, files, amendSession = true, skipIfNoChanges = true } = options;
        const cwd = this.workspaceService.getCurrentWorkspace();
        
        // Check if we're in a git repository first
        const gitCheckResult = await this.gitCommand(['rev-parse', '--git-dir'], cwd);
        if (gitCheckResult.isError || gitCheckResult.content[0]?.text?.includes('not a git repository')) {
          return {
            isError: true,
            content: [{
              type: 'text',
              text: 'Auto-commit failed: Not a git repository'
            }]
          };
        }
        
        // Check if there are any changes to commit
        if (skipIfNoChanges) {
          const statusResult = await this.gitStatus({ cwd });
          if (!statusResult.isError) {
            const statusText = statusResult.content[0]?.text;
            // Check if status is empty (no changes) or explicitly mentions no changes
            if (!statusText || 
                statusText.trim() === '' || 
                statusText === 'Command completed successfully' ||
                statusText.includes('nothing to commit') || 
                statusText.includes('working tree clean') ||
                statusText.includes('working directory clean')) {
              return {
                content: [{
                  type: 'text',
                  text: 'No changes to commit'
                }]
              };
            }
          }
        }
    
        // Stage the files
        const addArgs: GitAddArgs = { cwd };
        if (files && files.length > 0) {
          addArgs.files = files;
        } else {
          addArgs.all = true;
        }
    
        const addResult = await this.gitAdd(addArgs);
        if (addResult.isError) {
          return addResult;
        }
    
        // Prepare commit message with AI prefix
        const commitMessage = `[AI] ${message}`;
    
        const commitArgs: GitCommitArgs = {
          message: commitMessage,
          cwd
        };
    
        const commitResult = await this.gitCommit(commitArgs);
        if (commitResult.isError) {
          return {
            isError: true,
            content: [{
              type: 'text',
              text: `Auto-commit failed: ${commitResult.content[0]?.text || 'Failed to commit changes'}`
            }]
          };
        }
    
        // Return success with commit message
        return {
          content: [{
            type: 'text',
            text: `Successfully committed changes: ${commitMessage}`
          }]
        };
    
      } catch (error) {
        return {
          isError: true,
          content: [{
            type: 'text',
            text: `Auto-commit failed: ${error instanceof Error ? error.message : String(error)}`
          }]
        };
      }
    }
  • Input options interface for autoCommitChanges: message (required), files, amendSession, skipIfNoChanges.
    export interface AutoCommitOptions {
      message: string;
      files?: string[];
      amendSession?: boolean;
      skipIfNoChanges?: boolean;
    }
  • Tool definition with inputSchema: requires message, optional files (array of strings) and amendSession (boolean).
    name: 'auto_commit_changes',
    description: 'Automatically commit AI-made changes with tracking',
    inputSchema: {
      type: 'object',
      properties: {
        message: { type: 'string', description: 'Commit message' },
        files: { type: 'array', items: { type: 'string' }, description: 'Specific files to commit' },
        amendSession: { type: 'boolean', description: 'Amend to current session commit' }
      },
      required: ['message']
    }
  • src/index.ts:355-360 (registration)
    Case statement in the tool dispatcher routing 'auto_commit_changes' to gitService.autoCommitChanges() with args.
    case 'auto_commit_changes':
      return await this.gitService.autoCommitChanges({
        message: args.message,
        files: args.files,
        amendSession: args.amendSession
      });
  • Helper call to autoCommitChanges after running a command, used when gitAutoCommit config is enabled.
    if (commitResult) {
      const config = await this.configService.loadProjectConfig();
      if (config.gitAutoCommit) {
        const message = commitMessage || `Executed command: ${command}`;
        await this.gitService.autoCommitChanges({
          message,
          skipIfNoChanges: true
        });
Behavior2/5

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

No annotations exist, so the description carries full burden. It mentions 'with tracking' but does not explain what tracking entails or disclose side effects (e.g., whether it creates a new commit, reverts previous changes, or needs authentication). The behavior is underspecified.

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

Conciseness3/5

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

The description is extremely concise (one phrase). While efficient, it lacks structure and could include a brief sentence on behavior or typical use cases. It is not verbose but sacrifices clarity for brevity.

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

Completeness2/5

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

For a tool with no output schema and three parameters, the description is insufficient. It does not explain return values, error handling, or the impact on the repository. An agent has little context to invoke this tool correctly without guessing.

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?

Schema coverage is 100%, so the schema already documents each parameter. The description adds no additional meaning beyond what the schema provides, but the baseline of 3 is appropriate as the schema is self-contained.

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

Purpose4/5

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

The description clearly indicates the tool commits changes, specifically 'AI-made' with 'tracking'. This distinguishes it from the generic git_commit sibling, but the phrasing 'automatically commit AI-made changes' is somewhat vague regarding what qualifies as 'AI-made'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like git_commit or git_add. The description implies it's for AI-generated changes but does not state explicit conditions, prerequisites, or scenarios where it should be preferred.

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/agentics-ai/code-mcp'

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