Agent skill

Code Instrumentation Generator

by ArabelaTso in ArabelaTso/Skills-4-SE

Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics.

Apache-2.0Auto-check passedDevelopment

Install Code Instrumentation Generator

skills CLI
$ npx skills add ArabelaTso/Skills-4-SE --skill code-instrumentation-generator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ArabelaTso/Skills-4-SE code-instrumentation-generator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/code-instrumentation-generator .claude/skills/code-instrumentation-generator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-instrumentation-generator
GitHub stars
253
Token cost
~2.3k tokens
SKILL.md length
386 words
Files
1
Skills in repo
151
Repo updated
First seen
Licence
Apache-2.0

At a glance

Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics.

  • Works in 5 steps: Analyze the Source Code → Determine Instrumentation Strategy → Insert Instrumentation Code → …
  • Tracing to code for debugging
  • SKILL.md covers Workflow, Language-Specific Patterns, Branch Instrumentation Example and Configuration-Based…, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Code Instrumentation Generator is an agent skill from ArabelaTso/Skills-4-SE. Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics. Use when users need to: (1) Add logging or tracing to code for debugging, (2) Collect runtime execution data for analysis, (3) Monitor function calls and control flow, (4) Track variable values during execution, (5) Generate execution traces for testing or profiling. Supports Python, Java, JavaScript, and C/C++ with…

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development. It works with C++, Java, JavaScript and Python. The repository describes itself as: A curated list of 180+ useful Claude Skills for Software Engineering and resources for customizing AI for SE workflows. The licence is Apache-2.0.

When your agent uses it

  • Tracing to code for debugging
  • Collect runtime execution data for analysis
  • Monitor function calls and control flow
  • Track variable values during execution

Example prompts

  • “/code-instrumentation-generator”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Analyze the Source Code
  2. Determine Instrumentation Strategy
  3. Insert Instrumentation Code
  4. Ensure Semantic Preservation
  5. Generate Output

What it can do on your machine

Read from SKILL.md and the folder at commit 4f38503. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python, java, javascript, c and markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Instrumentation Generator loads about 2.3k tokens when it runs. Until then it costs about 145 tokens; SKILL.md has 386 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~145
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ArabelaTso/Skills-4-SE at commit 4f38503, republished under its Apache-2.0 licence (© ArabelaTso). 386 words, ~2,290 tokens.

Download SKILL.mdSave it as .claude/skills/code-instrumentation-generator/SKILL.md (or your agent's skills folder).
name
code-instrumentation-generator
description
Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics. Use when users need to: (1) Add logging or tracing to code for debugging, (2) Collect runtime execution data for analysis, (3) Monitor function calls and control flow, (4) Track variable values during execution, (5) Generate execution traces for testing or profiling. Supports Python, Java, JavaScript, and C/C++ with configurable instrumentation levels.

Code Instrumentation Generator

Automatically instrument source code to collect runtime information while preserving program semantics.

Workflow

Follow these steps to instrument code:

1. Analyze the Source Code

Understand the code structure and identify instrumentation points:

  • Language detection: Identify the programming language
  • Code structure: Parse functions, classes, branches, loops
  • Entry/exit points: Locate function boundaries
  • Control flow: Identify branches (if/else, switch, loops)
  • Variable scope: Understand variable declarations and usage
2. Determine Instrumentation Strategy

Choose appropriate instrumentation based on requirements:

Instrumentation levels:

  • Function-level: Entry/exit of functions with parameters and return values
  • Branch-level: Execution of conditional branches (if/else, switch cases)
  • Statement-level: Individual statement execution
  • Variable-level: Variable assignments and value changes

Configuration options:

  • Enable/disable specific instrumentation types
  • Filter by function names or file patterns
  • Set verbosity level
  • Choose output format (logs, JSON, CSV)
3. Insert Instrumentation Code

Add instrumentation hooks at identified points:

Function instrumentation:

  • Insert entry hook at function start
  • Capture function name, parameters, timestamp
  • Insert exit hook before returns
  • Capture return value, execution time

Branch instrumentation:

  • Insert hooks at branch conditions
  • Record which branch was taken
  • Track branch coverage

Variable instrumentation:

  • Insert hooks after variable assignments
  • Capture variable name and value
  • Track value changes over time
4. Ensure Semantic Preservation

Verify that instrumentation doesn't change program behavior:

  • No side effects: Instrumentation code doesn't modify program state
  • Exception safety: Instrumentation handles exceptions properly
  • Performance: Minimal overhead added
  • Thread safety: Instrumentation is safe in concurrent code
Show full SKILL.md (155 more words)Show less
5. Generate Output

Provide instrumented code and documentation:

  • Instrumented source code: Modified code with instrumentation
  • Probe description: Documentation of inserted instrumentation points
  • Configuration file: Settings to enable/disable instrumentation
  • Usage instructions: How to run and collect data

Language-Specific Patterns

Python
python
# Original code
def calculate_sum(a, b):
    result = a + b
    return result

# Instrumented code
import logging
logging.basicConfig(level=logging.INFO)

def calculate_sum(a, b):
    # Function entry instrumentation
    logging.info(f"ENTER calculate_sum(a={a}, b={b})")

    result = a + b
    # Variable instrumentation
    logging.info(f"VAR result={result}")

    # Function exit instrumentation
    logging.info(f"EXIT calculate_sum() -> {result}")
    return result
Java
java
// Original code
public int calculateSum(int a, int b) {
    int result = a + b;
    return result;
}

// Instrumented code
public int calculateSum(int a, int b) {
    // Function entry instrumentation
    System.out.println("ENTER calculateSum(a=" + a + ", b=" + b + ")");

    int result = a + b;
    // Variable instrumentation
    System.out.println("VAR result=" + result);

    // Function exit instrumentation
    System.out.println("EXIT calculateSum() -> " + result);
    return result;
}
JavaScript
javascript
// Original code
function calculateSum(a, b) {
    const result = a + b;
    return result;
}

// Instrumented code
function calculateSum(a, b) {
    // Function entry instrumentation
    console.log(`ENTER calculateSum(a=${a}, b=${b})`);

    const result = a + b;
    // Variable instrumentation
    console.log(`VAR result=${result}`);

    // Function exit instrumentation
    console.log(`EXIT calculateSum() -> ${result}`);
    return result;
}
C/C++
c
// Original code
int calculate_sum(int a, int b) {
    int result = a + b;
    return result;
}

// Instrumented code
#include <stdio.h>

int calculate_sum(int a, int b) {
    // Function entry instrumentation
    printf("ENTER calculate_sum(a=%d, b=%d)\n", a, b);

    int result = a + b;
    // Variable instrumentation
    printf("VAR result=%d\n", result);

    // Function exit instrumentation
    printf("EXIT calculate_sum() -> %d\n", result);
    return result;
}

Branch Instrumentation Example

python
# Original code
def check_value(x):
    if x > 0:
        return "positive"
    else:
        return "non-positive"

# Instrumented code
def check_value(x):
    logging.info(f"ENTER check_value(x={x})")

    # Branch instrumentation
    if x > 0:
        logging.info("BRANCH if(x > 0) -> TRUE")
        result = "positive"
    else:
        logging.info("BRANCH if(x > 0) -> FALSE")
        result = "non-positive"

    logging.info(f"EXIT check_value() -> {result}")
    return result

Configuration-Based Instrumentation

Generate a configuration file to control instrumentation:

python
# instrumentation_config.py
INSTRUMENTATION_ENABLED = True
INSTRUMENT_FUNCTIONS = True
INSTRUMENT_BRANCHES = True
INSTRUMENT_VARIABLES = False
LOG_LEVEL = "INFO"
OUTPUT_FORMAT = "text"  # or "json", "csv"

# Instrumented code with configuration
import instrumentation_config as config

def calculate_sum(a, b):
    if config.INSTRUMENT_FUNCTIONS:
        logging.info(f"ENTER calculate_sum(a={a}, b={b})")

    result = a + b

    if config.INSTRUMENT_VARIABLES:
        logging.info(f"VAR result={result}")

    if config.INSTRUMENT_FUNCTIONS:
        logging.info(f"EXIT calculate_sum() -> {result}")

    return result

Output Format

Probe Description Document
markdown
## Instrumentation Report

**File**: calculator.py
**Instrumentation Date**: 2024-02-17
**Configuration**: Function-level + Branch-level

### Instrumented Functions

1. **calculate_sum(a, b)**
   - Entry probe: Line 3
   - Exit probe: Line 8
   - Captures: Parameters (a, b), return value

2. **check_value(x)**
   - Entry probe: Line 11
   - Branch probe: Line 14 (if x > 0)
   - Exit probe: Line 19
   - Captures: Parameter (x), branch decision, return value

### Instrumentation Statistics
- Total functions instrumented: 2
- Total branches instrumented: 1
- Total variables instrumented: 0
- Estimated overhead: <5%

### Usage
Run the instrumented code normally. Instrumentation output will be written to:
- Console (stdout)
- Log file: instrumentation.log (if configured)

Best Practices

  1. Minimize overhead: Only instrument what's necessary
  2. Use conditional compilation: Allow disabling instrumentation in production
  3. Handle exceptions: Ensure instrumentation doesn't crash the program
  4. Preserve semantics: Never modify program logic
  5. Thread-safe logging: Use thread-safe logging mechanisms
  6. Structured output: Use consistent format for easy parsing
  7. Timestamp everything: Include timestamps for temporal analysis

Advanced Features

Selective Instrumentation
python
# Only instrument specific functions
INSTRUMENTED_FUNCTIONS = ["calculate_sum", "process_data"]

def should_instrument(func_name):
    return func_name in INSTRUMENTED_FUNCTIONS

# Apply instrumentation conditionally
if should_instrument("calculate_sum"):
    # Add instrumentation
    pass
Performance Monitoring
python
import time

def calculate_sum(a, b):
    start_time = time.time()
    logging.info(f"ENTER calculate_sum(a={a}, b={b})")

    result = a + b

    elapsed = time.time() - start_time
    logging.info(f"EXIT calculate_sum() -> {result} [time={elapsed:.6f}s]")
    return result
JSON Output Format
python
import json
import time

def calculate_sum(a, b):
    entry_event = {
        "type": "function_entry",
        "function": "calculate_sum",
        "params": {"a": a, "b": b},
        "timestamp": time.time()
    }
    print(json.dumps(entry_event))

    result = a + b

    exit_event = {
        "type": "function_exit",
        "function": "calculate_sum",
        "return_value": result,
        "timestamp": time.time()
    }
    print(json.dumps(exit_event))

    return result

Constraints

  • Preserve semantics: Never change program behavior
  • Minimal overhead: Keep instrumentation lightweight
  • No side effects: Instrumentation shouldn't modify program state
  • Exception safety: Handle errors gracefully
  • Configurable: Allow enabling/disabling instrumentation

© ArabelaTso, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/code-instrumentation-generator of ArabelaTso/Skills-4-SE.

Open the folder on GitHubat commit 4f38503

Compare with similar skills

Code Instrumentation Generator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Instrumentation Generator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Instrumentation Generator this skillArabelaTso/Skills-4-SE253—~2.3kAutomated safety check: PassApache-2.0
MCP Debuggerdebugmcp/mcp-debugger171—~3.8kAutomated safety check: PassMIT
CodeQL Security Scantrailofbits/skills7.4k—~4.6kAutomated safety check: NotesCC-BY-SA-4.0
Fory Version Bumpapache/fory4.6k—~1.1kAutomated safety check: PassApache-2.0
Fory Performance Optimizationapache/fory4.6k—~2.2kAutomated safety check: PassApache-2.0
Constant-Time Analysistrailofbits/skills7.4k—~3.3kAutomated safety check: NotesCC-BY-SA-4.0

Similar skills

  • MCP Debugger

    debugmcp/mcp-debugger

    A skill your agent uses when investigating a bug, failing test, or unexpected runtime behavior and the mcp-debugger MCP server is available — drives real step-through debuggers (breakpoints, stack…

    171 GitHub stars~3.8k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • CodeQL Security Scan

    trailofbits/skills

    Official

    Scans a codebase for vulnerabilities with CodeQL's data flow and taint tracking in run-all or important-only modes, including data extensions for project-specific sources and sinks.

    7.4k GitHub stars~4.6k tokensUpdated 5 days ago
    SecurityAuto-check: notes
  • Bump Apache Fory release or post-release development versions across Java, Kotlin, Scala, Python, Rust, Go, C++, C, Dart, JavaScript, Swift, integration tests, examples, and source docs.

    4.6k GitHub stars~1.1k tokensUpdated today
    MobileAuto-check passed
  • Run profile-driven bottleneck optimization across Apache Fory implementations (Java, C++, Python/Cython, Go, Rust, Swift, C, JavaScript/TypeScript, Dart, Kotlin, Scala).

    4.6k GitHub stars~2.2k tokensUpdated today
    MobileAuto-check passed
  • Constant-Time Analysis

    trailofbits/skills

    Official

    Compiles cryptographic code and inspects the assembly or bytecode for variable-time instructions, then triages which flagged operations actually touch secrets.

    7.4k GitHub stars~3.3k tokensUpdated 5 days ago
    SecurityAuto-check: notes
  • Fory Release

    apache/fory

    Prepare an Apache Fory release candidate from a clean release branch, including the version bump, RC tag, JVM staging, ASF source artifacts, SVN upload, and vote email.

    4.6k GitHub stars~2.9k tokensUpdated today
    Auto-check passed

More from ArabelaTso/Skills-4-SE

All 151 skills in this repo
  • Framework Migration Assistant

    ArabelaTso/Skills-4-SE

    Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI).

    253 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Metamorphic Test Generator

    ArabelaTso/Skills-4-SE

    Generate test cases using metamorphic testing by applying transformations based on metamorphic properties.

    253 GitHub stars~798 tokensUpdated 1 mo ago
    Auto-check passed
  • Reproduction Trace Instrumenter

    ArabelaTso/Skills-4-SE

    Instruments programs to capture execution traces specifically for reproducing reported bugs, enabling consistent replay and diagnosis of failures.

    253 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Spring Mvc To Boot Migrator

    ArabelaTso/Skills-4-SE

    Automatically migrate Spring MVC applications to Spring Boot.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • State Snapshot Instrumenter

    ArabelaTso/Skills-4-SE

    Instrument programs (Python, C/C++, Java) to capture snapshots of key program states at runtime, including variables, memory, and call stacks.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Code Instrumentation Generator

What does Code Instrumentation Generator do?

Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics. Code Instrumentation Generator is an agent skill from ArabelaTso/Skills-4-SE. Automatically instruments source code to collect runtime information such as function calls, branch decisions, variable values, and execution traces while preserving original program semantics.

When should I use Code Instrumentation Generator?

Code Instrumentation Generator fits situations like: tracing to code for debugging; collect runtime execution data for analysis; monitor function calls and control flow; track variable values during execution.

How do I install Code Instrumentation Generator in Claude Code?

Run `npx skills add ArabelaTso/Skills-4-SE --skill code-instrumentation-generator -a claude-code`. Or copy the skill folder (skills/code-instrumentation-generator in ArabelaTso/Skills-4-SE) into .claude/skills/code-instrumentation-generator in your project. Claude Code loads it when a task matches its description.

How do I install Code Instrumentation Generator in Codex?

Run `npx skills add ArabelaTso/Skills-4-SE --skill code-instrumentation-generator -a codex`. Or copy the skill folder (skills/code-instrumentation-generator in ArabelaTso/Skills-4-SE) into .agents/skills/code-instrumentation-generator in your project. Codex loads it when a task matches its description.

Can I use Code Instrumentation Generator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ArabelaTso/Skills-4-SE --skill code-instrumentation-generator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-instrumentation-generator, .gemini/skills/code-instrumentation-generator, .github/skills/code-instrumentation-generator and .opencode/skills/code-instrumentation-generator in your project.

What does Code Instrumentation Generator need to run?

SKILL.md names no scripts, command-line tools or credentials: Code Instrumentation Generator is instructions for the agent only. Our summary lists: Python 3.

Does Code Instrumentation Generator access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Code Instrumentation Generator safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Code Instrumentation Generator use?

Code Instrumentation Generator is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Instrumentation Generator use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Code Instrumentation Generator?

Skills that share tags, products or a category with Code Instrumentation Generator: MCP Debugger (debugmcp/mcp-debugger, 171 stars), CodeQL Security Scan (trailofbits/skills, 7.4k stars), Fory Version Bump (apache/fory, 4.6k stars) and Fory Performance Optimization (apache/fory, 4.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Instrumentation Generator?

ArabelaTso (a GitHub user) maintains it in ArabelaTso/Skills-4-SE, which has 253 GitHub stars. The repository holds 151 skills in this directory. The repository was last updated on August 21, 2026.

Source: ArabelaTso/Skills-4-SE on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.