DEV Community

J Now
J Now

Posted on

Cowork's ephemeral $HOME broke my state storage — here's the fix

I built skill-tree-ai to classify 11 observable collaboration behaviors from Anthropic's AI Fluency Index against your own Claude Code or Cowork session history. The classifier runs 7 steps end-to-end in 30–60 seconds: find session files, extract user messages, hit a remote classifier (Claude Haiku on Fly.io), assign one of seven archetype cards, synthesize a narrative, render, return a stable URL.

The growth quest — one behavior you haven't tried, surfaced as a prompt for your next session — needed to persist across sessions. That's where Cowork's environment made things interesting.

Claude Code has a stable ~/.skill-tree/ path. Writing state there is straightforward. Cowork doesn't: its $HOME is ephemeral. Anything written there during one session is gone before the next. So the same plugin can't use the same path on both platforms without silently losing data on Cowork.

The fix was a dual-state-path design keyed to the environment. On Claude Code, state goes to ~/.skill-tree/. On Cowork, it goes to $CLAUDE_PLUGIN_ROOT/.user-state/ — which survives across sessions because $CLAUDE_PLUGIN_ROOT is durable even when $HOME isn't. The plugin detects which environment it's running in at write time and routes accordingly.

This pattern matters beyond skill-tree-ai. If you're building any Claude plugin that needs to persist user state across sessions and you want it to work on both platforms, you can't assume $HOME is stable. $CLAUDE_PLUGIN_ROOT is the safe anchor on Cowork.

The full 7-step orchestration, the archetype card renderer, and the SessionStart hook that surfaces the growth quest at the top of each session are all in the repo. Live example of an archetype card at skill-tree-ai.fly.dev/fixture/illuminator.

https://github.com/robertnowell/ai-fluency-skill-cards

Top comments (0)