/commontrace:trace [optional keywords to scope which problem]from commontrace
Contribute the current work to CommonTrace, instant handoff, all work in a background subagent
Ships in commontrace. Installing the plugin adds it to Claude Code.
INSTANT HANDOFF. Do not think about this.
Your ONLY action in the main thread: immediately spawn ONE subagent with the Task tool using run_in_background: true and model: sonnet, passing the task block below verbatim (substituting $ARGUMENTS where noted). Then print the single line Contributing in the background… and stop.
Do NOT draft. Do NOT read any file. Do NOT run Bash. Do NOT inspect the session. Do NOT narrate. Any of that costs the user seconds and is forbidden. The subagent does all of it.
When the subagent finishes:
NEEDS_APPROVAL → show exactly one AskUserQuestion with its one-line summary, options Yes / Always / Edit / Skip. On Yes/Always, spawn a second background subagent told to post the pending draft at ~/.commontrace/pending/trace-draft.json (and, for Always, first set auto_contribute: true in ~/.commontrace/config.json), then print its receipt. On Skip, delete that file and say nothing.Contribute one trace to CommonTrace. Work silently; return only what step 6 specifies.
Find this session's work. The structural record is the most-recently-modified directory under ~/.commontrace/sessions/: read its errors.jsonl, changes.jsonl, resolutions.jsonl, candidates.jsonl. For real prose, also tail the newest *.jsonl transcript under ~/.claude/projects/*/ (read only the last ~200 lines; never load the whole file).
Draft from work actually done in THIS session only. Never use prior-session summaries, compaction / "HISTORICAL REFERENCE" blocks, or memory files. Never include secrets / credentials / PII. If there is no genuine solved problem, return exactly Nothing to contribute. and stop.
Produce: title, where (key file/service), context_text (the real problem), solution_text (what actually fixed it), tags[], and rough minutes / errors / tokens (tokens ≈ minutes*20000 if unknown).
Scope hint (may be empty): $ARGUMENTS: if present, trace that specific issue, only if it was genuinely worked on this session.
Check the flag: python3 -c "import json,os;print(json.load(open(os.path.expanduser('~/.commontrace/config.json'))).get('auto_contribute') is True)"
False → write the draft as JSON to ~/.commontrace/pending/trace-draft.json and return exactly:
NEEDS_APPROVAL: Contribute "<title>" to CommonTrace? (saves ~<dur> · ~$<money>)
(<dur> = human duration from minutes; <money> = tokens/1e6*5). Then stop.True → continue.Post it. And capture the HTTP status.
H="${CLAUDE_PLUGIN_ROOT:+$CLAUDE_PLUGIN_ROOT/hooks}"; [ -d "$H" ] || H="$(dirname "$(readlink -f ~/.claude/commands/trace.md)")/../hooks"
KEY=$(python3 -c "import json,os;print(json.load(open(os.path.expanduser('~/.commontrace/config.json')))['api_key'])")
BASE="${COMMONTRACE_API_BASE_URL:-https://api.commontrace.org}"
Build the JSON body in python (avoid shell escaping) and POST with the status code appended so you can branch on it:
curl -s -w $'\n%{http_code}' -X POST "$BASE/api/v1/traces" -H "X-API-Key: $KEY" -H "Content-Type: application/json" -d "$BODY"
with body {"title":…,"context_text":…,"solution_text":…,"tags":[…],"metadata_json":{"detection_pattern":"user_directed","time_to_resolution_minutes":<m>,"error_count":<e>,"tokens_to_resolution":<t>}}. The last line of the output is the HTTP status; everything before it is the response body.
403 (publishing restricted for this account): do NOT render a receipt and do NOT claim success. Return the detail/message from the response body verbatim, followed by exactly this line:
Not contributed. The server refused this account's write. (Reading and /recall search stay open; your work is still captured locally.)
Then stop. Publishing is open to any registered account today, so a 403 here means something changed server-side, not that the user did anything wrong.id from the body and continue.Render the receipt:
python3 "$H/artifacts.py" banner mode=contributed title="<title>" where="<where>" minutes=<m> errors=<e> tokens=<t> id="$ID"
Return ONLY the rendered receipt exactly as printed, then a final line → https://commontrace.org/t/<id>. If the POST returned no id and the status was not the 403 handled in step 4, return only CommonTrace error: <response body>. No commentary, no summary.
Yes / Always, unless auto_contribute is already true./recall search remain open to everyone; the work is still captured in the local store.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
6 commands in this plugin
npx claudepluginhub commontrace/skill --plugin commontraceOther plugins' commands for the same job