/foundry:profile [--since 24h|7d|30d] [--session-id ID] [--top-n N]from foundry
Analyzes Claude Code session wall-clock time and token/cost from local logs and transcripts. Answers why a skill ran slowly, what a session cost, or which skill consumes the most tokens.
Ships in foundry. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Bucket session clock time from ~/.claude/logs/{timings,invocations}.jsonl into:
tool=Skill wall durations...and bucket session tokens/cost from Claude Code transcripts (~/.claude/projects/**, main-loop + subagent files) into:
--session-id) — cost by main/sidechain × model tier, agent roster, top cache-rebuild calls, cold-start shareOutputs a markdown report at .reports/profile/<UTC-timestamp>/report.md plus a .temp/output-profile-...md copy: per-session clock table, per-skill clock rollup, top-N longest single calls, plus a ## Tokens & cost section scoped to same window / --session-id.
NOT for: per-line Python perf (use foundry:perf-optimizer); known failure diagnosis (use /foundry:investigate); a real billing statement (prices are public list rates, not effective plan rates).
--since DURATION (default 24h) — window: NNs|NNm|NNh|NNd--session-id ID — optional; restrict to one session--top-n N (default 5) — slowest single calls to listIf $ARGUMENTS empty, default window is 24h.
Task hygiene — task tools may be deferred; load before first use: ToolSearch(query="select:TaskList,TaskCreate,TaskUpdate,TaskGet", max_results=4). Call TaskList first and triage each task it returns: completed if work clearly done, deleted if orphaned, keep in_progress only if genuinely continuing. Never spend a turn on bookkeeping alone — every TaskCreate/TaskUpdate ships in the same response as the next substantive tool call; one exception, TaskUpdate(completed) immediately before a long output block (rules/task-lifecycle.md).
Task tracking: TaskCreate two tasks up front — 1 "Run analyzers + render report" (Steps 1–3), 2 "Step 4: Print report header" (Step 4). Mark each in_progress before its first tool call; 1 completed once report.md exists, 2 completed right after the header and path are printed, before the executive summary.
Unsupported flag check — before executing Step 2, scan $ARGUMENTS for --<token> patterns. Supported: --since, --session-id, --top-n (space-separated or = values). Any other flag, including --noop (an internal parser placeholder, not a supported profile flag): invoke AskUserQuestion with question text ! Unknown flag(s): `--<token>`. Supported: `--since`, `--session-id`, `--top-n`. — (a) Abort (stop, re-invoke with correct flags) · (b) Continue ignoring (remove unknown flags before passing $ARGUMENTS to Step 2). On Abort: stop.
The first part of the Step 2 block below does this step (one Bash call with the clock-time analyzer): argument text is parsed in bin/ and validated against closed patterns before use, then persisted as KEY=VALUE lines to ${TMPDIR:-/tmp}/foundry-profile-state-${CSID}; Steps 2b–3 read it back key by key, never sourcing it (bash state doesn't persist across Bash calls, and REPORT_DIR carries a per-shell timestamp that can't be re-derived).
PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name foundry) || exit $?; export PLUGIN_ROOT
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
# timeout: 60000
# --flags is mandatory for the helper; profile has no boolean flags. --keep-state: no eval; --inlined: profile keeps no compaction contract, so it clears none
python "$PLUGIN_ROOT/bin/parse-skill-flags.py" --flags noop --value-flags since,session-id,top-n --keep-state profile --inlined -- "$ARGUMENTS" >/dev/null
IFS= read -r SINCE < "${TMPDIR:-/tmp}/profile-since-${CSID}" 2>/dev/null; SINCE="${SINCE:-24h}"
IFS= read -r TOP_N < "${TMPDIR:-/tmp}/profile-top-n-${CSID}" 2>/dev/null; TOP_N="${TOP_N:-5}"
IFS= read -r SESSION_ID < "${TMPDIR:-/tmp}/profile-session-id-${CSID}" 2>/dev/null || SESSION_ID=""
[[ $SINCE =~ ^[0-9]+[smhd]$ && $TOP_N =~ ^[0-9]+$ && $SESSION_ID =~ ^[A-Za-z0-9._-]*$ ]] || { echo "! BLOCKED — invalid --since/--top-n/--session-id"; exit 1; }
STAMP="$(date -u +%Y-%m-%dT%H-%M-%SZ)"
REPORT_DIR=".reports/profile/$STAMP"
mkdir -p "$REPORT_DIR"
{
echo "REPORT_DIR=$REPORT_DIR"
echo "SINCE=$SINCE"
echo "SESSION_ID=$SESSION_ID"
echo "TOP_N=$TOP_N"
} | tee "${TMPDIR:-/tmp}/foundry-profile-state-${CSID}"
set --; [ -n "$SESSION_ID" ] && set -- --session-id "$SESSION_ID"
python "$PLUGIN_ROOT/bin/timing_analyzer.py" \
--since "$SINCE" \
--top-n "$TOP_N" \
--output "$REPORT_DIR/report.md" \
"$@" 2>"$REPORT_DIR/warnings.log"
TIME_EXIT=$?
echo "time_exit=$TIME_EXIT"
[ "$TIME_EXIT" -lt 2 ] || { echo "! BLOCKED — timing_analyzer exit $TIME_EXIT; see $REPORT_DIR/warnings.log"; exit 1; }
[ "$TIME_EXIT" -eq 0 ] || { echo "No sessions in window; stopping."; exit 1; }
set -- array form passes --session-id and its value as separate arguments only when set (shell-portable; an unquoted "--session-id $SESSION_ID" string is one argument under zsh). Exit code 1: no sessions in window — surface that, stop; nothing in Step 2b can rescue a missing clock report, since enforce-profile-header.js keys on report.md specifically. Exit code 2 or higher: analyzer error (bad arguments, crash) — surface the ! BLOCKED line with the tail of warnings.log, stop; do not run Step 2b.
PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name foundry) || exit $?; export PLUGIN_ROOT
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
# timeout: 60000
while IFS== read -r K V; do case "$K" in REPORT_DIR) REPORT_DIR=$V;; SINCE) SINCE=$V;; SESSION_ID) SESSION_ID=$V;; TOP_N) TOP_N=$V;; esac; done < "${TMPDIR:-/tmp}/foundry-profile-state-${CSID}"
set --; [ -n "$SESSION_ID" ] && set -- --session-id "$SESSION_ID"
python "$PLUGIN_ROOT/bin/cost_analyzer.py" \
--since "$SINCE" \
--top-n "$TOP_N" \
--output "$REPORT_DIR/cost.md" \
"$@" 2>>"$REPORT_DIR/warnings.log"
COST_EXIT=$?
if [ "$COST_EXIT" -eq 0 ] && [ -s "$REPORT_DIR/report.md" ]; then
printf '\n' >> "$REPORT_DIR/report.md"
cat "$REPORT_DIR/cost.md" >> "$REPORT_DIR/report.md"
fi
echo "cost_exit=$COST_EXIT"
STATUS=complete
[ "$COST_EXIT" -lt 2 ] || STATUS=partial
echo '{"status":"'"$STATUS"'","cost_exit":'"$COST_EXIT"',"since":"'"$SINCE"'","session_id":"'"$SESSION_ID"'","top_n":'"$TOP_N"'}' > "$REPORT_DIR/result.jsonl"
Separate data source (transcripts under ~/.claude/projects/**, not timings.jsonl), separate script, same --since/--session-id/--top-n scoping. cost_exit=1 means no transcripts fell in window (or no match for --session-id) — not fatal: clock report still ships without a ## Tokens & cost section. The two analyzers never share a report path write; only report.md is append-target, only after cost_exit=0, so a cost-side failure can't corrupt or block the clock report.
The last line of the Step 2b block writes $REPORT_DIR/result.jsonl (status: complete for cost_exit 0 or 1, status: partial for a cost analyzer error, plus cost_exit, since, session_id, top_n) — it runs only after Step 2's stop branches passed, exactly as this step did. Surface a cost analyzer error with warnings.log while delivering the clock report.
Build the delivery block: read YAML header from $REPORT_DIR/report.md (first block between --- lines), render as two-column Markdown table (Field | Value, one row per key, file order) per quality-gates.md §Report File Format — never the raw ----delimited block. Then → $REPORT_DIR/report.md. Then read Headline split block plus top 3 sessions from per-session table, and — when a ## Tokens & cost section is present — window total or single-session total cost line, add both as executive summary. Deliver the full block once in the final reply after the answer, after the last tool call — never before the question, never in an option or Bash/tool stdout. The first question's text carries only the report path, Title, Outcome and headline split, plus the cost total when present. Keep the question text to at most 6 plain lines (target 600 characters, hard cap 1,500), with no table, no pipe layout and no code fence. Options have no preview. Step 5 always asks once a report exists; a turn ending without the question still needs the full header table in the final reply, enforced by Stop.
Output-Routing exemption: this report-header follow-up carries a plain summary in the question and the full delivery block in the final reply after the answer. Quality-gates.md §Report File Format's table-first-in-reply rule and Output Routing step 2a do not require a table before the question; the full dump below still goes to
.temp/.
Also Write the long-output dump per quality-gates rule — never overwrite an existing dump; if the path exists, append the first unused counter suffix (-2.md, -3.md, …) before calling Write:
Write(file_path=".temp/output-profile-<branch>-<YYYY-MM-DD>.md", content=<full report contents>)
Where <branch> = $(git branch --show-current 2>/dev/null | tr '/' '-' || echo 'main').
Backed by hooks/enforce-profile-header.js: on Stop it keeps a turn going once per report when the final reply lacks the matching header table. While Step 1 state is live, Step 5's workflow follow-up requires a saved report and a short plain summary in the first question's text naming $REPORT_DIR/report.md, Title and Outcome; reply text and option fields do not supply that summary. Missing/unreadable delivery evidence blocks that transition; apply the placement the deny reason names before retrying. Diagnostic/recovery questions remain available under their own question header, not profile.
Invoke AskUserQuestion (denied by enforce-profile-header.js until Step 2 has written report.md — if the analyzer found no sessions, report that and stop instead of asking):
profileTitle, Outcome, headline split and → $REPORT_DIR/report.md as short plain lines per Step 4; include the cost total when present.--session-id <id>--since 7d, --since 30d)preview./foundry:investigate: investigate diagnoses failures; profile measures wall time when things ran fine but slow.foundry:perf-optimizer: perf-optimizer profiles Python/ML code (CPU/GPU/IO); profile measures Claude Code session wall time.model field is 100% null in current task-log.js payload — clock report doesn't break down by model tier. Documented in report Confidence Gaps. ## Tokens & cost section does break down by tier, but from a different data source (transcripts, not timings.jsonl) — the two never merge into one table.timings.jsonl's hook fires only in main Claude Code process; subagent internal tool calls do NOT hit it, so reasoning bucket underestimates when subagent spawns dominate. Cost side lacks this gap — reads each session's subagents/agent-*.jsonl transcripts directly, so subagent token spend is included, not inferred.duration_ms < 1s (a spawn-only row — every Agent() returns at dispatch) matched against invocations.jsonl started→completed pairs by (agent, desc) substring within ±60s window. Concurrent same-type spawns may mispair.duration_ms > 1h for tool=Bash clipped at 3,600,000 ms to avoid runaway-shell pollution; clip count surfaced in legend.cost_analyzer.py uses each transcript's own row timestamp field for --since cutoff (file mtime is only a cheap pre-filter to skip old files before parsing them), so window is as accurate as clock side's.## Tokens & cost dollar figures are proportional truth (useful for ranking, comparing), not a billing statement — effective plan rates may differ. Per-command session $ also attributes a session's whole cost to every command it ran, so that column ranks, never sums.cost_analyzer.py finds no transcripts in window (or no match for --session-id): exits 1, ## Tokens & cost section simply omitted — clock report still ships.What SKILL.md sets; muted values are Claude Code's defaults
lownpx claudepluginhub borda/ai-rig --plugin foundry11 skills in this plugin
/auditFull-sweep quality audit of .claude/ config — cross-references, permissions, model tiers, docs freshness. Scope tokens select what to audit; --upgrade applies docs-sourced improvements; --adversarial runs foundry:challenger + Codex adversarial review; --efficiency sweeps model tiers, token bloat, spawn patterns, boilerplate duplication, and bin/ extraction candidates (extraction performed separately via /foundry:distill executables); --consolidate proposes merging overlapping narrow rules into fewer broader ones and sharpening overlapping skill notes and agent clauses (advisory, edits nothing). Fix level chosen via conditional follow-up gate after report./brainstormIterative brainstorming skill for turning fuzzy ideas into approved tree documents. Diverges into branches, deepens and prunes them over many rounds, saves a tree doc. Run breakdown on the tree to distill it into a spec via guided questions. SKIP: a content outline to co-create, or one already approved and awaiting finished content (use foundry:create — create co-creates the outline, foundry:creator writes the finished artifact; brainstorm is for idea generation before an outline exists); a code-level implementation plan derived from an existing spec (use develop:plan (requires `develop` plugin))./calibrateCalibration testing for agents and skills. Generates synthetic problems with known outcomes (quasi-ground-truth), runs targets against them, measures recall, precision, confidence calibration — reveals whether self-reported confidence scores track actual quality./createInteractive outline co-creation for developer advocacy content — collects format, audience profile, story arc (Problem→Journey→Insight→Action), and voice/tone; detects out-of-scope requests (FAQs, comparison tables); surfaces conflicts between user brief and audience needs. Writes approved outline to .plans/content/<slug>-outline.md for foundry:creator to execute. Use when starting a blog post, Marp slide deck, social thread, talk abstract, lightning talk, animated SVG, or short video (HyperFrames HTML composition; render stays user-run). SKIP: idea generation before an outline exists (use foundry:brainstorm — brainstorm explores directions into a tree; create co-creates the outline, foundry:creator writes the finished artifact)./distillOne-time snapshot extracting patterns from work history and accumulated lessons, distills into concrete improvements — new agent/skill suggestions, memory pruning, consolidating lessons into rules/agent updates, or performing bin/ extraction from /foundry:audit --efficiency candidates. Roster boundary analysis → /foundry:audit agents (Check 46)./humanizerStrip AI-writing tells from prose destined for humans — docs, PR/commit bodies, reports, release notes, blog posts, Slack/email drafts. Removes LLM-vocabulary clichés (delve, boasts, testament, underscore, robust, tapestry...), banned constructions (not just X but Y, rule-of-three triads, "-ing" superficial-analysis clauses, vague-attribution weasel words), and formatting tells (title-case headings, mechanical bolding, em-dash overuse, curly quotes, bare-bullet inline-header lists). TRIGGER when: user asks to humanize/polish/de-AI a piece of text or file; before finalizing a substantial human-facing prose artifact drafted as part of the current task (docs, PR/commit body, report, blog post, release notes, external message) — self-review pass, best-effort model-initiated, not a guaranteed intercept. SKIP when: output is a terse conversational chat reply, code, JSON/YAML/config, a machine-parsed agent envelope ("Return ONLY:"), a `.reports/` file or a file with report-schema frontmatter (report format needs the block and bold labels intact), or the target is an ultra-caveman-tier handover file (`.temp/`, inter-agent prose per `plugins/CLAUDE.md` compression tiers). Preserve ordinary publishing frontmatter and edit only the prose body.Other plugins' skills for the same job