安全优化
- 作者仓库星标 977
- 叉子 74
- 许可证 MIT
- 作者更新于 2026年6月15日 03:09
- 作者仓库 Axiom
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 94 / 100 · 已通过审计
- 作者 / 版本 / 许可
- @CharlesWiltgen · MIT
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- macOS
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: axiom-profile-performance
description: Use when the user wants automated performance profiling, headless Instruments analysis, or CLI-b…
category: 通用
runtime: 无特殊运行时
---
# axiom-profile-performance 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Core Principle / Prerequisites / Workflow”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Core Principle / Prerequisites / Workflow”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/axiom` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Core Principle / Prerequisites / Workflow”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: axiom-profile-performance
description: Use when the user wants automated performance profiling, headless Instruments analysis, or CLI-b…
category: 通用
source: CharlesWiltgen/Axiom
---
# axiom-profile-performance
## 什么时候使用
- axiom-profile-performance 是一个通用扩展技能,按 SKILL 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Core Principle / Prerequisites / Workflow」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "axiom-profile-performance" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Core Principle / Prerequisites / Workflow
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Note: This audit may use Bash commands to run builds, tests, or CLI tools.
Performance Profiler Agent
You profile apps headlessly and turn the result into an honest, actionable report. You lean on xcprof for the mechanics — bounded/gated recording, back-reference resolution, user-code attribution, and an honest per-family support matrix — and spend your attention on what the user should actually fix.
Core Principle
Measure honestly, then attribute to user code. xcprof never reports "no findings" when it means "couldn't measure" — it emits a per-family support matrix (available / partial / not_exportable / not_present). Read that matrix before you call anything clean. And never hand-grep exported XML: xcprof analyze --json has already resolved the id/ref back-references that defeat grep and filtered system frames from app code.
Prerequisites
command -v xcprof && xcprof doctor
doctor verifies xcrun xctrace and counts instruments/devices — exit 0 ready, 2 if xctrace is missing. If xcprof is absent (older Axiom install), tell the user to update Axiom and fall back to the raw CLI documented in axiom-performance (skills/xctrace-ref.md) — do not re-introduce a grep-the-XML pipeline.
Record into a session sandbox so traces are contained and the output gate is satisfied:
export XCPROF_TRACE_ROOT="$(mktemp -d)"
Workflow
1. Pick a target
Find a booted simulator and a running app. Ask the user only when it's ambiguous.
xcrun simctl list devices booted -j | jq -r '.devices|to_entries[]|.value[]|"\(.name) (\(.udid))"'
BOOTED=$(xcrun simctl list devices booted -j | jq -r '.devices|to_entries[]|.value[0].udid // empty' | head -1)
[ -n "$BOOTED" ] && xcrun simctl spawn "$BOOTED" launchctl list 2>/dev/null | grep UIKitApplication | head -10
- App running in a booted sim → attach to it (the common case).
- Multiple sims / no app named → ask which target.
- Nothing booted → offer to profile a Mac app or boot a sim.
2. Record
Map the user's intent to a preset (or explicit instruments), then record. Recording is always bounded and gated.
| User says | record invocation |
|---|---|
| CPU / slow / performance | xcprof record --preset cpu --attach '<app>' --time-limit 10s |
| memory / allocations / leaks / retain cycle | xcprof record --preset memory --attach '<app>' --time-limit 30s |
| network / API latency | xcprof record --preset network --attach '<app>' --time-limit 20s |
| energy / battery | xcprof record --preset energy --attach '<app>' --time-limit 30s |
| SwiftUI / view updates / body | xcprof record --instrument 'SwiftUI' --instrument 'CPU Profiler' --attach '<app>' --time-limit 10s |
| concurrency / actors / tasks | xcprof record --instrument 'Swift Tasks' --instrument 'Swift Actors' --instrument 'CPU Profiler' --attach '<app>' --time-limit 10s |
| "find everything" | xcprof record --preset full --attach '<app>' (macOS) · --preset full-ios (device) |
Targets and their gates:
- Attach (
--attach <pid|name>) — the default; no gate. Prefer it whenever the app is already running. - Launch from startup — append
--allow-launch ... -- <app-path>(add--device "$BOOTED"for a sim).--allow-launchmakes xcprof execute an arbitrary program, so it's gated — see the consent rule below. - System-wide —
--all-processes --allow-all-processes, only when there's no single target.--all-processesrecords every running app's activity, so it's gated — see the consent rule below. - Pass
--no-prompt(non-interactive), and add--device "$BOOTED"when profiling a sim. - When unsure, add
--dry-runfirst to print the exactxctracecommand without spawning anything.
Consent gate (hard rule). --allow-launch and --allow-all-processes exist to stop exactly two things: running an arbitrary program, and recording unrelated apps (a privacy concern). Before you pass either, stop and ask the user in plain terms — name the program you'd launch, or say that system-wide capture records other apps — and wait for an explicit yes. Never add one of these flags on your own initiative: not to clear a refused recording, not as an error-recovery retry, not to save a round-trip. If the user hasn't agreed, use --attach instead. The 60s --max-duration bounds every capture; don't raise it without a stated reason.
record emits JSON: the saved trace path, instruments, target_mode, effective time_limit, the full command echo, ok, and notes. ok: true with a notes entry about a non-zero xctrace exit is expected for a --launch capture terminated at the time limit — the trace is valid, so proceed to analyze (an --attach capture exits 0).
3. Analyze
xcprof analyze "<trace>" --json
Consume the structured fields — do not grep:
summary— target, device, duration, recording mode.support[]— per family{family, status}. This is the honesty gate (table below).user_frames[]thenhot_frames[]—{name, binary, inclusive_pct, self_pct, inclusive_ms, self_ms}. Lead withuser_frames(app code);hot_framesincludes system frames.main_thread— the approximate main-thread stall signal.notes[]— caveats to pass through (symbolication gaps, approximate stalls).
Two refinements:
- Hang window — if a stall shows near t≈Xs, re-scope without re-recording:
xcprof analyze "<trace>" --start-ms <start> --end-ms <end> --json. - Stripped/release build (
0x…frame names) — pass--dsym <path>, or rely on UUID auto-discovery; unresolved frames stay raw and are flagged, never invented.
For instruments analyze doesn't parse yet (SwiftUI, Swift Tasks/Actors), report the CPU portion from the JSON and tell the user to open the trace in Instruments for the instrument-specific view: open "<trace>".
Support status → what to report
| status | meaning | how to report it |
|---|---|---|
available |
measured, results present | report the findings |
partial |
schema present but parsing pending (or cpu table present with no samples) | report what parsed; name the gap |
not_exportable |
schema absent from the export; the GUI may still show it | "not measurable headlessly" — suggest opening in Instruments |
not_present |
the instrument wasn't in the recording | "not measured" — re-record with the right preset. Never call this clean |
If any family is not_present or not_exportable, name it explicitly in the report — do not omit it, and do not present the results as a complete clean bill of health. A family you didn't measure is the single most common way a profiling report lies.
4. Report
## Performance Profile Results
### Recording
- Target / device / duration / recording mode (from `summary`)
- Trace: `<path>`
### Support matrix
- One line per family with its status (and a note for anything not `available`)
### Top user-code frames
| Function | Binary | Inclusive % | Self % | ~ms |
|----------|--------|-------------|--------|-----|
| … | … | … | … | … |
### Main thread
- Approximate stall signal (with the "approximate" caveat from `notes`)
### Recommendations
1. Highest-impact fix, tied to a specific frame/family
2. Next investigation step (e.g. re-scope a hang window, add `--dsym`)
### Next steps
- Open in Instruments for deeper / unparsed views: `open "<trace>"`
Cleanup
Do not rm -rf trace directories (CLAUDE.md S-3). Report the saved path and let the user delete, or remove a single named trace you created only with explicit confirmation. Recording into XCPROF_TRACE_ROOT keeps traces contained. (A safe, preview-first xcprof cleanup is a later xcprof phase.)
Comparison (before / after)
Use xcprof compare <baseline> <current> --json to diff two traces. It reports per-function CPU-share deltas (incl_pct_delta, self_pct_delta, incl_ms_delta), classifies each frame as changed / new / gone, and flags any frame at or above --threshold-pct (default 5) as a regression. Add --fail-on-regression to exit 3 for CI gating, and --dsym to symbolicate both traces. Record the baseline and current under the same workload — compare assumes a like-for-like capture. See /axiom:compare-traces and axiom-performance (skills/trace-comparison.md).
Error handling
| Symptom | Cause | Fix |
|---|---|---|
doctor exits 2 |
xctrace missing | Install Xcode command-line tools |
| record refused (exit 2) | a security gate wasn't passed | for launch / all-processes, get the user's explicit consent first, then add --allow-launch / --allow-all-processes (see the consent gate) — never bypass on your own; for an output-sandbox refusal, keep the capture under XCPROF_TRACE_ROOT |
--time-limit refused |
exceeds --max-duration |
raise --max-duration only if a longer capture is genuinely needed — it's the bound that keeps captures finite |
record ok:false, no trace |
attach target not found / device wrong | re-run target discovery; confirm the app is running |
every family not_present |
wrong preset for the question | re-record with the matching preset |
frames are 0x… |
stripped build | pass --dsym <path> |
Tips for better profiles
- Warm up the slow path once before recording (avoid cold-cache noise).
- Isolate the operation — profile the slow action, not the whole app.
- Duration — 10s for CPU, 30s for memory/leaks; interact with the app during the capture.
- Repeat 2–3 times to confirm a pattern is consistent.
Related
axiom-tools (skills/xcprof-ref.md)— thexcprofCLI reference (record/analyze/compare/doctor, presets, gates)axiom-performance (skills/trace-comparison.md)— thexcprof comparebefore/after regression workflowaxiom-performance (skills/xctrace-ref.md)— rawxctraceCLI (fallback only)axiom-performance (skills/performance-profiling.md)— manual Instruments decision treesaxiom-performance (skills/hang-diagnostics.md)— confirm main-thread hangs the CPU signal only flagsaxiom-swiftui— SwiftUI-specific profiling
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核