### View skill workflow guide Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/01-skill.mdx Print the workflow guide bundled with the installed CLI version. Use the --full flag for detailed workout JSON or API shape information. ```console $ trainheroic skill $ trainheroic skill --full ``` -------------------------------- ### GET /3.0/coach/program/{id} Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example response for program metadata and details. ```json { "id": 4713234, "user_id": 2771594, "published": 0, "description": "", "type": 2, "length": 28, "days": 0, "title": "Test Program", "group_id": 4677607, "logo": "...", "org_id": 602402 } ``` -------------------------------- ### GET /1.0/coach/programs Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example response for the coach programs list. ```json [ { "id": 4677607, "order": 0, "owner_user_id": 2771594, "featured": 0, "title": "Test Program", "date_created": 1773112569, "description": "", "slug": "iberico-program-1773112569", "status": 0, "group_program": 4713234, "org_id": 602402, "logo": "..." } ] ``` -------------------------------- ### Install the CLI Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Install the package globally using npm or run it directly via npx. ```bash npm install -g @trainheroic-unofficial/cli # or: npx @trainheroic-unofficial/cli ``` -------------------------------- ### Install and run the CLI Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/index.mdx Install the CLI globally and execute a command to fetch athlete workouts within a specific date range. ```console $ npm install -g @trainheroic-unofficial/cli $ export TRAINHEROIC_EMAIL=athlete@example.com $ export TRAINHEROIC_PASSWORD=yourpassword $ trainheroic athlete workouts --start 2026-08-01 --end 2026-08-31 ``` -------------------------------- ### Install and initialize the TypeScript SDK Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/index.mdx Install the package and use the TrainHeroicClient to fetch an athlete's profile summary. ```package-install @trainheroic-unofficial/js ``` ```ts import { TrainHeroicClient, fetchAthleteProfileSummary, resolveAthleteUserId } from "@trainheroic-unofficial/js"; const client = new TrainHeroicClient(process.env.TRAINHEROIC_EMAIL!, process.env.TRAINHEROIC_PASSWORD!); const userId = await resolveAthleteUserId(client); console.log(await fetchAthleteProfileSummary(client, userId)); ``` -------------------------------- ### Install dependencies Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/core/README.md Install the core package along with the TrainHeroic JS client and the MCP server SDK. ```bash npm install @trainheroic-unofficial/core @trainheroic-unofficial/js @modelcontextprotocol/server@2.3.1 ``` -------------------------------- ### Install CLI Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Install the CLI globally or run it via npx. Requires Node >= 18 and an existing TrainHeroic account. ```APIDOC ## Install CLI ### Description Install the @trainheroic-unofficial/cli package globally or run it via npx. ### Command npm install -g @trainheroic-unofficial/cli ### Alternative npx @trainheroic-unofficial/cli ### Requirements - Node >= 18 - Existing TrainHeroic account ``` -------------------------------- ### Install or update the CLI Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/SKILL.md Commands to install the CLI globally or update it to the latest version, followed by refreshing skill files. ```bash npm install -g @trainheroic-unofficial/cli trainheroic install-skill # also refreshes skill files in ~/.claude/skills/ ``` ```bash npm update -g @trainheroic-unofficial/cli trainheroic install-skill # pick up any updated skill files ``` -------------------------------- ### Install and use the TrainHeroic CLI Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/README.md Install the CLI globally via npm, set authentication environment variables, and run commands to interact with coach or athlete data. ```bash npm install -g @trainheroic-unofficial/cli export TRAINHEROIC_EMAIL=coach@example.com TRAINHEROIC_PASSWORD=yourpassword trainheroic whoami # confirm auth (shared) trainheroic coach athletes # coach: list your roster trainheroic athlete profile # athlete: lifetime totals + profile trainheroic athlete export # athlete: dump training history to JSON trainheroic help ``` -------------------------------- ### Install @trainheroic-unofficial/js Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Installation commands for the SDK using npm or pnpm. ```bash npm install @trainheroic-unofficial/js # or: pnpm add @trainheroic-unofficial/js ``` -------------------------------- ### GET /user/simple Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example JSON response for the simplified current user profile endpoint. ```json { "id": 2771594, "profileImg": "https://static.trainheroic.com/avatar-2025/J/avatar-JI.png", "coverImg": "https://static.trainheroic.com/images/defaults/5.png", "firstName": "jamon", "lastName": "iberico", "username": "neat.nest6259@fastmail.com", "email": "neat.nest6259@fastmail.com", "is_active": true, "days_from_login": 0, "roles": ["COACH", "TRIAL"], "hasRole": { "COACH": 1, "TRIAL": 1 }, "org_id": 602402, "mpEnabled": null, "use_metric": false, "fdhqUser": false, "trial_days_remaining": 14 } ``` -------------------------------- ### Install @trainheroic-unofficial/dto Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/dto/README.md Install the package using npm. ```bash npm install @trainheroic-unofficial/dto ``` -------------------------------- ### Install @trainheroic-unofficial/js Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/sdk/index.mdx Install the SDK package using your package manager. Requires global fetch and Web Crypto (Node 18+, Cloudflare workerd, or a modern browser). ```APIDOC ## Install @trainheroic-unofficial/js ### Description Install the SDK package using your package manager. Requires global fetch and Web Crypto (Node 18+, Cloudflare workerd, or a modern browser). ### Installation ```bash npm install @trainheroic-unofficial/js ``` ``` -------------------------------- ### GET /v5/programs/new Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves new programs. ```APIDOC ## GET /v5/programs/new ### Description Returns a list of new programs. ### Method GET ### Endpoint /v5/programs/new ``` -------------------------------- ### Initialize local development environment Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cloudflare/README.md Run these commands to generate types, migrate the local D1 database, and start the development server. ```bash pnpm cf-typegen # generate worker-configuration.d.ts (re-run after binding changes) pnpm db:migrate:local # apply migrations to the local D1 pnpm dev # wrangler dev on http://localhost:8787 ``` -------------------------------- ### GET /v5/programs/new Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists new programs. ```APIDOC ## GET /v5/programs/new ### Description Lists new programs. ### Method GET ### Endpoint /v5/programs/new ``` -------------------------------- ### GET /1.0/coach/programs Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists coach programs. ```APIDOC ## GET /1.0/coach/programs ### Description Lists coach programs. ### Method GET ### Endpoint /1.0/coach/programs ### Response #### Success Response (200) - **id** (integer) - Program container ID - **order** (integer) - Order - **owner_user_id** (integer) - Owner user ID - **featured** (integer) - Featured flag - **title** (string) - Program title - **date_created** (integer) - Creation timestamp - **description** (string) - Description - **slug** (string) - Slug - **status** (integer) - Status - **group_program** (integer) - Underlying program ID - **org_id** (integer) - Organization ID - **logo** (string) - Logo URL #### Response Example [ { "id": 4677607, "order": 0, "owner_user_id": 2771594, "featured": 0, "title": "Test Program", "date_created": 1773112569, "description": "", "slug": "iberico-program-1773112569", "status": 0, "group_program": 4713234, "org_id": 602402, "logo": "..." } ] ``` -------------------------------- ### GET /v5/programs/free Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists free programs. ```APIDOC ## GET /v5/programs/free ### Description Lists free programs. ### Method GET ### Endpoint /v5/programs/free ``` -------------------------------- ### GET /v5/programs/free Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves free programs. ```APIDOC ## GET /v5/programs/free ### Description Returns a list of free programs. ### Method GET ### Endpoint /v5/programs/free ``` -------------------------------- ### Install Claude Code Skill Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/README.md Install the TrainHeroic skill for Claude Code using the npx command. ```bash npx skills add alandotcom/trainheroic-unofficial ``` -------------------------------- ### GET /v5/coaches/onboarding Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves onboarding tracking information for the coach. ```APIDOC ## GET /v5/coaches/onboarding ### Description Retrieves onboarding tracking information for the coach. ### Method GET ### Endpoint /v5/coaches/onboarding ### Response #### Success Response (200) No response body documented. #### Response Example No response example documented. ``` -------------------------------- ### Register tools in an MCP server Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/core/README.md Example of setting up an MCP server using ToolContext and registering tool groups. ```ts import { McpServer } from "@modelcontextprotocol/server"; import { serveStdio } from "@modelcontextprotocol/server/stdio"; import { TrainHeroicClient, ExerciseLibrary } from "@trainheroic-unofficial/js"; import { registerReadTools, registerExerciseTools, registerWorkoutTools, // registerAthleteTools, registerTeamTools, registerAnalyticsTools, registerMessagingTools type ToolContext, } from "@trainheroic-unofficial/core"; const client = new TrainHeroicClient( process.env.TRAINHEROIC_EMAIL!, process.env.TRAINHEROIC_PASSWORD!, ); const index = new ExerciseLibrary(client); serveStdio(() => { const server = new McpServer({ name: "trainheroic", version: "1.0.0" }); const ctx: ToolContext = { client, index }; registerReadTools(server, ctx); registerExerciseTools(server, ctx); registerWorkoutTools(server, ctx); return server; }); ``` -------------------------------- ### GET /v5/programs Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists programs. ```APIDOC ## GET /v5/programs ### Description Lists programs. ### Method GET ### Endpoint /v5/programs ``` -------------------------------- ### GET /v5/exerciseLibrary/all Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/workout-creation.md Retrieves the full exercise library. This endpoint is used to get all available exercises with their IDs and parameter types. ```APIDOC ## GET /v5/exerciseLibrary/all ### Description Retrieves the full exercise library, including exercise IDs, titles, and parameter types. ### Method GET ### Endpoint /v5/exerciseLibrary/all ### Parameters None ### Response #### Success Response (200) - **exercises** (array) - List of exercises, each with id, title, param_1_type, param_2_type #### Response Example { "exercises": [ { "id": 1, "title": "Back Squat", "param_1_type": 3, "param_2_type": 1 } ] } ``` -------------------------------- ### Configure MCP in .mcp.json Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/README.md Example configuration for adding the coach MCP server to Claude Desktop or other stdio clients. ```jsonc { "mcpServers": { "trainheroic": { "command": "npx", "args": ["-y", "@trainheroic-unofficial/coach-mcp"], "env": { "TRAINHEROIC_EMAIL": "coach@example.com", "TRAINHEROIC_PASSWORD": "yourpassword", }, }, }, } ``` -------------------------------- ### Development commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/athlete-mcp/README.md Common development tasks for the package, including starting the server and running the MCP Inspector. ```bash pnpm start # run from source pnpm inspect # MCP Inspector UI against the source server pnpm build # tsdown → dist/server.mjs pnpm typecheck pnpm test ``` -------------------------------- ### GET /1.0/coach/subscriptions Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists program subscriptions. ```APIDOC ## GET /1.0/coach/subscriptions ### Description Lists program subscriptions. ### Method GET ### Endpoint /1.0/coach/subscriptions ``` -------------------------------- ### GET /1.0/coach/workouts Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves a paginated list of session templates. ```APIDOC ## GET /1.0/coach/workouts ### Description Retrieves a paginated list of session templates. ### Method GET ### Endpoint /1.0/coach/workouts ### Parameters #### Query Parameters - **page** (integer) - Required - Page number for pagination. - **pageSize** (integer) - Required - Number of items per page. ``` -------------------------------- ### GET /3.0/coach/program/{id} Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves program metadata and details. ```APIDOC ## GET /3.0/coach/program/{id} ### Description Retrieves program metadata and details. ### Method GET ### Endpoint /3.0/coach/program/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Program ID ### Response #### Success Response (200) - **id** (integer) - Program ID - **user_id** (integer) - User ID - **published** (integer) - Published flag - **description** (string) - Description - **type** (integer) - Type - **length** (integer) - Length in days - **days** (integer) - Days - **title** (string) - Program title - **group_id** (integer) - Group ID - **logo** (string) - Logo URL - **org_id** (integer) - Organization ID #### Response Example { "id": 4713234, "user_id": 2771594, "published": 0, "description": "", "type": 2, "length": 28, "days": 0, "title": "Test Program", "group_id": 4677607, "logo": "...", "org_id": 602402 } ``` -------------------------------- ### GET /v5/exerciseLibrary/all Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves the full exercise library containing all available exercises. ```APIDOC ## GET /v5/exerciseLibrary/all ### Description Retrieves the full exercise library with all available exercises. ### Method GET ### Endpoint /v5/exerciseLibrary/all ``` -------------------------------- ### Run dev, build, and preview from website package Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/AGENTS.md Commands to run from the website package directory: start the dev server, build the site, and preview the production build. ```bash pnpm dev ``` ```bash pnpm build ``` ```bash pnpm preview ``` -------------------------------- ### GET /v5/coaches/lowProgramming Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves low programming alerts for the coach. ```APIDOC ## GET /v5/coaches/lowProgramming ### Description Retrieves low programming alerts for the coach. ### Method GET ### Endpoint /v5/coaches/lowProgramming ### Response #### Success Response (200) No response body documented. #### Response Example No response example documented. ``` -------------------------------- ### Drop set pattern JSON Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example of a drop set configuration with decreasing weight and increasing reps. ```json { "exercise_id": 1162, "title": "Bench Press", "instruction": "Drop set - no rest between sets", "param_1_type": 3, "param_2_type": 1, "param_1_data_1": "6", "param_2_data_1": "185", "param_1_data_2": "8", "param_2_data_2": "165", "param_1_data_3": "10", "param_2_data_3": "145", "param_1_data_4": "12", "param_2_data_4": "125", "param_1_data_5": "15", "param_2_data_5": "95", "param_count": 5 } ``` -------------------------------- ### Add and configure the Claude Code skill Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/index.mdx Install the skill and set environment variables for authentication before running Claude. ```console $ npx skills add alandotcom/trainheroic-unofficial $ export TRAINHEROIC_EMAIL=coach@example.com $ export TRAINHEROIC_PASSWORD=yourpassword $ claude ``` -------------------------------- ### GET /v5/athletes Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example JSON response for the list all athletes endpoint. ```json [ { "id": 2771594, "fullName": "iberico, jamon", "firstName": "jamon", "lastName": "iberico", "email": "neat.nest6259@fastmail.com", "useMetric": 0, "teamCount": 0, "daysSinceLastLogin": 0, "groups": [], "groupTitles": [], "userTags": [], "imageProfile": "...", "canUserBeRemovedFromTeam": false, "athleteType": "" } ] ``` -------------------------------- ### GET /v5/exercises/{id} Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-athlete/references/athlete-api.md Retrieves exercise detail including description, parameter types, units, and video. ```APIDOC ## GET /v5/exercises/{id} ### Description Retrieves exercise detail including description, parameter types, units, and video. ### Method GET ### Endpoint /v5/exercises/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Exercise identifier ### Response #### Success Response (200) - **description** (string) - Exercise description - **param1Type** (string) - Type of parameter 1 - **param2Type** (string) - Type of parameter 2 - **units** (string) - Units used - **video** (string) - Video URL or reference ``` -------------------------------- ### GET /v5/headCoach Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example JSON response for the head coach information endpoint. ```json { "id": 2771594, "nameFirst": "jamon", "nameLast": "iberico", "profileImage": "...", "orgId": 602402, "orgName": "Jamon Fit", "coachLicenseId": 10, "nextBillingDate": "2026-03-24", "isTrial": true, "isMarketplaceEnabled": false, "isExpiredTrial": false, "daysLeftInTrial": 14, "isFirstMobileLogin": true } ``` -------------------------------- ### Import SDK Entry Points Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Shows how to import the runtime-agnostic client and Node-only filesystem helpers. ```APIDOC ## Import SDK Entry Points ### Description Import the main client and exercise library from the runtime-agnostic entry, and Node-only filesystem helpers from the ./node entry. ### Code Example ```ts // Runtime-agnostic. Safe in browsers and on workerd. import { TrainHeroicClient, ExerciseLibrary, buildSession } from "@trainheroic-unofficial/js"; // Node-only filesystem helpers, kept out of the main entry. import { JsonFileLibraryCache, defaultCachePath } from "@trainheroic-unofficial/js/node"; ``` ``` -------------------------------- ### Athlete MCP CLI Commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/athlete-mcp/CLAUDE.md Commonly used commands for starting, inspecting, building, and testing the athlete MCP server. ```bash pnpm start # tsx src/server.ts (needs the two env vars) pnpm inspect # MCP Inspector over stdio (forwards the two env vars via -e) pnpm build # tsdown -> dist/server.mjs (the trainheroic-athlete-mcp bin) pnpm typecheck pnpm test ``` -------------------------------- ### Verify CLI installation Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/SKILL.md Check if the trainheroic command is available in your system path. ```bash which trainheroic ``` -------------------------------- ### GET /v5/teams/{teamId}/teamCodes Response Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Example response containing a list of team access codes. ```json [ { "id": 874576, "code": "17731133064959", "created_by": 2771594, "date_created": "2026-03-10T03:28:26Z", "date_modified": "2026-03-10T03:28:26Z", "description": "", "end_date": "2099-01-01T00:00:00Z", "max_use_count": null, "name": "", "start_date": "2026-03-10T03:28:26Z", "status": 1, "team_id": 4677619, "type": 2, "use_count": 0 } ] ``` -------------------------------- ### POST /2.0/coach/exercise/create Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Creates a new custom exercise. Refer to the Custom Exercise Creation section for full details and examples. The tags endpoint GET /2.0/coach/tags/getByType/3 is used during creation. ```APIDOC ## POST /2.0/coach/exercise/create ### Description Creates a new custom exercise. See the Custom Exercise Creation section for full details and examples. ### Method POST ### Endpoint /2.0/coach/exercise/create ### Notes - Uses tags endpoint: GET /2.0/coach/tags/getByType/3 (exercise tags) ``` -------------------------------- ### GET /2.0/coach/workoutSetExercise/template Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves prescription templates for workout set exercises. ```APIDOC ## GET /2.0/coach/workoutSetExercise/template ### Description Retrieves prescription templates for workout set exercises. ### Method GET ### Endpoint /2.0/coach/workoutSetExercise/template ### Response #### Success Response (200) Returns an array of prescription templates. #### Response Example [ { "id": 99, "title": "4 x 3", "type": 1, "param_1_type": 3, "param_2_type": 0, "param_1_data_1": "3", "param_1_data_2": "3", "param_1_data_3": "3", "param_1_data_4": "3", "param_count": 4, "tags": [{ "id": 251, "title": "Strength", "type": 4 }], "editable": false, "use_count": 0 } ] ``` -------------------------------- ### GET /v5/exercises/{id}/stackUp/isSupportedExercise Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Checks if an exercise supports stack-up. ```APIDOC ## GET /v5/exercises/{id}/stackUp/isSupportedExercise ### Description Checks whether a specific exercise supports the stack-up feature. ### Method GET ### Endpoint /v5/exercises/{id}/stackUp/isSupportedExercise ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the exercise. ``` -------------------------------- ### Run website development and build commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/README.md Use these pnpm commands to start the development server locally or build the static site for production. ```bash pnpm website:dev # http://localhost:4321 pnpm website:build ``` -------------------------------- ### trainheroic coach exercise get Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Get details for a specific exercise. ```APIDOC ## trainheroic coach exercise get ### Description Gets details for a specific exercise. ### Command trainheroic coach exercise get ### Arguments - id (string) - Required - Exercise id. ### Output JSON object with exercise details. ``` -------------------------------- ### Initialize ExerciseLibrary and perform searches Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Demonstrates initializing the ExerciseLibrary with a persistent cache and performing fuzzy searches or name resolution for exercises. ```ts import { ExerciseLibrary } from "@trainheroic-unofficial/js"; import { JsonFileLibraryCache } from "@trainheroic-unofficial/js/node"; // `client` is the TrainHeroicClient from the Quickstart above. const library = new ExerciseLibrary(client, new JsonFileLibraryCache()); // Fuzzy search, ranked. Returns up to `limit` matches, each with id, title, and units. const matches = await library.search("back squat", 5); // resolve() returns { match, candidates }. A single confident hit fills `match`; // an ambiguous name leaves `match` null and returns the candidates to choose from. const { match, candidates } = await library.resolve("Barbell Back Squat"); if (!match) { // Ask the user (or the model) to pick one of `candidates`, then use its id. console.log(candidates.map((c) => `${c.id}: ${c.title}`)); } ``` -------------------------------- ### Install and refresh TrainHeroic CLI skill Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-athlete/SKILL.md Checks if the trainheroic CLI is available, installs it globally via npm if missing, and refreshes skill files in ~/.claude/skills/. No credentials are required for installation. ```bash which trainheroic || npm install -g @trainheroic-unofficial/cli trainheroic install-skill # refreshes skill files in ~/.claude/skills/ ``` -------------------------------- ### Run website dev server from repo root Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/AGENTS.md Starts the local development server for the website from the repository root. The site is served at http://localhost:4321. ```bash pnpm website:dev # http://localhost:4321 ``` -------------------------------- ### Workout Specification JSON Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Example of a workout specification file (day.json) defining blocks and exercises. ```jsonc // day.json: one block with one exercise (id 41822 is a library exercise id) { "instruction": "Warm up first.", "blocks": [ { "title": "Strength", "exercises": [ { "id": 41822, "sets": 5, "reps": 5, "primaryUnit": "reps", "weight": 225, "secondaryUnit": "lb", "rpe": 8, }, ], }, ], } ``` -------------------------------- ### Build a session draft with buildSession Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/sdk/02-workouts.mdx This example demonstrates resolving an exercise from the library and using buildSession to create a draft session. The publish flag is set to false to ensure the session remains a draft for inspection. ```ts import { buildSession } from "@trainheroic-unofficial/js"; const { match } = await library.resolve("Back Squat"); if (!match) throw new Error("Choose one exercise before building"); if (match.units[0] !== "reps" || match.units[1] !== "lb") { throw new Error("Choose an exercise with reps and pounds as its fixed units"); } const { pwId, workoutId } = await buildSession(client, { programId: 12345, index: library, date: [2026, 8, 17], // [year, month, day], with a 1-based month instruction: "Warm up first.", blocks: [ { title: "Strength", exercises: [ { id: match.id, sets: 5, reps: 5, primaryUnit: "reps", weight: 225, secondaryUnit: "lb", rpe: 8, }, ], }, ], publish: false, }); ``` -------------------------------- ### Perform a POST request with a body Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Example of creating an exercise by passing a body object to the request method. ```ts const created = await client.request("POST", "/2.0/coach/exercise/create", { body: { title: "Sled Push", points_of_performance: "" }, }); ``` -------------------------------- ### Create Session on Program Timeline Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Alternative Step 2 for program timelines that are not date-based. ```http POST /2.0/coach/calendar/workout/createWorkoutForTimelineDay/{programId}/{day}/null ``` -------------------------------- ### Local preview command Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/README.md Run this command locally after executing pnpm build to preview the website using wrangler. ```bash pnpm --filter @trainheroic-unofficial/website exec wrangler dev ``` -------------------------------- ### Import SDK entry points Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/sdk/index.mdx The SDK provides a runtime-agnostic entry point and a separate entry point for Node.js filesystem helpers to ensure compatibility with environments like Cloudflare Workers. ```ts import { TrainHeroicClient, ExerciseLibrary, buildSession } from "@trainheroic-unofficial/js"; ``` ```ts import { JsonFileLibraryCache, defaultCachePath } from "@trainheroic-unofficial/js/node"; ``` -------------------------------- ### GET /v5/athletes Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists all athletes. ```APIDOC ## GET /v5/athletes ### Description Lists all athletes. ### Method GET ### Endpoint /v5/athletes ### Response #### Success Response (200) - **id** (integer) - Athlete ID - **fullName** (string) - Full name - **firstName** (string) - First name - **lastName** (string) - Last name - **email** (string) - Email address - **useMetric** (integer) - Whether metric units are used - **teamCount** (integer) - Number of teams - **daysSinceLastLogin** (integer) - Days since last login - **groups** (array) - Groups - **groupTitles** (array) - Group titles - **userTags** (array) - User tags - **imageProfile** (string) - Profile image URL - **canUserBeRemovedFromTeam** (boolean) - Whether user can be removed from team - **athleteType** (string) - Athlete type #### Response Example [ { "id": 2771594, "fullName": "iberico, jamon", "firstName": "jamon", "lastName": "iberico", "email": "neat.nest6259@fastmail.com", "useMetric": 0, "teamCount": 0, "daysSinceLastLogin": 0, "groups": [], "groupTitles": [], "userTags": [], "imageProfile": "...", "canUserBeRemovedFromTeam": false, "athleteType": "" } ] ``` -------------------------------- ### Authenticate and Run Commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Set your credentials in the environment variables and execute commands. All commands output JSON to stdout. ```bash export TRAINHEROIC_EMAIL="coach@example.com" export TRAINHEROIC_PASSWORD="..." trainheroic whoami # confirm auth; prints your account trainheroic coach exercise resolve "Back Squat" # name -> exercise (id, units) ``` -------------------------------- ### Development commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/core/README.md Commands for building, typechecking, and testing the package. ```bash pnpm build # tsdown pnpm typecheck pnpm test pnpm exec vitest run test/confirm.test.ts # one file ``` -------------------------------- ### GET /3.0/athlete/leaderboard/{id} Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves the leaderboard. ```APIDOC ## GET /3.0/athlete/leaderboard/{id} ### Description Returns the leaderboard for the specified ID. ### Method GET ### Endpoint /3.0/athlete/leaderboard/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the leaderboard. ``` -------------------------------- ### Visualize the architecture Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/index.mdx A Mermaid diagram showing how the SDK, CLI, and MCP layers interact. ```mermaid flowchart LR dto["dto
zod schemas"] --> js["js
TypeScript SDK"] js --> core["core
MCP tool layer"] js --> cli["cli"] core --> local["coach-mcp
athlete-mcp"] core --> hosted["Hosted MCP
Cloudflare Worker"] cli --> skill["Claude Code skill"] ``` -------------------------------- ### trainheroic skill Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Print the full workflow guide to stdout, version-matched to the binary. Use --full to include API and workout-creation reference docs. ```APIDOC ## trainheroic skill ### Description Prints the full workflow guide (with copy-paste workout-spec examples) to stdout, version-matched to the binary. Use --full to add the API and workout-creation reference docs. ### Command trainheroic skill ### Options - --full (boolean) - Optional - Adds the API and workout-creation reference docs. ### Output Workflow guide as text to stdout. ``` -------------------------------- ### Build and Publish Workouts Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/README.md Commands to build a workout as a draft or publish it directly to athletes. ```bash # Build as a draft (988 is the program id): trainheroic coach workout build --program 988 --date 2026-6-22 --file day.json # Build and publish to athletes (publishing is athlete-facing, so it needs --yes): trainheroic coach workout build --program 988 --date 2026-6-22 --file day.json --publish --yes ``` -------------------------------- ### GET /1.0/user/userInfo Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves user info. ```APIDOC ## GET /1.0/user/userInfo ### Description Returns information about the authenticated user. ### Method GET ### Endpoint /1.0/user/userInfo ``` -------------------------------- ### Core Package Build and Test Commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/core/CLAUDE.md Standard commands for building, type-checking, and testing the core package. ```bash pnpm build # tsdown pnpm typecheck pnpm test pnpm exec vitest run test/confirm.test.ts pnpm exec vitest run -t "" ``` -------------------------------- ### GET /1.0/athlete/programming/programs Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves athlete programs. ```APIDOC ## GET /1.0/athlete/programming/programs ### Description Returns the list of programs for the athlete. ### Method GET ### Endpoint /1.0/athlete/programming/programs ``` -------------------------------- ### GET /v5/site-banners Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves site banners. ```APIDOC ## GET /v5/site-banners ### Description Retrieves site banners. ### Method GET ### Endpoint /v5/site-banners ### Response #### Success Response (200) - **banners** (array) - List of site banners. #### Response Example { "banners": [] } ``` -------------------------------- ### Importing library entry points Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Shows the separation between the runtime-agnostic main entry point and the Node.js-specific filesystem helpers. ```ts // Runtime-agnostic. Safe in browsers and on workerd. import { TrainHeroicClient, ExerciseLibrary, buildSession } from "@trainheroic-unofficial/js"; // Node-only filesystem helpers, kept out of the main entry. import { JsonFileLibraryCache, defaultCachePath } from "@trainheroic-unofficial/js/node"; ``` -------------------------------- ### buildSession(client, options) Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/website/src/content/docs/developers/sdk/02-workouts.mdx Creates a session inside a program, saving its blocks and exercises. It can optionally publish the session, but the recommended workflow is to build a draft first, inspect it, and then publish deliberately. ```APIDOC ## buildSession(client, options) ### Description Creates a session inside a program, saving its blocks and exercises. It can optionally publish the session, but the recommended workflow is to build a draft first, inspect it, and then publish deliberately. ### Method SDK function call ### Endpoint buildSession(client, options) ### Parameters #### client - **client** (Client) - Required - The authenticated SDK client. #### options - **programId** (number) - Required - The program that receives the session. Use a team's program or a roster athlete's calendar; a personal calendar rejects coach writes. - **index** (ExerciseIndex) - Required - The exercise library. Every exercise and its units are checked against it before the first write. - **blocks** (BlockSpec[]) - Required - The session's blocks, each with a title and its exercises. - **date** ([year, month, day]) - Optional - The calendar day for the session, with a 1-based month. Required unless you pass timelineDay. - **timelineDay** (number) - Optional - The day number in a fixed-length program. Use it in place of date. - **publish** (boolean) - Optional - Publish the session to athletes after it saves. Leave it off to build a draft. Default: false. - **instruction** (string) - Optional - The session's coach instructions, saved after the blocks. - **confirmSetSplit** (boolean) - Optional - Allow a prescription above ten sets to become consecutive blocks. Default: false. ### Request Example ```ts const { pwId, workoutId } = await buildSession(client, { programId: 12345, index: library, date: [2026, 8, 17], // [year, month, day], with a 1-based month instruction: "Warm up first.", blocks: [ { title: "Strength", exercises: [ { id: match.id, sets: 5, reps: 5, primaryUnit: "reps", weight: 225, secondaryUnit: "lb", rpe: 8, }, ], }, ], publish: false, }); ``` ### Response #### Success Response - **pwId** (number) - The session's placement in the program. Read, publish, unpublish, copy, and remove operations use it. - **workoutId** (number) - The underlying workout record. - **advisories** ({ notes: string[]; warnings: string[] }) - Notes and warnings from the build, such as a set count that was split across blocks. #### Response Example ```ts { pwId: 123, workoutId: 456, advisories: { notes: [], warnings: [] } } ``` ``` -------------------------------- ### pnpm build, typecheck, test, and targeted vitest commands Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/CLAUDE.md Commands for building the SDK with tsdown (emitting separate '.' and './node' bundles), typechecking, running the full test suite, running a specific test file, and running tests matching a name pattern. ```bash pnpm build # tsdown; emits separate "." and "./node" bundles pnpm typecheck pnpm test pnpm exec vitest run test/.test.ts pnpm exec vitest run -t "" ``` -------------------------------- ### GET /v5/programs/fixed Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Lists fixed programs. ```APIDOC ## GET /v5/programs/fixed ### Description Lists fixed programs. ### Method GET ### Endpoint /v5/programs/fixed ``` -------------------------------- ### Build a workout session with buildSession Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/js/README.md Shows how to construct a workout session using BlockSpec and buildSession, including validation against the exercise library. ```ts import { buildSession, type BlockSpec } from "@trainheroic-unofficial/js"; const { match } = await library.resolve("Back Squat"); if (!match) throw new Error("Resolve to a single exercise before building."); if (match.units[0] !== "reps" || match.units[1] !== "lb") { throw new Error("Choose an exercise with reps and pounds as its fixed units."); } const blocks: BlockSpec[] = [ { title: "Strength", exercises: [ // sets/reps/weight scalars; rpe is routed into the instruction text (see the encoder). { id: match.id, sets: 5, reps: 5, primaryUnit: "reps", weight: 225, secondaryUnit: "lb", rpe: 8, }, ], }, ]; const { pwId, workoutId } = await buildSession(client, { programId: 12345, index: library, date: [2026, 6, 22], // [year, month, day]; month is 1-based, so 6 = June blocks, instruction: "Warm up first.", publish: false, // build as a draft; publish makes it visible to athletes }); ``` -------------------------------- ### GET /v5/coaches/orgs Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves coach organizations. ```APIDOC ## GET /v5/coaches/orgs ### Description Retrieves coach organizations. ### Method GET ### Endpoint /v5/coaches/orgs ### Response No response schema provided in the source. ``` -------------------------------- ### GET /v5/athleteProfile/summary Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves athlete profile summary. ```APIDOC ## GET /v5/athleteProfile/summary ### Description Returns a summary of the athlete profile. ### Method GET ### Endpoint /v5/athleteProfile/summary ``` -------------------------------- ### GET /v5/users/circuits/history Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves circuit history for the user. ```APIDOC ## GET /v5/users/circuits/history ### Description Returns the circuit history for the authenticated user. ### Method GET ### Endpoint /v5/users/circuits/history ``` -------------------------------- ### POST /2.0/coach/calendar/workout/createWorkoutForTimelineDay/{programId}/{day}/null Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Creates a session in a program timeline. ```APIDOC ## POST /2.0/coach/calendar/workout/createWorkoutForTimelineDay/{programId}/{day}/null ### Description Creates a session in a program (timeline). ### Method POST ### Endpoint /2.0/coach/calendar/workout/createWorkoutForTimelineDay/{programId}/{day}/null ### Parameters #### Path Parameters - **programId** (string) - Required - The ID of the program. - **day** (string) - Required - The day identifier. ``` -------------------------------- ### GET /v5/users/circuits/recent Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves recent circuits for the user. ```APIDOC ## GET /v5/users/circuits/recent ### Description Returns a list of recent circuits for the authenticated user. ### Method GET ### Endpoint /v5/users/circuits/recent ``` -------------------------------- ### GET /v5/users/exercises/recent Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves recent exercises for the user. ```APIDOC ## GET /v5/users/exercises/recent ### Description Returns a list of recent exercises for the authenticated user. ### Method GET ### Endpoint /v5/users/exercises/recent ``` -------------------------------- ### Launch MCP Inspector Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cloudflare/README.md Use this command to fetch and open the official MCP debugging UI for testing the local server. ```bash pnpm inspect # fetches and opens the Inspector UI via npx ``` -------------------------------- ### GET /v5/notifications/counts Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves the count of notifications for the user. ```APIDOC ## GET /v5/notifications/counts ### Description Retrieves the count of notifications for the user. ### Method GET ### Endpoint /v5/notifications/counts ### Response #### Success Response (200) - **count** (integer) - The number of notifications. #### Response Example { "count": 0 } ``` -------------------------------- ### Create KV namespace and D1 database Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cloudflare/DEPLOY.md Run these commands to provision the required Cloudflare storage resources. After execution, update the returned IDs in wrangler.jsonc and run pnpm cf-typegen. ```bash pnpm exec wrangler kv namespace create OAUTH_KV pnpm exec wrangler d1 create trainheroic ``` -------------------------------- ### GET /v5/notifications Source: https://github.com/alandotcom/trainheroic-unofficial/blob/main/packages/cli/skill/trainheroic-unofficial/references/api-reference.md Retrieves the list of notifications for the user. ```APIDOC ## GET /v5/notifications ### Description Retrieves the list of notifications for the user. ### Method GET ### Endpoint /v5/notifications ### Response #### Success Response (200) - **notifications** (array) - List of notifications. #### Response Example { "notifications": [] } ```