Skip to main content
Glama

analyze_pr_behavior

Compare working tree against a base ref's merge-base via a detached worktree; output added/removed/modified node counts, affected workflows and narratives, top 25 risk nodes, and dirty-tree state.

Instructions

Computes a behavioral diff between the working tree and the merge-base of HEAD with a base ref, using a detached git worktree. Returns added, removed and modified node counts (modified = same declaration, changed body hash — a rewrite that keeps its name and callees), the affected workflows with narratives, and the top 25 nodes by risk. Reports whether the working tree was dirty, since that makes the result non-reproducible from commits alone. Requires a git repository with a resolvable base ref: if none exists the call returns an error rather than a fabricated baseline. Base ref defaults to origin/main, then origin/master, main, master, HEAD~1.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseRefNoGit ref to find the merge-base against. Example: 'origin/develop' or a commit SHA.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.0.1
    • changedInput schema / properties / baseRef / description
      Previous value: -"Git ref to diff against. Defaults: origin/main → main → HEAD~1. Example: 'origin/develop' or a commit SHA."New value: +"Git ref to find the merge-base against. Example: 'origin/develop' or a commit SHA."
  2. Changed1 schema field changedv2.1.10
    • addedInput schema / properties / baseRef / description
      Added value: +"Git ref to diff against. Defaults: origin/main → main → HEAD~1. Example: 'origin/develop' or a commit SHA."
  3. First observed

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the use of a detached worktree, the non-reproducibility implication of a dirty tree, and the error-on-unresolvable-base behavior. It stops short of explicitly stating whether the operation is read-only or has side effects (e.g., worktree cleanup), but the passive 'computes' and focus on diff analysis suggest a safe read. The dirty-tree flag is a thoughtful behavioral disclosure.

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 detailed but well-organized: it leads with the core computation, then lists outputs, then notes the dirty-tree caveat, and ends with prerequisites and defaults. Every sentence adds relevant information, and the structure is logical, though slightly dense for a quick scan. It earns its length given the tool's complexity.

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 tool with no output schema, the description is thorough: it explains what is computed, defines 'modified' precisely, lists all return categories (counts, workflows, risk nodes), and covers edge cases (dirty tree, unresolvable base). It also states the default base ref resolution. An agent has enough to call it correctly and interpret results, making this complete.

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?

The schema already documents baseRef with an example, so coverage is 100%. The description adds meaningful context beyond the schema: the default resolution order (origin/main, origin/master, main, master, HEAD~1) and the condition that an unresolvable base returns an error rather than fabricating a baseline. This enriches the parameter's meaning beyond a simple string type.

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 opens with a specific verb ('Computes') and resource ('behavioral diff'), and precisely defines the scope ('working tree vs merge-base of HEAD with a base ref'). It clearly distinguishes this tool from siblings like detect_drift or analyze_repository by focusing on PR-specific diff analysis, and enumerates concrete outputs (added/removed/modified counts, workflows, risk nodes).

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 description provides clear context for invocation: it requires a git repository with a resolvable base ref and explains the default fallback order. It does not explicitly contrast with alternative tools or state when not to use it, but the specificity of 'behavioral diff for PRs' implies its niche. The error behavior for missing base refs gives a clear precondition.

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