Skip to content

feat: cowork modes — persistent memory for non-coding work#1311

Open
thedotmack wants to merge 10 commits intomainfrom
feat/cowork-modes
Open

feat: cowork modes — persistent memory for non-coding work#1311
thedotmack wants to merge 10 commits intomainfrom
feat/cowork-modes

Conversation

@thedotmack
Copy link
Owner

Summary

Adds a mode system for non-coding knowledge workers — writers, researchers, analysts, project managers — so they get persistent memory across Claude Code sessions without any developer-oriented noise.

  • Cowork mode (cowork.json): 6 observation types (creation, research, transformation, decision, discovery, automation) and 7 concepts tuned for knowledge work instead of software engineering
  • Cowork Chill variant (cowork--chill.json): Low-noise variant that only records work painful to rediscover
  • /set-mode skill: Full mode activation — updates settings, installs mode-specific CLAUDE.md project instructions, restarts worker. Single command: /set-mode cowork
  • /make-mode skill: Guided interview that creates custom modes for any domain (sales, academic research, legal review, etc.) — no code changes needed
  • /mode command: List available modes and switch between them
  • Lazy session init: Observation endpoint auto-initializes sessions for Cowork environments where UserPromptSubmit may not fire
  • Docs: Full Mintlify docs page (cowork-modes.mdx) with setup guide, FAQ, and examples targeting non-developer users

Bug fixes

  • Remove pro code leaking into worker build
  • Skip tree-sitter reinstall on sync (was causing build failures)
  • Add missing matcher field to UserPromptSubmit hook in hooks.json

Test plan

  • /mode lists all available modes with active indicator
  • /set-mode cowork activates cowork mode, updates settings, restarts worker
  • /set-mode code switches back without regression
  • Cowork session records observations with correct types (creation, research, etc.)
  • /make-mode walks through interview and produces valid mode JSON
  • cowork--chill variant inherits parent observation types/concepts
  • Lazy session init works when UserPromptSubmit doesn't fire
  • npm run build-and-sync succeeds without tree-sitter errors

🤖 Generated with Claude Code

thedotmack and others added 4 commits March 8, 2026 22:21
…mode skill

- Add lazy session initialization in observation endpoint for Cowork
  environments where UserPromptSubmit hook doesn't fire
- Add Python version auto-detection in ChromaMcpManager (probes 3.13→3.10)
- Add matcher "*" to UserPromptSubmit hook for defense-in-depth
- Add /mode slash command to list and switch modes via settings API
- Add cowork.json mode with 6 knowledge-work observation types and 7 concepts
- Add cowork--chill.json behavioral variant for selective recording
- Add make-mode skill for guided custom mode creation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New set-mode skill: full mode activation (settings + project
  instructions + worker restart) in one command
- Updated make-mode skill: added Step 6 for creating mode CLAUDE.md
  files focused on human-primary agent relationship
- Mode CLAUDE.md files are standalone project instructions with no
  claude-mem internal references
- set-mode installs mode instructions via <claude-mem-mode> tags
  in the project's CLAUDE.md (idempotent on mode switches)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… sync

Reverted ChromaMcpManager.ts python detection change (unrelated to cowork).
Rebuilt worker-service.cjs from clean source without pro code contamination.
Added --ignore-scripts to bun install in sync-marketplace to stop
tree-sitter-cli from re-downloading its binary on every sync.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Mar 9, 2026

Code Review — feat: cowork modes

This is a solid feature addition that broadens the audience for claude-mem considerably. The architecture is clean and the documentation is excellent. A few things worth addressing before merge:


Bugs

make-mode/SKILL.md: Template body is missing (Step 4)

The skill references a JSON skeleton but the placeholder text is never filled in — the LLM has no structure to follow for 33 prompt fields and will likely produce inconsistent output. The law-study.json example referenced in Step 6 suggests a canonical reference exists — the template should be embedded or the skill should explicitly read a reference mode file.

plugin/commands/mode.md vs /set-mode: Inconsistent switch behavior

/mode <name> updates settings but notes the change takes effect on the next session. /set-mode <name> does the same update plus restarts the worker for immediate effect. Two commands doing the same thing with different behavior will confuse users. Either consolidate (/mode should delegate to /set-mode), or make the distinction explicit in the command output.


Security

set-mode/SKILL.md Step 3: $ARGUMENTS in curl JSON body

If $ARGUMENTS contains a double-quote character, the JSON payload will be malformed. A crafted mode name could also break the shell command. Suggest using jq to build the payload, or --data @- with a process substitution. The same pattern appears in mode.md Step 3.


Code Quality

SessionRoutes.ts: No error handling in lazy init path

if (!this.sessionManager.getSession(sessionDbId)) {
  const syntheticPrompt = '[auto-initialized from observation]';
  store.saveUserPrompt(contentSessionId, 1, syntheticPrompt);
  this.sessionManager.initializeSession(sessionDbId, syntheticPrompt, 1);
  this.ensureGeneratorRunning(sessionDbId, 'lazy-init');
}

Any of these calls can throw, which would surface as an unhandled 500 from the observation endpoint. A try/catch with log-and-continue would keep the endpoint resilient — observation failure should not block the user's workflow.

Also: the synthetic prompt string '[auto-initialized from observation]' will appear in user_prompts in the DB. If any query or export surfaces raw prompt text this could look strange to users. A nullable prompt or a clearly internal sentinel might be cleaner.

cowork--chill.json: Missing description and version fields

The parent cowork.json has both. The chill variant omits both. If the UI or any code iterates mode files expecting those fields it will get undefined. Suggest adding at least a description.


Minor

docs/public/introduction.mdx: Folder Context card replaced

The Folder Context card on the main landing page was replaced with Cowork Modes. Folder Context is an existing core feature — removing it from the main nav hurts discoverability. Consider expanding the CardGroup rather than swapping.

sync-marketplace.cjs: --ignore-scripts scope

This fixes tree-sitter but will silently skip all post-install scripts for all current and future deps. Worth adding an inline comment explaining why the flag is needed so it does not get removed later.

plugin/skills/make-mode/SKILL.md: Write path is dev-only

Step 5 writes to plugin/modes/{mode-name}.json — this path only exists inside the claude-mem dev repo. Installed users at ~/.claude/plugins/marketplaces/thedotmack/ will not have it. The same dual-path detection from set-mode/SKILL.md should apply here.


Positive Notes

  • hooks.json matcher: "*" fix is correct and clearly was causing real breakage.
  • The lazy session init comment explaining why Cowork needs it is appreciated.
  • --ignore-scripts is the right fix for the tree-sitter build failure.
  • cowork-modes.mdx is genuinely excellent documentation — clear, non-technical, practical examples.
  • The parent-fallback logic for -- variants is well-thought-out and applied consistently.

Copy link

@xkonjin xkonjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review focus: bugs, security issues, and test coverage.

Snapshot: 13 files changed, +980/-119 lines.

Key findings:

  • Hardcoded password-like assignment found. Use secrets manager.
  • Debug statements present. Remove or guard behind a debug flag.
  • Source changes without corresponding tests. Please add or update tests to cover new/changed logic.

Suggestions:

  • Add targeted unit tests for edge cases and error handling.
  • Consider adding CI checks for secret scanning and dependency pinning.

thedotmack and others added 6 commits March 10, 2026 15:46
When CLAUDE_PLUGIN_ROOT is unset (SessionStart bug #24529), hooks now
check the marketplace cache directory before falling back to the dev path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
/set-mode now uses ${CLAUDE_SKILL_DIR}/../../ to resolve mode files and
worker-cli.js. /mode command discovers modes from cache, marketplace,
and dev paths. Fixes compatibility with marketplace cache installs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CursorHooksInstaller now shows generic path guidance instead of a
specific marketplace path. BranchManager comment updated to reference
MARKETPLACE_ROOT variable instead of hardcoded path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
worker-cli now resolves plugin root via: CLAUDE_PLUGIN_ROOT env var,
__dirname-based detection, cache directory scan, then marketplace
fallback. Fixes worker restart from cache-installed plugins.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The cache directory is owned by the plugin system, not the plugin itself.
Strip the 3rd-tier cache scan from all 8 hook commands, worker-cli.js
_resolvePluginRoot(), and mode.md discovery list. Resolution is now:
CLAUDE_PLUGIN_ROOT → marketplace fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants