profiling

profiling is a skill for Claude Code, Codex from chaterm/terminal-skills. It costs 5 tokens per session (1,298 once invoked), scanned A, original, Apache-2.0.

A set of Linux instructions for finding which parts of a running program or system use CPU time, memory, or other resources.

In plain words
What is it for?
Use it to record CPU activity, inspect performance reports, count events such as cache misses, trace system calls with strace, and create flame graphs.
Why use it?
It helps explain why a program or server is slow by showing where time is spent and which system calls it makes. A flame graph is a visual chart of those collected call stacks.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is perf script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl > out.svg.

Good fit Use it to record CPU activity, inspect performance reports, count events such…

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/chaterm/terminal-skills
agentmods
npx agentmods add skills/chaterm/terminal-skills/profiling

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 profiling

README.md
[![agentmods](https://agentmods.dev/badge/skills/chaterm/terminal-skills/profiling.svg)](https://agentmods.dev/skills/chaterm/terminal-skills/profiling)
Your own site
<a href="https://agentmods.dev/skills/chaterm/terminal-skills/profiling"><img src="https://agentmods.dev/badge/skills/chaterm/terminal-skills/profiling.svg" alt="Measured on agentmods" height="20"></a>
Per session 5 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,298 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.
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.00005 $0.01298
Opus 5 $0.00003 $0.00649
Sonnet 5 $0.00001 $0.00260
Haiku 4.5 $0.00001 $0.00130

Measured 7d ago against content hash ce558186b49e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

profiling 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 7d ago.

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.

performance/profiling/SKILL.md · 255 lines

How it starts

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

性能分析

概述

CPU/内存分析、火焰图、追踪技能。

perf 工具

基础命令

# 安装
apt install linux-tools-common linux-tools-$(uname -r)

# CPU 采样
perf record -g -p PID
perf record -g -a -- sleep 30

# 查看报告
perf report
perf report --stdio

# 实时统计
perf top
perf top -p PID

# 统计事件
perf stat command
perf stat -p PID sleep 10

常用事件

# CPU 周期
perf record -e cycles -p PID

# 缓存未命中
perf record -e cache-misses -p PID

# 上下文切换
perf record -e context-switches -p PID

# 列出可用事件
perf list

火焰图

# 采集数据
perf record -F 99 -g -p PID -- sleep 30

# 生成火焰图
perf script | stackcollapse-perf.pl | flamegraph.pl > flamegraph.svg

# 或使用 FlameGraph 工具
git clone https://github.com/brendangregg/FlameGraph
perf script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl > out.svg

strace 追踪

基础用法

# 追踪进程
strace -p PID

# 追踪命令
strace command

# 统计系统调用
strace -c command
strace -c -p PID

# 追踪特定调用
strace -e open,read,write command
strace -e trace=network command
strace -e trace=file command

高级选项

# 显示时间戳
strace -t command
strace -tt command      # 微秒

# 显示耗时
strace -T command

# 跟踪子进程
strace -f command

# 输出到文件
strace -o trace.log command

ltrace 库调用

# 追踪库调用
ltrace command
ltrace -p PID

# 统计
ltrace -c command

# 特定库
ltrace -l libc.so.6 command

内存分析

valgrind

# 内存泄漏检测
valgrind --leak-check=full ./program

# 内存错误
valgrind --tool=memcheck ./program

# 缓存分析
valgrind --tool=cachegrind ./program

# 调用图
valgrind --tool=callgrind ./program
kcachegrind callgrind.out.*

pmap

# 查看进程内存映射
pmap PID
pmap -x PID

# 详细信息
pmap -XX PID

smem

# 内存使用统计
smem
smem -u          # 按用户
smem -p          # 按进程
smem -k          # 人类可读

系统分析

vmstat

# 每秒刷新
vmstat 1

# 输出说明
# r: 运行队列
# b: 阻塞进程
# si/so: 交换
# bi/bo: 块 IO
# us/sy/id/wa: CPU 使用

iostat

# 磁盘统计
iostat -x 1

# 输出说明
# %util: 设备利用率
# await: 平均等待时间
# r/s, w/s: 读写 IOPS

pidstat

# CPU 使用
pidstat -u 1

# 内存使用
pidstat -r 1

# IO 使用
pidstat -d 1

# 特定进程
pidstat -p PID 1

Read the full file on GitHub · 255 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. 7d ago First seen · 255 lines · 5 tokens per session scan A ce558186b49e

Subscribe to this mod's changes

profiling is a skill published in the GitHub repository chaterm/terminal-skills (58 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 5 tokens to every session and 1,298 once invoked, about $0.0000 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.