gradient-detection

gradient-detection is a skill for Claude Code, Codex from zjunlp/Mechanist. It costs 134 tokens per session (855 once invoked), scanned A, original, MIT.

A method for finding which inputs, internal model states, or parameters most affect a model’s output by measuring how sensitive a result is to them.

In plain words
What is it for?
Use it to investigate why a model produces a particular score, prediction, or loss, then identify candidates for deeper causal testing.
Why use it?
It gives a quick way to rank potentially important parts of a model before testing whether changing them truly causes the behavior.

Skill for Claude CodeCodex

Part of the mechanist plugin — 54 skills, 4 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zjunlp/mechanist/gradient-detection
Any agent
npx skills add zjunlp/Mechanist --skill gradient-detection
Clone the repo
git clone --depth 1 https://github.com/zjunlp/Mechanist

Made for: Claude Code, Codex.

Or install mechanist, the plugin that ships this one along with the rest of its 54 skills, 4 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gradient-detection

README.md
[![agentmods](https://agentmods.dev/badge/skills/zjunlp/mechanist/gradient-detection.svg)](https://agentmods.dev/skills/zjunlp/mechanist/gradient-detection)
Your own site
<a href="https://agentmods.dev/skills/zjunlp/mechanist/gradient-detection"><img src="https://agentmods.dev/badge/skills/zjunlp/mechanist/gradient-detection.svg" alt="Measured on agentmods" height="20"></a>
Per session 134 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 855 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00134 $0.00855
Opus 5 $0.00067 $0.00428
Sonnet 5 $0.00027 $0.00171
Haiku 4.5 $0.00013 $0.00085

Measured 3d ago against content hash cda50b8700ab, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gradient-detection scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 6 executable files (inputs-and-layer-wise-states/scripts/calculate_gradients.py, inputs-and-layer-wise-states/scripts/visualize_gradients.py, intermediate-outputs/scripts/basic_relp_analysis.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mechanism-skills/gradient-detection/SKILL.md · 31 lines

How it starts

The opening of the file, as written. The whole thing — 31 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Advantage

Gradient Detection can be applied to many types of objects (inputs, activations, parameters) without additional training. It only requires a backward pass, making it efficient for quickly ranking important components. Compared with exhaustive interventions, it can produce rankings with a relatively small number of backward passes, making it practical as an initial localization step when the candidate set is large.

Limitation

Gradients provide a local proxy, not causal necessity: salience can be offset by downstream computation, and finite interventions may depart from first-order effects in non-linear regimes. For these reasons, gradient-ranked objects are typically paired with Causal Attribution to validate whether the identified objects are genuinely responsible for the target behavior.

Submethods

Given object categories, the method typically takes three forms:

  • Inputs and Layer-wise States: For input embeddings $x_i^0$ and the residual stream state $x^l$, gradients directly quantify how sensitive $F(x)$ is to changes in specific prompt components and their propagated representations. In practice, one computes $\nabla_{x_i^0} F(x)$ or $\nabla_{x^l} F(x)$ and derives token-level influence, such as the gradient norm $|\nabla_{x_i^0} F(x)|$, the gradient–input score $\nabla_{x_i^0} F(x)^\top x_i^0$, or integrated gradients. Aggregating these scores across positions $i$ (optionally across layers $l$) yields a ranked view of which tokens or contextual spans are most responsible for a target output, as used to analyze CoT prompting and which depth regions contribute most strongly to the formation of that output, with closely related layer-/token-saliency signals also supporting dynamic token pruning and inference-time steering. You can find a demo for this method in ./inputs-and-layer-wise-states.This demo shows layer-gradient: Analyze and visualize layer-wise gradient behaviors in LLMs during fine-tuning for fast vs slow thinking tasks, calculate gradient statistics, and understand training patterns across different model layers

Read the full file on GitHub · 31 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 31 lines · 134 tokens per session scan A cda50b8700ab

Subscribe to this mod's changes

gradient-detection is a skill published in the GitHub repository zjunlp/Mechanist (51 stars, last pushed 8d ago), licensed MIT. It adds 134 tokens to every session and 855 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

skypilot-multi-cloud-orchestration

Multi-cloud orchestration for ML workloads with automatic cost optimization. Use when you need to run training or batch jobs across multiple clouds, leverage spot instances with auto-recovery, or optimize GPU costs across providers.

OpenRaiser/NanoResearch · 51 tokens

potpie-source-ingestion

Use when the user explicitly asks to ingest, refresh, or deeply understand a repository, PR, issue, ticket, runbook, incident report, document, or web link into Potpie. The harness performs todo-driven discovery, uses local/GitHub/integration tools and read-only subagents when available, builds evidence-backed…

potpie-ai/potpie · 82 tokens

create-atomic-context-provider

Build a BaseDynamicContextProvider that injects a named, titled block into an agent's system prompt at every run() — current time, user identity, retrieved RAG docs, session state, cached DB schema. Use when the user asks to "add a context provider", "inject X into the prompt", "give the agent dynamic context", "wire…

Eigenwise/atomic-agents · 106 tokens

synalinks

Use for anything involving the Synalinks neuro-symbolic LM framework (Keras-inspired) — DataModel/Field/Input, JSON operators (+ & | ^ ), synalinks.ops, LanguageModel/EmbeddingModel and provider prefixes (openai/anthropic/ollama/groq/openrouter/bedrock/...); the Program class and its four building APIs…

SynaLinks/synalinks-skills · 290 tokens

scienceworld-ambiguous-action-resolution

Use when the ScienceWorld environment returns an "Ambiguous request" prompt with a numbered list of identical action options. This skill resolves the disambiguation by selecting the lowest available number (typically 0) to proceed, ensuring task progression when multiple identical object instances exist and the system…

zjunlp/SkillNet · 73 tokens

brainstorming-research-ideas

Guides researchers through structured ideation frameworks to discover high-impact research directions. Use when exploring new problem spaces, pivoting between projects, or seeking novel angles on existing work.

OpenRaiser/NanoResearch · 43 tokens