Skip to main content
Glama

propose_commit

Validate and save code files by enforcing strict formatting rules, including header comments, nesting depth, and file length limits, while creating restore points for safety.

Instructions

The ONLY way to write code. Validates the code against strict rules before saving: 2-line header comments, no inline comments, max nesting depth, max file length. Creates a shadow restore point before writing. REJECTS code that violates formatting rules.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesWhere to save the file (relative to project root).
new_contentYesThe complete file content to save.

Implementation Reference

  • The proposeCommit function implements the core tool logic: validating file headers, inline comments, and code complexity (nesting depth) before saving the file and creating a shadow restore point.
    export async function proposeCommit(options: ProposeCommitOptions): Promise<string> {
      const fullPath = resolve(options.rootDir, options.filePath);
      const ext = extname(fullPath);
      const lines = options.newContent.split("\n");
      const allErrors: ValidationError[] = [];
    
      if (isSupportedFile(fullPath)) {
        allErrors.push(...validateHeader(lines, ext));
        allErrors.push(...validateNoInlineComments(lines, ext));
      }
      allErrors.push(...validateAbstraction(lines));
    
      const commentErrors = allErrors.filter((e) => e.rule === "no-comments");
      if (commentErrors.length > 5) {
        return [
          `REJECTED: ${allErrors.length} violations found.\n`,
          ...allErrors.slice(0, 10).map((e) => `  ❌ [${e.rule}] ${e.message}`),
          allErrors.length > 10 ? `  ... and ${allErrors.length - 10} more violations` : "",
          "\nFix all violations and resubmit.",
        ].join("\n");
      }
    
      const warnings = allErrors.filter((e) => e.rule !== "no-comments" || commentErrors.length <= 5);
    
      await createRestorePoint(options.rootDir, [options.filePath], `Pre-commit: ${options.filePath}`);
      await mkdir(dirname(fullPath), { recursive: true });
      await writeFile(fullPath, options.newContent, "utf-8");
    
      const result = [`✅ File saved: ${options.filePath}`];
      if (warnings.length > 0) {
        result.push(`\n⚠ ${warnings.length} warning(s):`);
        for (const w of warnings) result.push(`  ⚠ [${w.rule}] ${w.message}`);
      }
      result.push(`\nRestore point created. Use undo tools if needed.`);
    
      return result.join("\n");
    }
  • Input validation interface for propose_commit tool.
    export interface ProposeCommitOptions {
      rootDir: string;
      filePath: string;
      newContent: string;
    }
Behavior5/5

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

No annotations provided, so description carries full burden. Excellent disclosure: lists specific validation constraints (2-line headers, no inline comments, max nesting/length), discloses automatic side effect (creates shadow restore point), and specifies failure mode (rejects violations). Rich safety and behavioral context.

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?

Four dense sentences with zero waste. Opens with strong positional claim ('The ONLY way'), efficiently lists validation constraints, discloses restore point creation, and states rejection policy. Every sentence earns its place.

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

Completeness4/5

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

For a 2-parameter write tool with complex side effects (validation, restore points), description adequately covers the validation rules, backup behavior, and failure modes. No output schema exists, but the description provides sufficient behavioral coverage for agent to understand consequences of invocation.

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 has 100% description coverage, establishing baseline of 3. Description mentions validation rules that apply to new_content (no inline comments, etc.) adding some semantic context, but does not add usage syntax, format details, or specific mappings beyond what the schema already provides for file_path and new_content.

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?

Description explicitly states this is the code writing tool ('The ONLY way to write code') and distinguishes from siblings (mostly search/read tools like search_memory_graph, get_context_tree) by claiming exclusivity for write operations and mentioning validation/restore behaviors unique to this tool.

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

Usage Guidelines4/5

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

The 'ONLY way to write code' provides clear usage priority. Explicitly states rejection criteria ('REJECTS code that violates formatting rules'). Mentions restore point creation, implying relationship to undo_change sibling, though could explicitly reference that tool for reverting.

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/ForLoopCodes/contextplus'

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