workoutgen: Apple Watch custom workout (.workout) file generator
Create Apple Watch custom workouts from a few lines of text: warmup, intervals, repeats, recoveries and cooldown, with pace, heart-rate zone, cadence and power alerts. workoutgen writes the .workout file that the iPhone Workout app imports and syncs to your Watch. No Swift, no Xcode, no iOS app. It also decodes any .workout file back to editable text.
It's one Python file using only the standard library. Apple doesn't document the .workout format (a binary protobuf of a WorkoutKit WorkoutPlan), so it was reverse-engineered from real exports. Every supported feature is checked byte-for-byte against one (fixtures/); the full field map is in FORMAT.md. AI agents can use it too: see For AI agents.
Quick start
curl -O https://raw.githubusercontent.com/ayaanh03/workoutgen/main/workoutgen.py
cat > intervals.txt <<'EOF'
name: 5x3 min
warmup: 1mi @ 9:15-10:30/mi
repeat 5
work: 3:00 @ current 7:00-7:15/mi
recovery: 2:00
cooldown: 1mi @ 9:15-10:30/mi
EOF
python3 workoutgen.py build intervals.txt # -> intervals.workout
python3 workoutgen.py decode intervals.workout # prints the spec back
Get the .workout onto the iPhone paired with your Watch (AirDrop, Files, Messages, a download link) and open it. The Workout app imports it.
Prefer a command? pipx install workoutgen (from PyPI), or run it without installing: uvx workoutgen build intervals.txt.
Spec
| Line | Meaning |
|---|---|
name: <text> |
Name shown on the Watch (required) |
activity: running |
Optional, default running |
location: outdoor |
Optional, default outdoor |
warmup: <goal> [@ <alert>] |
Optional |
work: <goal> [@ <alert>] |
A work step; standalone steps run once |
recovery: <goal> [@ <alert>] |
A recovery step |
repeat N |
The indented work / recovery lines under it repeat N times |
cooldown: <goal> [@ <alert>] |
Optional |
# ... |
Comment |
Goals: open, distance (400m, 2km, 1mi, 3.11mi), time (1:30, 50:00, 90s, 5min).
Alerts:
| Alert | Examples |
|---|---|
| Average pace, single or range | 7:40/mi, 4:45/km, 9:10-10:30/mi |
| Current pace, single or range | current 7:00/mi, current 7:00-7:20/mi |
| Heart rate, range or zone (no single value) | 120-150bpm, zone 3 |
| Current cadence, single or range | 170spm, 160-190spm |
| Average power, range | 200-205w |
| Current power, single | current 200w |
Build from stdin with workoutgen.py build - -o out.workout. --uuid pins the plan UUID; by default it's derived from the content, so the same spec always gives the same bytes.
What's verified
Running, outdoor, with the goals and alerts above. Files built this way were imported on an iPhone in October 2026. Cadence ranges and current power are mapped but have no fixture yet; adding an export of either is an easy first contribution. Anything else stops with not mapped yet instead of writing a file the app might reject.
Want cycling, swimming, indoor runs or another alert? It takes one exported file. See CONTRIBUTING.md, or open an issue and attach the export.
For AI agents
- Skill: SKILL.md follows the Agent Skills standard. For Claude Code:
git clone https://github.com/ayaanh03/workoutgen ~/.claude/skills/workoutgen. - Any agent with a shell: fetch the single file (see Quick start) and follow SKILL.md.
- Working on the code: AGENTS.md.
Errors are one line that names the spec line and what to write instead, so an agent can fix its input and retry.
FAQ
How do I make an Apple Watch custom workout without Xcode or an app?
Write the workout as a short spec (above), run python3 workoutgen.py build spec.txt, and open the .workout on your iPhone.
How do I import a custom workout into the Apple Watch Workout app from a file?
Open the .workout file on the iPhone paired with the Watch, for example from AirDrop, the Files app, Messages, or a web link. The Workout app takes it from there.
What is the .workout file format?
A WorkoutKit custom workout (WorkoutPlan) serialized as binary protobuf. Apple only supports importing and exporting it in that binary form. FORMAT.md documents every field mapped so far.
Can I convert a .workout file to text or JSON?
workoutgen.py decode file.workout turns it into the editable text spec, and workoutgen.py dump file.workout prints the raw protobuf tree. There's no JSON output.
Can an AI assistant build Apple Watch workouts for me?
Yes, if it can run Python: it writes the spec, calls build and hands you the file. Claude Code can install it as a skill (above).
Does it support cycling, swimming, strength or indoor workouts? Not yet. Each needs one real export to map; see CONTRIBUTING.md.
Does it use WorkoutKit or need an Apple device? No. It writes the same file format directly, so it runs anywhere Python 3.8+ does. You only need the iPhone to open the result.
Related projects
- WorkoutKit: Apple's official Swift API, used from inside an iOS or watchOS app.
- dotworkout: TypeScript, with a browser editor and an MCP server.
- DotnetWorkoutKit: a .NET library that writes
.workoutfiles.
How it works
The format is protobuf; FORMAT.md has the field map and a worked example. workoutgen.py dump file.workout prints the raw field tree of any export. Tests: python3 test_workoutgen.py.
License
MIT. Not affiliated with Apple. Apple Watch is a trademark of Apple Inc.
Metadata
Release files for workoutgen 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| workoutgen-0.1.0.tar.gz | 11.8 kB | With provenance | Details for workoutgen-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| workoutgen-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for workoutgen-0.1.0-py3-none-any.whl |
Total release size: 24.2 kB
Release files / workoutgen-0.1.0.tar.gz
| Download URL | workoutgen-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcf407fe6f7a2963738844c0fed44e083ba4b353bb33576a912adb9a117c75d9
|
|
BLAKE2b-256 checksum How to use checksums |
afe72bb72df14d2875bd935e681b88f8491b2d34d7272a1f15a32b2714aef19e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / workoutgen-0.1.0-py3-none-any.whl
| Download URL | workoutgen-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8d596792ef5447fba8be31c1749a60200b56b4e798fa62449ae4aa0b9aeeefa
|
|
BLAKE2b-256 checksum How to use checksums |
4f35c4f6f67d9ac1681825ac536915c36c42e1d2592d0e3d9a8f8f27a5f56d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for workoutgen 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for workoutgen-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.