Myelin

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-sdk

Or 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.json

How it works

Once configured, the integration runs automatically on every task:

  1. Claude calls search at the start of a task to find a matching workflow. If a match is found, it calls record to begin a recording session. The full procedure markdown is returned for the agent to follow.
  2. 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.
  3. Claude calls finish when 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 finish provides 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 record begins a new recording session. Search and start once at the beginning of a distinct task, not for every sub-step.