pyvene-interventions

pyvene-interventions is a skill for Claude Code, Codex from davila7/claude-code-templates. It costs 46 tokens per session (3,364 once invoked), scanned A, original, MIT.

A guide to pyvene, a PyTorch library for changing internal neural-network values during an experiment. These controlled changes help test whether a particular model component causes a behaviour.

In plain words
What is it for?
Use it for causal tracing, activation patching, interchange intervention training, and testing explanations of PyTorch models.
Why use it?
It provides a repeatable way to investigate how a model produces its outputs instead of only measuring the final answer.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for causal tracing, activation patching, interchange intervention training, and testing explanations of PyTorch models.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene
About the project

Claude Code Templates is a command-line tool and catalogue for configuring Anthropic’s Claude Code with agents, commands, settings, hooks, integrations, skills, and project templates. Developers use it to browse and install reusable components for their coding workflows. The catalogue includes many of these Claude Code components.

davila7/claude-code-templates · 32,882 stars · on GitHub · aitmpl.com

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.

Any agent
npx skills add davila7/claude-code-templates --skill mechanistic-interpretability-pyvene
Clone the repo
git clone --depth 1 https://github.com/davila7/claude-code-templates

Made for: Claude Code, Codex.

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 pyvene-interventions

README.md
[![agentmods](https://agentmods.dev/badge/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene/github.svg)](https://agentmods.dev/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene)
Your own site
<a href="https://agentmods.dev/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pyvene-interventions

Your own site · 80×15
<a href="https://agentmods.dev/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/mechanistic-interpretability-pyvene.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,364 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00046 $0.03364
Opus 5.5 $0.00018 $0.01346
Sonnet 5.5 $0.00009 $0.00673
Haiku 4.5 $0.00005 $0.00336

Measured today against content hash 1aa3b030abf8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pyvene-interventions 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 today.

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.

Origin

Copies of this mod

3 near-identical copies found in the catalogue:

cli-tool/components/skills/ai-research/mechanistic-interpretability-pyvene/SKILL.md · 475 lines

How it starts

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

pyvene: Causal Interventions for Neural Networks

pyvene is Stanford NLP's library for performing causal interventions on PyTorch models. It provides a declarative, dict-based framework for activation patching, causal tracing, and interchange intervention training - making intervention experiments reproducible and shareable.

GitHub: stanfordnlp/pyvene (840+ stars) Paper: pyvene: A Library for Understanding and Improving PyTorch Models via Interventions (NAACL 2024)

When to Use pyvene

Use pyvene when you need to:

  • Perform causal tracing (ROME-style localization)
  • Run activation patching experiments
  • Conduct interchange intervention training (IIT)
  • Test causal hypotheses about model components
  • Share/reproduce intervention experiments via HuggingFace
  • Work with any PyTorch architecture (not just transformers)

Consider alternatives when:

  • You need exploratory activation analysis → Use TransformerLens
  • You want to train/analyze SAEs → Use SAELens
  • You need remote execution on massive models → Use nnsight
  • You want lower-level control → Use nnsight

Installation

pip install pyvene

Standard import:

import pyvene as pv

Core Concepts

IntervenableModel

The main class that wraps any PyTorch model with intervention capabilities:

import pyvene as pv
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load base model
model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")

# Define intervention configuration
config = pv.IntervenableConfig(
    representations=[
        pv.RepresentationConfig(
            layer=8,
            component="block_output",
            intervention_type=pv.VanillaIntervention,
        )
    ]
)

# Create intervenable model
intervenable = pv.IntervenableModel(config, model)

Intervention Types

Type Description Use Case
VanillaIntervention Swap activations between runs Activation patching
AdditionIntervention Add activations to base run Steering, ablation
SubtractionIntervention Subtract activations Ablation
ZeroIntervention Zero out activations Component knockout
RotatedSpaceIntervention DAS trainable intervention Causal discovery
CollectIntervention Collect activations Probing, analysis

Read the full file on GitHub · 475 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. today Changed · +1 lines 1aa3b030abf8
  2. 1mo ago First seen · 474 lines · 46 tokens per session scan A cc26be84bdf2

Subscribe to this mod's changes

pyvene-interventions is a skill published in the GitHub repository davila7/claude-code-templates (32,882 stars, last pushed today), licensed MIT. It adds 46 tokens to every session and 3,364 once invoked, about $0.0002 per session on Opus 5.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-09-03.

Related

Other skills, from other repositories

ccc-data

Route data work to the right method: ETL/ELT pipelines, SQL optimization, charts and dashboards, machine learning, data quality, product analytics, scheduled reports, or vector search. Use when the user is building, querying, validating or visualizing data, or types $ccc-data.

KevinZai/commander · 62 tokens

couchbase-fts

Design, build, and tune Couchbase Full Text Search (FTS) and vector search indexes. Use whenever the user asks about FTS indexes, Search service, text search, full-text search, fuzzy search, phrase search, wildcard search, regex search, geo search, geo-distance, geo-bounding-box, facets, scoring, boosting, analyzers…

celticht32/Couchbase-Skills-for-Claude.ai · 208 tokens

couchbase-ai-applications

Design and build AI-powered applications on Couchbase, including RAG pipelines, vector search architecture, embedding strategies, and AI agent data patterns. Use whenever the user asks about RAG, retrieval-augmented generation, vector search for AI, Hyperscale Vector Index (HVI), Composite Vector Index (CVI), Search…

celticht32/Couchbase-Skills-for-Claude.ai · 202 tokens

feature-engineer

Design and create ML features — encoding, scaling, interaction terms, embeddings, and feature selection.

inbharatai/claude-skills · 23 tokens

gcp-architect

Design Google Cloud architectures — GKE, Cloud Run, BigQuery, Pub/Sub, and Cloud Spanner solutions.

inbharatai/claude-skills · 28 tokens

midjourney-prompter

Engineer Midjourney prompts — style references, aspect ratios, negative prompts, and v6 parameter tuning.

inbharatai/claude-skills · 28 tokens