Skip to main content
Glama

validate

Verify forge module changes compile, run, and meet API contracts before merging. Checks files, syntax, commands, and cross-module dependencies, tracking progress across attempts.

Instructions

Run full verification for a forge module against a specific working directory. Executes the module's verify commands in a subprocess, checks that required files exist on disk, runs AST-level syntax validation for .js/.mjs/.cjs/.py/.ts/.tsx files, and performs cross-module API contract checks (importer references matched against exporter symbols). Tracks attempts across retries, detects stagnation when the same failure set recurs, measures score velocity across attempts, and flags oscillation when the current failures match any of the last four attempts. Returns a structured pass/fail verdict with a per-check breakdown and a recommendation field (PROCEED, RETRY, ESCALATE).

Behaviour:

  • MUTATION. Appends an attempt entry to the module's iteration state at .forge/iterations/<runId>/<moduleId>.json when runId is provided, or the legacy flat path otherwise. Also emits a tool_call and a validate event to the current run's JSONL log.

  • No authentication, no network calls, no rate limits.

  • Verify commands run with a 2-minute per-command timeout; AST syntax checks get 60 seconds each. Commands execute through the shell (execSync) so plan-generated commands can use pipes and redirects — plans are human-approved before execution.

  • The cwd argument (v0.4.0+) redirects file existence checks, syntax checks, contract checks, and command execution to a specified directory. Precedence: args.cwd > FORGE_CWD env > process.cwd(). Workers running in isolated git worktrees MUST pass their worktree path as cwd — otherwise validation silently checks the main project root, and every worker DONE report would be meaningless.

  • Nonexistent cwd returns a cwd_check failure with recommendation: "ESCALATE" and a clear diagnostic, rather than letting every command fail with an opaque ENOENT.

Use when:

  • The orchestrator has received a DONE report from a worker agent and needs to verify that the changes actually compile, run, and honor any cross-module API contracts before merge-back.

  • A module has just been retried by the debugger agent and you want to know whether the attempt count has crossed the stagnation threshold.

  • A user invokes /forge-validate <moduleId> manually to re-run checks on a completed or in-progress module.

Do NOT use for:

  • Plan-level structural checks (DAG cycles, missing commands) — use validate_plan instead.

  • Querying past validation attempts without bumping a counter — use forge_logs or iteration_state with action: "get".

  • Running commands outside the context of a known moduleId — this tool mutates per-module iteration state.

Returns: A JSON text block with { passed, score, results[], attempt, stagnant, velocity, oscillating, recommendation, sameAsPrev } where results[] is a list of per-check objects tagged with type (file_check, syntax_check, contract_check, command, cwd_check) and their pass/fail metadata.

Example: validate({ moduleId: "m3", runId: "2026-04-15-1", files: ["src/auth.mjs", "src/auth.test.mjs"], commands: ["node --test src/auth.test.mjs"], cwd: "/tmp/forge-worktrees/m3" }) → { "passed": true, "score": 1.0, "recommendation": "PROCEED", "results": [ ... ], "attempt": 1, "stagnant": false }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
moduleIdYesModule ID (e.g. m1, m2)
runIdNoOptional run ID (plan slug). Scopes iteration state so attempts from different forge runs don't pollute each other. Strongly recommended — without it, attempts accumulate across all runs forever.
cwdNoOptional absolute path to redirect file checks and command execution. Workers running in git worktrees should pass their worktree path here so validation sees their changes. Precedence: args.cwd > FORGE_CWD env > process.cwd(). Must exist when provided — nonexistent paths return a cwd_check failure with recommendation=ESCALATE.
commandsYesShell commands to run as verification checks
filesNoFile paths (relative to the validation working dir — `cwd` if provided, else server CWD) that should exist after module completion
contractChecksNoOptional cross-module API contract checks — verifies importer references match exporter exports
Behavior5/5

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

With no annotations provided, the description carries full burden and delivers comprehensive behavioral disclosure. It details mutation behavior (appends to iteration state, emits events), execution constraints (timeouts, shell execution), authentication/network/rate limit status, cwd precedence rules, and failure handling for nonexistent paths.

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?

The description is well-structured with clear sections (Behavior, Use when, Do NOT use, Returns, Example) and front-loaded core purpose. While comprehensive, some sentences could be more concise (e.g., the cwd precedence explanation is verbose). Overall, most content earns its place.

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 complex mutation tool with 6 parameters, no annotations, and no output schema, the description provides exceptional completeness. It covers purpose, usage guidelines, behavioral details, parameter context, return structure with example, and distinguishes from all relevant sibling tools, leaving no significant gaps.

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 adds meaningful context beyond schema: it explains cwd precedence rules, consequences of nonexistent cwd, that commands use shell execution allowing pipes/redirects, and that contract checks verify importer references match exporter exports. However, it doesn't fully explain all parameter interactions.

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 explicitly states the verb ('Run full verification') and resource ('forge module'), clearly distinguishing it from siblings like 'validate_plan' for plan-level checks. It specifies the comprehensive scope including verification commands, file existence, syntax validation, and API contract checks.

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?

The description includes explicit 'Use when' scenarios (e.g., after DONE report, after retry, manual validation) and 'Do NOT use for' exclusions (e.g., plan-level checks, querying past attempts), naming specific alternative tools like 'validate_plan', 'forge_logs', and 'iteration_state'.

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/TT-Wang/forge'

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