Skip to content
Back to skills

Profile

ASecurity

Use when asked to profile Flemma performance, compare keystroke latency between branches, or run the profiling harness. Trigger on "profile", "perf", "benchmark", "keystroke latency", or "InsertCharPre".

  • 57 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 27, 2026
data-aibashgitperformance

Security analysis

A93/100
  • highPerforms destructive filesystem operations

Pro scans all 5 files and shows the line behind each finding

Scanned September 6, 2026

npx -y skills add Flemma-Dev/flemma.nvim --skill profile --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Profile?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Profile
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/flemma-dev-profile/badge)](https://www.skillsdirectory.com/skills/flemma-dev-profile)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: profile
description: Use when asked to profile Flemma performance, compare keystroke latency between branches, or run the profiling harness. Trigger on "profile", "perf", "benchmark", "keystroke latency", or "InsertCharPre".
---

# Profile: main vs HEAD

Compare per-keystroke performance between `main` (latest stable) and the current working tree using `contrib/profile/run.sh`.

## Prerequisites

- **tmux session must be active** — the harness drives edits via `tmux send-keys`
- The tmux socket is typically outside the sandbox allowlist — commands that touch tmux need sandbox bypass
- Each run takes ~40 seconds (typing simulation + data collection)

## Procedure

Run these steps sequentially. All `bash` commands that touch tmux need `dangerouslyDisableSandbox: true`.

### 1. Verify tmux

```bash
tmux has-session 2>&1 && echo "ready" || echo "no tmux"
```

If no tmux, stop and tell the user to start a tmux session first.

### 2. Ensure the fixture exists

```bash
ls contrib/profile/fixture.chat 2>/dev/null && echo "exists" || echo "missing"
```

If missing, generate it:

```bash
nvim --headless --noplugin -u NONE --cmd 'set rtp^=.' -l contrib/profile/generate-fixture.lua
```

### 3. Create a worktree for `main`

```bash
git worktree remove --force $TMPDIR/flemma-profile-main 2>&1; git worktree add $TMPDIR/flemma-profile-main main 2>&1
```

### 4. Replace harness in worktree with HEAD's copy

**Always purge and replace** — even if `main` already has `contrib/profile/`, its harness may be outdated. The HEAD version of the harness is the single source of truth for instrumentation. Using `main`'s own harness would mean each branch is measured with different instrumentation code, invalidating the comparison.

```bash
rm -rf $TMPDIR/flemma-profile-main/contrib/profile
mkdir -p $TMPDIR/flemma-profile-main/contrib/profile
cp contrib/profile/{run.sh,init.lua,instrument.lua,generate-fixture.lua,GUIDE.md} \
   $TMPDIR/flemma-profile-main/contrib/profile/
cp contrib/profile/fixture.chat $TMPDIR/flemma-profile-main/contrib/profile/
```

Both runs must use **identical instrumentation** (same `instrument.lua`, same `run.sh`) and **identical input** (same `fixture.chat`) for a fair comparison. Only the Flemma runtime code differs.

### 5. Run profiling on `main`

```bash
cd $TMPDIR/flemma-profile-main && bash contrib/profile/run.sh 2>&1
```

Timeout: 300000ms. Capture the full output.

### 6. Run profiling on HEAD

Run from the primary working directory (the repo root where the conversation started):

```bash
bash contrib/profile/run.sh 2>&1
```

Timeout: 300000ms. Capture the full output.

### 7. Clean up

```bash
git worktree remove --force $TMPDIR/flemma-profile-main 2>&1
```

### 8. Present results

Extract `InsertCharPre` rows from both runs and build a comparison table:

```
| Branch    | Avg ms/key | Max ms | Baseline (md) |
|-----------|-----------|--------|---------------|
| main      | X.XXX     | XX.XX  | X.XXX         |
| HEAD      | X.XXX     | XX.XX  | X.XXX         |
```

Below the headline table, include:

- **Function timings** side-by-side (parser, bridge.update_ui, folding — from the `chat-flemma` variant of each run)
- **Parser cache hit rate** for each (`parse_lines` calls / `get_parsed_document` calls`)
- **Notable differences** in the jit.p profiles or autocmd event distribution
- A brief interpretation: where time moved, what improved/regressed, and whether the delta is within noise

If the user passed arguments to `/profile`, treat them as a custom input file path for the harness (both runs use the same file).

## Interpreting Results

See `contrib/profile/GUIDE.md` for the full methodology — event timing semantics, function timing interpretation, jit.p reading, and isolation techniques. That document is the reference for diagnosing specific bottlenecks once the comparison identifies a regression.

Files in this skill

  • SKILL.md19.4 KB
  • generate-fixture.lua15.7 KB
  • init.lua2.2 KB
  • instrument.lua6.9 KB
  • run.sh9.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.