Skip to content
Back to skills

Variable Tracker

BSecurity

Track Python variable definitions, uses, and scope across files

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 16, 2026
toolspythonbashnodedebugginggit

Works with

  • cli

Security analysis

B88/100
  • criticalModifies startup scripts or system services for persistence

Pro scans all 4 files and shows the line behind each finding

Scanned October 16, 2026

npx -y skills add G-Eskayo/marvin --skill variable-tracker --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Variable Tracker?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Variable Tracker
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/g-eskayo-variable-tracker/badge)](https://www.skillsdirectory.com/skills/g-eskayo-variable-tracker)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: variable-tracker
description: Track Python variable definitions, uses, and scope across files
tags: [domain:code-navigation, intent:analysis, type:skill]
---

# Variable Tracker Skill

Find where a Python variable is defined, where it's used, and what scope it belongs to — without reading the whole file.

## Triggers

Load this skill when you're:
- "track this variable" / "where is X defined/used"
- Starting work on an unfamiliar Python file
- Asking "what's the state of X" — did we mutate it, is it stale?
- Debugging variable shadowing or scope issues

## CLI usage

```bash
# After running install.sh:
track-vars <path> [<path>...]                    # scan file(s) or dir(s)
track-vars <path> --name X                       # find variable X only
track-vars <path> --since HEAD~1                 # only files changed since commit
track-vars <path> --format json                  # JSON output for piping
```

## Output format

Default text output: compact, inline-friendly, meant to paste into conversation:

```
cfg    [module]    lib/config.py    (dict)
  def    L12    cfg = load_config()
  use    L15    return cfg["timeout"]
  use    L30    log_config(cfg)
```

Columns: variable name, scope, file, inferred type (if annotated).  
Each var tracks definitions (assignments, parameters, for/with targets) and uses (loads).

Same variable name in different scopes (e.g., `x` in module vs `x` in `func1()`) tracked separately — shadowing isn't conflated.

JSON output (`--format json`) suitable for tool chaining:

```json
[
  {
    "name": "cfg",
    "scope": "[module]",
    "file": "lib/config.py",
    "definitions": [
      {"line": 12, "kind": "assign", "snippet": "cfg = load_config()"}
    ],
    "uses": [
      {"line": 15, "snippet": "cfg[\"timeout\"]"}
    ]
  }
]
```

## Extraction logic

Python-only (v1). Walks the AST:
- **Definitions**: assignments, annotated assignments, augmented assignments (+=), for/with targets, function parameters, global/nonlocal declarations
- **Uses**: Name nodes in Load context (reading a var)
- **Scope**: module-level or function name; same var in different scopes tracked as separate records

Type annotations from `x: int = 10` are captured.

## Filters

- `--name X`: return only variable X across all scanned files/scopes
- `--since <git-ref>`: restrict scan to files changed since `<ref>` (via `git diff --name-only`)

## Directory traversal

Recursively scans `.py` files; skips `venv`, `node_modules`, `.git`, `__pycache__`, `.venv`.

## Install

```bash
bash ~/.agents/skills/variable-tracker/install.sh
source ~/.zshrc
```

Then use `track-vars` from anywhere in the repo.

Files in this skill

  • SKILL.md2.6 KB
  • install.sh833 B
  • scripts/tests/test_track_vars.py8.1 KB
  • scripts/track_vars.py12.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.