Skip to main content
Glama

Lint strategy code for lookahead and bias

check_code
Read-onlyIdempotent

Review Python/pandas backtest code statically to detect lookahead bias, data leakage, and invalid validation; return rule IDs, severity, fix hints, and a 0-100 audit score.

Instructions

Static review of Python/pandas strategy code for patterns that inflate backtests: negative shifts in features or signals, centered windows, backward fill, fitting before the time split, shuffled CV, signal and fill on the same bar, labels on the wrong bar, today's index constituents, yfinance caveats, intraday resample labels, global normalization, target leakage, full-sample parameter search and missing costs. Each finding has a rule id, severity (high/medium/possible/info), line, why it inflates results and a fix hint. Returns Markdown plus JSON with a 0-100 audit score, and suggested_fixes: minimal line edits for unambiguous findings, each re-checked by re-linting (often empty). For files on disk, prefer check_path.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "source": "<source>"
    },
    "name": "check_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
sourceYesPython source of the strategy/backtest (pandas, numpy, sklearn, vectorbt, backtrader...). Paste the whole file or notebook cells.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.7.0

TDQS

A4.4/5.0
Behavior5/5

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

Beyond the readOnly and idempotent annotations, the description discloses finding structure (rule id, severity, line, explanation, fix hint), output formats, a numeric audit score, and that suggested_fixes are re-linted and often empty. This adds substantial behavioral context for a static lint tool.

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 front-loaded with purpose and alternatives, and every sentence contributes useful information. The long enumeration of patterns is dense but justified by the tool's breadth, though it could be more scannable.

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?

Given the tool's complexity, output schema, and annotations, the description is complete enough to invoke it correctly. It covers input context, detection scope, output shape, suggested fixes, and the check_path alternative.

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 schema already fully documents the single source parameter, including that whole files or notebook cells can be pasted. The description reinforces the Python/pandas context but adds little parameter-level meaning beyond the 100%-covered schema.

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 and resource: static review of Python/pandas strategy code for patterns that inflate backtests. It lists concrete lookahead and bias patterns and explicitly distinguishes itself from check_path for files on disk.

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?

It gives clear usage context for pasted source or notebook cells and explicitly routes files on disk to check_path. It does not spell out when not to use check_code beyond that alternative, so it falls short of fully explicit when/when-not guidance.

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