Claude Code
The Myelin SDK integrates with Claude Code through PostToolUse hooks and MCP tools. Setup takes under 5 minutes — no code changes required.
Setup
1. Install the SDK
uv tool install myelin-sdkOr pip install myelin-sdk if you don't use uv. Both register the myelin-capture command needed by the hook. If myelin-capture is not on your PATH (common on Windows), use python -m myelin_sdk.claude_code as the hook command instead.
2. Add the MCP server
Run this from your project directory (replace YOUR_API_KEY with your key from the dashboard):
claude mcp add --scope project --transport http \
myelin https://myelin.fly.dev/mcp \
-H "Authorization: Bearer YOUR_API_KEY"3. Add the PostToolUse hooks
Add the following to your project's .claude/settings.json:
{
"hooks": {
"PostToolUse": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "myelin-capture" }]
}],
"PostToolUseFailure": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "myelin-capture" }]
}]
}
}4. Update .gitignore
The MCP config contains your API key. Exclude it from version control:
.mcp.jsonHow it works
Once configured, the integration runs automatically on every task:
- Claude calls
searchat the start of a task to find a matching workflow. If a match is found, it callsrecordto begin a recording session. The full procedure markdown is returned for the agent to follow. - The PostToolUse and PostToolUseFailure hooks fire after every tool call — including failed ones — capturing the tool name, input, output, and agent reasoning. Data is redacted before leaving your machine.
- Claude calls
finishwhen the task is done. The server evaluates the session, extracts workflows from successful runs, and updates success rates.
Best Practices
- Keep task descriptions high-level. When calling
search, use a short description like “reset user password” rather than including specific variables. This improves workflow matching across similar tasks. - Always call finish. Even if the task failed, calling
finishprovides valuable signal. The server-side evaluator handles scoring — agents don't need to self-report success or failure. - Follow matched workflows. When search returns a match, follow the procedure content. This improves the workflow's success rate and helps future agents.
- One search + start per task. Each call to
recordbegins a new recording session. Search and start once at the beginning of a distinct task, not for every sub-step.