claude-code - 💡(How to fix) Fix [BUG] session-meta records 'Unknown skill' error as first_prompt, polluting /insights telemetry [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46958Fetched 2026-04-12 13:28:40
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4subscribed ×1unsubscribed ×1

When a slash command fails with Unknown skill: X (for example, invoking a plugin command before /reload-plugins, or hitting a regression like #42073), Claude Code writes a session-meta record where the first_prompt field is literally set to the error string. The session is otherwise empty (zero tokens, zero tool calls, zero duration), and both user_message_timestamps entries are identical to the millisecond, indicating the error was captured back as a user input on top of the actual input.

Error Message

When a slash command fails with Unknown skill: X (for example, invoking a plugin command before /reload-plugins, or hitting a regression like #42073), Claude Code writes a session-meta record where the first_prompt field is literally set to the error string. The session is otherwise empty (zero tokens, zero tool calls, zero duration), and both user_message_timestamps entries are identical to the millisecond, indicating the error was captured back as a user input on top of the actual input. 35 such polluted records exist locally. The duplicate millisecond timestamps are the signal that two writes happened in the same millisecond. One was the real user input, the second was the agent re-ingesting its own error echo. When a slash command fails with Unknown skill, the failure should be recorded as an error event (or the session-meta first_prompt should still reflect the user's actual intended input). Error strings from the agent should not be recorded as if the user typed them. first_prompt is overwritten with the error string. /insights and any third-party insights consumer (ccusage, ClaudeUsageTracker, phuryn/claude-usage) see "Unknown skill: plugin" as the user's first prompt. Real user intent is erased. 4. Combines with related pain. When slash commands fail, the user's real message gets swallowed (related to #32591 pattern) while the error gets recorded. Double erasure.

  • insights first_prompt error captured, stderr captured as first_prompt, session-meta error prompt captured, insights telemetry Unknown skill first_prompt, insights Unknown skill pollutes all return zero results.
  • Reviewed #34857, #32227, #27426, #24039, #28341. All about write races, Windows EBUSY, facet generation. None capture the error as prompt behavior.
  1. Stop writing error strings into the first_prompt field of session-meta.
  2. Preserve the user's real first prompt even when the session terminates on a slash command error.
  3. If error telemetry is wanted, record it in a separate session_errors field rather than overwriting user input.

Root Cause

  1. /insights aggregation is polluted. "Unknown skill" appears as a visible first prompt in session lists and rollups.
  2. Obscures root cause. The underlying problem (failed slash command) is hidden behind a telemetry artifact that looks like the user typed gibberish.
  3. Privacy adjacent. Errors from local plugin state leak into the persisted usage log with no scrubbing option.
  4. Combines with related pain. When slash commands fail, the user's real message gets swallowed (related to #32591 pattern) while the error gets recorded. Double erasure.

Code Example

{
  "session_id": "0315a816-3a6d-448b-835d-fcfbcd22001d",
  "user_message_count": 2,
  "assistant_message_count": 0,
  "tool_counts": {},
  "input_tokens": 0,
  "output_tokens": 0,
  "first_prompt": "Unknown skill: plugin",
  "user_message_timestamps": [
    "2026-04-02T22:23:21.606Z",
    "2026-04-02T22:23:21.606Z"
  ]
}

---

$ ls ~/.claude/usage-data/session-meta/*.json | xargs grep -l '"first_prompt": "Unknown skill' | wc -l
35
RAW_BUFFERClick to expand / collapse

Summary

When a slash command fails with Unknown skill: X (for example, invoking a plugin command before /reload-plugins, or hitting a regression like #42073), Claude Code writes a session-meta record where the first_prompt field is literally set to the error string. The session is otherwise empty (zero tokens, zero tool calls, zero duration), and both user_message_timestamps entries are identical to the millisecond, indicating the error was captured back as a user input on top of the actual input.

Evidence

Local reproduction on a 2026 Claude Code install. File ~/.claude/usage-data/session-meta/0315a816-3a6d-448b-835d-fcfbcd22001d.json:

{
  "session_id": "0315a816-3a6d-448b-835d-fcfbcd22001d",
  "user_message_count": 2,
  "assistant_message_count": 0,
  "tool_counts": {},
  "input_tokens": 0,
  "output_tokens": 0,
  "first_prompt": "Unknown skill: plugin",
  "user_message_timestamps": [
    "2026-04-02T22:23:21.606Z",
    "2026-04-02T22:23:21.606Z"
  ]
}

Verified count on this machine:

$ ls ~/.claude/usage-data/session-meta/*.json | xargs grep -l '"first_prompt": "Unknown skill' | wc -l
35

35 such polluted records exist locally. The duplicate millisecond timestamps are the signal that two writes happened in the same millisecond. One was the real user input, the second was the agent re-ingesting its own error echo.

Expected behavior

When a slash command fails with Unknown skill, the failure should be recorded as an error event (or the session-meta first_prompt should still reflect the user's actual intended input). Error strings from the agent should not be recorded as if the user typed them.

Actual behavior

first_prompt is overwritten with the error string. /insights and any third-party insights consumer (ccusage, ClaudeUsageTracker, phuryn/claude-usage) see "Unknown skill: plugin" as the user's first prompt. Real user intent is erased.

Impact

  1. /insights aggregation is polluted. "Unknown skill" appears as a visible first prompt in session lists and rollups.
  2. Obscures root cause. The underlying problem (failed slash command) is hidden behind a telemetry artifact that looks like the user typed gibberish.
  3. Privacy adjacent. Errors from local plugin state leak into the persisted usage log with no scrubbing option.
  4. Combines with related pain. When slash commands fail, the user's real message gets swallowed (related to #32591 pattern) while the error gets recorded. Double erasure.

Why existing issues do not cover this

Searched these angles, none match:

  • session-meta first_prompt returns only #34857 (non-atomic write corruption) and #32227 (EBUSY on Windows). Different mechanism.
  • usage-data session-meta same two issues plus unrelated insights display bugs.
  • insights first_prompt error captured, stderr captured as first_prompt, session-meta error prompt captured, insights telemetry Unknown skill first_prompt, insights Unknown skill pollutes all return zero results.
  • Reviewed #34857, #32227, #27426, #24039, #28341. All about write races, Windows EBUSY, facet generation. None capture the error as prompt behavior.

Related but distinct:

  • #42073 (commands regression in 2.1.89) triggers the Unknown skill path.
  • #44756 (skills silently fail in --print mode) another trigger.
  • #32591 swallows user messages after slash command fail.
  • None describe the telemetry side of the bug.

Request

  1. Stop writing error strings into the first_prompt field of session-meta.
  2. Preserve the user's real first prompt even when the session terminates on a slash command error.
  3. If error telemetry is wanted, record it in a separate session_errors field rather than overwriting user input.
  4. Document the session-meta schema so third-party insights consumers know what to expect.

Suggested labels: bug, area:cost, data-loss

extent analysis

TL;DR

Stop writing error strings into the first_prompt field of session-meta to prevent pollution of /insights aggregation and preserve the user's real first prompt.

Guidance

  • Identify and modify the code responsible for writing the first_prompt field in session-meta records to exclude error strings.
  • Consider introducing a separate session_errors field to record error telemetry without overwriting user input.
  • Review and update the session-meta schema documentation to reflect the expected format and fields for third-party insights consumers.
  • Investigate related issues (#42073, #44756, #32591) to ensure that the root causes of slash command failures are addressed.

Example

No specific code snippet is provided, but the fix likely involves modifying the code that handles slash command errors and updates the session-meta records.

Notes

The exact implementation details may vary depending on the underlying codebase and technology stack. It is essential to carefully review and test the changes to ensure that the fix does not introduce new issues.

Recommendation

Apply a workaround to stop writing error strings into the first_prompt field, as this will immediately prevent pollution of /insights aggregation and preserve the user's real first prompt. This change can be made while investigating and addressing the root causes of slash command failures.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a slash command fails with Unknown skill, the failure should be recorded as an error event (or the session-meta first_prompt should still reflect the user's actual intended input). Error strings from the agent should not be recorded as if the user typed them.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING