|
| 1 | +--- |
| 2 | +name: async-profiler |
| 3 | +description: > |
| 4 | + Install, run, and analyze async-profiler for Java — low-overhead sampling |
| 5 | + profiler producing flamegraphs, JFR recordings, and allocation profiles. |
| 6 | + Use for: "install async-profiler", "set up Java profiling", "Failed to open |
| 7 | + perf_events", "what JVM flags for profiling", "capture a flamegraph", |
| 8 | + "profile CPU/memory/allocations/lock contention", "profile my Spring Boot |
| 9 | + app", "generate a JFR recording", "heap keeps growing", "what does this |
| 10 | + flamegraph mean", "how do I read a flamegraph", "interpret profiling results", |
| 11 | + "open a .jfr file", "what's causing my CPU hotspot", "wide frame in my |
| 12 | + profile", "I see a lot of GC / Hibernate / park in my profile". |
| 13 | + Use this skill any time a Java developer mentions profiling, flamegraphs, |
| 14 | + async-profiler, JFR, or wants to understand JVM performance. |
| 15 | +compatibility: Requires Python 3.7+ for the analyze_collapsed.py script. |
| 16 | +--- |
| 17 | + |
| 18 | +# async-profiler |
| 19 | + |
| 20 | +async-profiler is a production-safe, low-overhead sampling profiler for Java |
| 21 | +that avoids the safepoint bias of standard JVM profilers. It can capture CPU |
| 22 | +time, heap allocations, wall-clock time, and lock contention, and produce |
| 23 | +interactive flamegraphs, JFR recordings, and collapsed stack traces. |
| 24 | + |
| 25 | +## Installing this skill |
| 26 | + |
| 27 | +### IntelliJ IDEA (Junie or GitHub Copilot) |
| 28 | + |
| 29 | +Skills live in a `.claude/skills/`, `.agents/skills/`, or `.github/skills/` |
| 30 | +directory, either in your project repo or in your home directory. |
| 31 | + |
| 32 | +**Project-level — recommended for teams** (commit so everyone gets it): |
| 33 | +```bash |
| 34 | +# From your project root: |
| 35 | +mkdir -p .github/skills |
| 36 | +cd .github/skills |
| 37 | +unzip /path/to/async-profiler.skill |
| 38 | +git add async-profiler |
| 39 | +git commit -m "Add async-profiler skill" |
| 40 | +``` |
| 41 | + |
| 42 | +**Global — personal use across all projects:** |
| 43 | +```bash |
| 44 | +mkdir -p ~/.claude/skills |
| 45 | +cd ~/.claude/skills |
| 46 | +unzip /path/to/async-profiler.skill |
| 47 | +``` |
| 48 | + |
| 49 | +> **Note for GitHub Copilot users:** There is a known issue where the Copilot |
| 50 | +> JetBrains plugin does not reliably pick up skills from the global `~/.copilot/skills` |
| 51 | +> directory. Use the project-level `.github/skills/` location to be safe. |
| 52 | +
|
| 53 | +Alternatively, install the **Agent Skills Manager** plugin from the JetBrains |
| 54 | +Marketplace (*Settings → Plugins → Marketplace* → "Agent Skills Manager") for |
| 55 | +a UI that installs skills without unzipping manually. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Using this skill in IntelliJ IDEA |
| 60 | + |
| 61 | +### With Junie (JetBrains AI) |
| 62 | + |
| 63 | +Junie is JetBrains' native coding agent, available in the AI Chat panel. |
| 64 | + |
| 65 | +1. Open the AI Chat panel (*View → Tool Windows → AI Chat*, or the chat icon |
| 66 | + in the right toolbar) |
| 67 | +2. In the agent dropdown at the top of the chat, select **Junie** |
| 68 | +3. Choose a mode: |
| 69 | + - **Code mode** — Junie can run terminal commands, write files, and execute |
| 70 | + the profiling scripts directly. Use this when you want it to actually run |
| 71 | + `scripts/install.sh` or `scripts/run_profile.sh` for you. |
| 72 | + - **Ask mode** — read-only; Junie analyzes and explains but won't touch |
| 73 | + files. Use this when you want help interpreting a flamegraph or JFR file. |
| 74 | +4. Just ask naturally — Junie loads the skill automatically when your question |
| 75 | + matches the description. You don't need to invoke it by name. |
| 76 | + |
| 77 | +Example prompts that will trigger this skill in Junie: |
| 78 | +- *"My Spring Boot app is using too much CPU. Help me capture a flamegraph."* |
| 79 | +- *"I have this JFR file — open it and tell me what's slow."* |
| 80 | +- *"Install async-profiler on this machine and set up the JVM flags."* |
| 81 | + |
| 82 | +In Code mode, Junie will run `scripts/install.sh`, execute `scripts/run_profile.sh` |
| 83 | +with the right flags, and then walk you through the results — all without |
| 84 | +leaving IntelliJ. |
| 85 | + |
| 86 | +### With GitHub Copilot in IntelliJ |
| 87 | + |
| 88 | +1. Enable agent mode: *Settings → GitHub Copilot → Chat → Agent* → turn on |
| 89 | + **Agent mode** and **Agent Skills** |
| 90 | +2. Open the Copilot Chat panel and make sure the mode selector shows **Agent** |
| 91 | +3. Ask naturally — Copilot loads the skill when your prompt matches |
| 92 | + |
| 93 | +Example prompts: |
| 94 | +- *"Profile my running Java app and show me where the CPU is going."* |
| 95 | +- *"Analyze this collapsed stack file and tell me what's allocating the most."* |
| 96 | + |
| 97 | +GitHub Copilot's agent mode can also run the bundled scripts on your behalf — |
| 98 | +it will propose the terminal command and ask for confirmation before executing. |
| 99 | + |
| 100 | +### GitHub Copilot CLI |
| 101 | + |
| 102 | +```bash |
| 103 | +mkdir -p ~/.copilot/skills |
| 104 | +cd ~/.copilot/skills |
| 105 | +unzip /path/to/async-profiler.skill |
| 106 | +``` |
| 107 | + |
| 108 | +Run `/skills list` to confirm it loaded. Then just ask naturally in the terminal. |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## Bundled scripts |
| 113 | + |
| 114 | +This skill includes four ready-to-run scripts in `scripts/`: |
| 115 | + |
| 116 | +| Script | What it does | |
| 117 | +|---|---| |
| 118 | +| `scripts/install.sh` | Auto-detects platform, downloads the right binary, verifies install | |
| 119 | +| `scripts/run_profile.sh` | Wraps `asprof` with defaults, timestamps output, prints opening instructions | |
| 120 | +| `scripts/collect.sh` | Agent-friendly background collection: start all-event profiling, do other work, then stop and get all flamegraphs | |
| 121 | +| `scripts/analyze_collapsed.py` | Ranked self-time / inclusive-time table for `.collapsed` files, with filters | |
| 122 | + |
| 123 | +Always offer to run these scripts on the user's behalf when relevant. |
| 124 | + |
| 125 | +## How to use this skill |
| 126 | + |
| 127 | +This skill has three sub-guides. Read the one that matches what the user needs: |
| 128 | + |
| 129 | +| Situation | Read | |
| 130 | +|---|---| |
| 131 | +| User needs to install or configure async-profiler, or is hitting setup errors | `setup/SKILL.md` | |
| 132 | +| User wants to run a profiling session (capture flamegraph, JFR, etc.) | `profile/SKILL.md` | |
| 133 | +| User has profiling output and wants to understand or interpret it | `analyze/SKILL.md` | |
| 134 | + |
| 135 | +**When the conversation spans multiple phases** (e.g., the user just ran a |
| 136 | +profile and now wants to understand the output), read whichever sub-guide is |
| 137 | +most relevant to the current question. If the user needs both setup *and* |
| 138 | +profiling guidance in one message, read `setup/SKILL.md` first and summarize |
| 139 | +the setup steps before moving to `profile/SKILL.md`. |
| 140 | + |
| 141 | +Read the relevant sub-guide now before responding. |
0 commit comments