Skip to main content
skill CX Codex

system-profile — Claude Code skill: what it does, how to install

Profiles Python scripts, processes, memory, and GPUs using CLI utilities and automated code instrumentation. Helps isolate latency bottlenecks in ML pipelines.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a claude-code
Open on GitHub

What system-profile does

The skill investigates execution targets ranging from a raw script or PID to frameworks like vLLM. It decides which profiling strategy fits the supplied argument. Depending on the environment, it invokes external tools like cProfile, py-spy, torch.profiler, nsys, or inspects hardware interconnects via nvidia-smi nvlink.

External tools are sometimes not enough. When that happens, the skill instruments your code directly by wrapping functions with context managers, decorators, or CUDA event timers. Every inline change is marked with # [PROFILE]. It avoids instrumenting tight inner loops so the observer effect stays minimal. Generated logs, traces, and flamegraphs land in ./profile_output/.

The final report groups metrics across CPU overhead, memory redundancy, and interconnect bandwidth. It also generates a mandatory changelog table covering modified files and line numbers. The skill relies on your system having the requested profiling binaries preinstalled, so it fails if tools like perf or nsys are missing from your PATH.

What it helps with

  • trace GPU interconnect and NVLink throughput bottlenecks
  • profile end-to-end latency in vLLM serving and training loops
  • detect duplicate memory allocations between CPU and GPU
  • insert CUDA event timers into target scripts automatically

Example prompts for the agent

  • Profile train.py
  • Benchmark vllm serving and identify bottlenecks
  • Run system-profile on pid 1234 focusing on gpu and memory

How to install system-profile

1Skills CLI (Vercel)

npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a claude-code

2Manually: put the files in place

~/.claude/skills/system-profile/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/system-profile/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about system-profile

How to install system-profile in Claude Code?

Run npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill system-profile -a claude-code in your terminal. You can also place the skill file in ~/.claude/skills/system-profile/SKILL.md.

What does system-profile do?

It assesses target scripts, services, or hardware subsystems with external tools like cProfile and torch.profiler. It also injects non-destructive instrumentation code and generates a breakdown of bottlenecks.

How do I revert code modifications after profiling?

The skill outputs a mandatory changelog table listing every modified file and line. You can ask the agent to clean up and remove all instrumentation once the analysis is done.

Source text

SKILL.md · MIT
---
name: system-profile
description: "Profile a target (script, process, GPU, memory, interconnect) for performance analysis. Use when user says \"profile\", \"benchmark\", \"bottleneck\", or wants performance analysis."
argument-hint: '<target, e.g. "train.py", "gpu", "pid 1234", "vllm serving">'
---

# System Profile

Profile the specified target and summarize the results. Target: $ARGUMENTS

## Instructions

You are a profiling assistant. Based on the user's target, choose appropriate profiling strategies, **including writing instrumentation code when needed**, then run profiling, analyze results, and produce a summary.

### Step 1: Determine the profiling target

Parse `$ARGUMENTS` to understand what to profile. Examples:
- A Python script or module
- A running process (PID or service name)
- A specific function or code block
- An entire framework or system (e.g., "autogen", "vllm serving") — profile its end-to-end execution, identify bottlenecks across components
- "gpu" / "interconnect" / "memory" for focused profiling

If `$ARGUMENTS` is empty or unclear, ask the user.

### Step 2: Choose profiling methods

Select from external tools and/or code instrumentation as appropriate. Don't limit yourself to the examples below — use whatever makes sense for the target.

**External tools** (check availability first):
- CPU: `cProfile`, `py-spy`, `line_profiler`, `perf stat`, `/usr/bin/time -v`
- Memory: `tracemalloc`, `memory_profiler`, `memray`
- GPU: `nvidia-smi`, `nvidia-smi dmon`, `nvitop`, `torch.profiler`, `nsys`
- Interconnect: `nvidia-smi topo -m`, `nvidia-smi nvlink`, `NCCL_DEBUG=INFO`
- System: `strace -c`, `iostat`, `vmstat`

**Code instrumentation** — when external tools are insufficient, write and insert profiling code into the target. Typical scenarios:
- Timing specific code blocks (wall time vs CPU time)
- Measuring CPU-GPU or GPU-GPU transfer size, frequency, and bandwidth
- Tracking memory allocation across CPU and GPU to detect redundancy
- Wrapping NCCL collectives to measure latency and throughput
- Adding CUDA event timing around kernels

Design the instrumentation based on what you observe in the code — don't use a fixed template.

### Step 3: Key dimensions to investigate

Depending on the target, focus on some or all of these:

**CPU overhead**
- Context switching (voluntary / involuntary)
- CPU utilization: ratio of CPU time to wall time
- Per-function execution time hotspots

**Memory overhead**
- CPU and GPU memory usage (allocated vs reserved vs peak)
- Redundant replication: same data living on both CPU and GPU
- Per-device allocation balance in multi-GPU setups

**Interconnect & communication**
- CPU-GPU transfer: frequency, per-transfer size, total volume, bandwidth achieved
- GPU-GPU transfer: P2P bandwidth, NVLink vs PCIe topology impact
- NCCL collectives: operation type, message size distribution, latency
- Communication-to-computation ratio

**GPU compute**
- SM utilization, kernel launch overhead
- Memory bandwidth utilization vs peak

### Step 4: Instrumentation guidelines

When inserting code into the target:
1. Read and understand the target code first
2. Prefer wrapping (decorator, context manager, standalone runner) over inline edits
3. If inline edits are necessary, mark them clearly (e.g., `# [PROFILE]` comments)
4. Minimize observer effect — don't instrument tight inner loops; sample instead
5. Collect results into a structured log, don't scatter print statements

### Step 5: Run profiling

1. Check available tools and hardware topology
2. Run the chosen methods, capture all output
3. Save artifacts (flamegraphs, traces, logs) to `./profile_output/`

### Step 6: Produce the report

**Part A — Profiling results** (structured tables by dimension, as applicable):
- CPU overhead table
- Memory overhead table (with redundancy column)
- Interconnect table (transfer type / frequency / size / latency / bandwidth)
- Hotspots / bottleneck identification
- Actionable recommendations ranked by expected impact

**Part B — Instrumentation changelog** (MANDATORY):
List every file that was modified or created for profiling purposes:

| File | Change type | What was added/modified | Line(s) |
|------|-------------|------------------------|---------|
| ... | modified | ... | ... |
| ... | created | ... | — |

This allows the user to review and revert all instrumentation changes.
Offer to clean up (remove all instrumentation) when the user is done.

© wanshuiyin · MIT · wanshuiyin/Auto-claude-code-research-in-sleep

Similar skills

Everything for AI and ML →

From the same set78

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor