Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions .claude/skills/memray/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---

name: memray
description: Profile the memory usage of a Python script using memray and visualize a temporal flamegraph in the browser. Use when the user wants to investigate memory consumption, find leaks, or understand allocation patterns.
compatibility: Requires the pixi profiling environment (pixi run -e profiling). Supports Linux and macOS.
allowed-tools: Bash(pixi run -e profiling memray-run:_) Bash(pixi run -e profiling memray-flame:_) Bash(open:_) Bash(xdg-open:_) Bash(python -m webbrowser:*)
allowed-tools: Bash(pixi run -e profiling memray-run:*) Bash(pixi run -e profiling memray-flame:*) Bash(open:*) Bash(xdg-open:*) Bash(python -m webbrowser:*)
---

## Steps
Expand All @@ -12,24 +11,24 @@ allowed-tools: Bash(pixi run -e profiling memray-run:_) Bash(pixi run -e profili

2. Run the script under memray:

```bash
pixi run -e profiling memray-run script.py
```
```bash
pixi run -e profiling memray-run script.py
```

This produces a binary file named `memray-script.py.<pid>.bin` in the current directory.
This produces a binary file named `memray-script.py.<pid>.bin` in the current directory.

3. Generate the flamegraph HTML report from the `.bin` file:

```bash
pixi run -e profiling memray-flame memray-script.py.<pid>.bin
```
```bash
pixi run -e profiling memray-flame memray-script.py.<pid>.bin
```

Replace `<pid>` with the actual PID shown in the filename. This writes `memray-flamegraph-script.py.<pid>.html`.
Replace `<pid>` with the actual PID shown in the filename. This writes `memray-flamegraph-script.py.<pid>.html`.

4. Open the report in the browser:
- macOS: `open memray-flamegraph-script.py.<pid>.html`
- Linux: `xdg-open memray-flamegraph-script.py.<pid>.html`
- Either: `python -m webbrowser memray-flamegraph-script.py.<pid>.html`
- macOS: `open memray-flamegraph-script.py.<pid>.html`
- Linux: `xdg-open memray-flamegraph-script.py.<pid>.html`
- Either: `python -m webbrowser memray-flamegraph-script.py.<pid>.html`

## Notes

Expand Down
15 changes: 7 additions & 8 deletions .claude/skills/profimp/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---

name: profimp
description: Profile Python import time using profimp and open a waterfall HTML report. Use when investigating slow startup or wanting to identify which imports are most expensive.
compatibility: Requires profimp (available as a pixi dependency). macOS or Linux.
allowed-tools: Bash(profimp:_) Bash(open:_) Bash(xdg-open:_) Bash(python -m webbrowser:_)
allowed-tools: Bash(profimp:*) Bash(open:*) Bash(xdg-open:*) Bash(python -m webbrowser:*)
---

## Steps

1. Ask what to profile. Suggest common patterns for this repo:
- `import spatialdata`
- `from spatialdata import SpatialData`
- `from spatialdata_io import xenium`
- `import spatialdata`
- `from spatialdata import SpatialData`
- `from spatialdata_io import xenium`

2. Run:

Expand All @@ -20,9 +19,9 @@ profimp --html "<import_stmt>" > /tmp/profimp.html
```

3. Open the report:
- macOS: `open /tmp/profimp.html`
- Linux: `xdg-open /tmp/profimp.html`
- Either: `python -m webbrowser /tmp/profimp.html`
- macOS: `open /tmp/profimp.html`
- Linux: `xdg-open /tmp/profimp.html`
- Either: `python -m webbrowser /tmp/profimp.html`

## Notes

Expand Down
41 changes: 19 additions & 22 deletions .claude/skills/pyspy/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---

name: pyspy
description: Profile the execution time of a Python script using py-spy and visualize the result with speedscope. Use when the user wants to benchmark performance, find slow code paths, or profile CPU time.
compatibility: Requires the pixi profiling environment (pixi run -e profiling). Speedscope must be installed separately (npm install -g speedscope). sudo is required on macOS.
allowed-tools: Bash(pixi run -e profiling pyspy:_) Bash(pixi run -e profiling speedscope:_) Bash(sudo pixi run -e profiling pyspy:*)
allowed-tools: Bash(pixi run -e profiling pyspy:*) Bash(pixi run -e profiling speedscope:*) Bash(sudo pixi run -e profiling pyspy:*)
---

## Steps
Expand All @@ -12,33 +11,31 @@ allowed-tools: Bash(pixi run -e profiling pyspy:_) Bash(pixi run -e profiling sp

2. Run py-spy to record the profile. The output is always written to `profile.speedscope.json` in the current directory.

**Linux** (no sudo needed):
**Linux** (no sudo needed):

```bash
pixi run -e profiling pyspy script.py
```
```bash
pixi run -e profiling pyspy script.py
```

**macOS** (sudo required — py-spy needs to attach to the process):
**macOS** (sudo required — py-spy needs to attach to the process):

```bash
sudo pixi run -e profiling pyspy script.py
```
```bash
sudo pixi run -e profiling pyspy script.py
```

If sudo fails to find the pixi environment, use absolute paths:
If sudo fails to find the pixi environment, use absolute paths:

```bash
sudo /path/to/.pixi/envs/profiling/bin/py-spy record --gil \
-o profile.speedscope.json --format speedscope \
-- /path/to/.pixi/envs/profiling/bin/python script.py
```
```bash
sudo /path/to/.pixi/envs/profiling/bin/py-spy record --gil \
-o profile.speedscope.json --format speedscope \
-- /path/to/.pixi/envs/profiling/bin/python script.py
```

3. Open the result in speedscope:

```bash
pixi run -e profiling speedscope
```

This opens `profile.speedscope.json` in the browser via the local speedscope CLI.
```bash
pixi run -e profiling speedscope
```
This opens `profile.speedscope.json` in the browser via the local speedscope CLI.

## Notes

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
- id: biome-format
exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
groups: [format]
# further file exclusions and other options are configured in biome.jsonc
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.30.3
hooks:
Expand Down
9 changes: 8 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.6.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.6.4/schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"formatter": { "useEditorconfig": true },
"overrides": [
Expand All @@ -19,4 +19,11 @@
"json": { "parser": { "allowComments": true } },
},
],
"files": {
"includes": [
"**",
// Claude Code skills and settings, not project source.
"!.claude",
],
},
}
Loading