prompt-history-backfill
Scan Claude and Codex conversation history for skill invocation prompts missing from repo prompt history and report or backfill them safely
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- prompt-history-backfill
- type
- analysis
- version
- v0.1
- description
- Scan Claude and Codex conversation history for skill invocation prompts missing from repo prompt history and report or backfill them safely
- argument-hint
- [--repo <path>] [--skill <slug>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--apply] [history/export paths...]
03 SKILL.md 正文
Prompt History Backfill
Invoke as /prompt-history-backfill.
Use this skill when the user wants to audit or backfill prompts/<skill-slug>/ prompt-history artifacts from local Claude Code and Codex conversation history. The skill identifies visible user prompts that invoked skills, compares them with the target repository's prompt-history convention, and produces a reviewable report by default.
Inputs
- Default target repository: current working directory.
- Optional
--repo <path>to target another repository. - Optional
--skill <slug>to limit detection and output to one skill. - Optional
--since YYYY-MM-DDand--until YYYY-MM-DDfilters. - Optional user-provided history files, exported logs, or session directories.
- Default Claude history file:
~/.claude/history.jsonl. - Default Codex prompt history file:
~/.codex/history.jsonl. - Default Codex rich session root:
~/.codex/sessions/**/*.jsonl.
Process
-
Resolve arguments and mode:
- Default mode is report-only.
- Do not create, modify, or remove prompt files unless the visible invocation includes explicit
--apply. - In report-only mode, prompt backfill candidates are reviewed but no files under
prompts/<skill-slug>/are created.
-
Resolve known skills in the target repo:
- Read active non-archive
SKILL.mdfiles underglobal/,packs/,.claude/skills/, and.codex/skills/when present. - Include existing
prompts/<skill-slug>/directories as known prompt-history targets. - Maintain a hardcoded legacy skill map for slugs that no longer exist as active skills:
run— renamed →execreview— renamed →expert-reviewskill-creator— split/renamed →create-agentic-skill+create-local-skillverify— never a skill (native tool)simplify— never a skill (native tool)schedule— never a skill (native tool)
- Apply
--skill <slug>before writing or reporting candidate rows when provided.
- Read active non-archive
-
Read conversation history:
- Read all existing default sources for the selected date range:
~/.claude/history.jsonl,~/.codex/history.jsonl, and~/.codex/sessions/**/*.jsonl. - Read optional user-provided history/export paths in addition to the defaults unless the user explicitly says to use only those paths.
- If a source is missing or unreadable, report it and continue with available sources.
- Read all existing default sources for the selected date range:
-
Normalize records into visible user prompt candidates only:
- Claude compact history: use visible user-facing fields such as
display, timestamp, project, session ID, and directly pasted visible context such aspastedContents. - Codex compact history: use prompt
text, timestamp, session ID, and cwd/project metadata when available. - Codex rich session JSONL: include user
response_itemrecords only when they are user-authored messages. - Exclude hidden system instructions, hidden developer instructions, base prompts, tool output, tool arguments, assistant messages, unavailable model context, and generated summaries.
- Claude compact history: use visible user-facing fields such as
-
Classify candidate confidence:
- High confidence: the visible user prompt begins with or clearly invokes
/skill-name,$skill-name, orYou have the <skill> skill installed. - Medium confidence: the visible user prompt names a known skill and asks the agent to use it, but does not use command syntax.
- Low confidence: the prompt only loosely mentions a skill or workflow. Include it in the report, but never write it even when
--applyis present. - When a candidate's skill slug matches a legacy skill map entry, tag it as
legacy: truein addition to its confidence level.
- High confidence: the visible user prompt begins with or clearly invokes
-
Compare against existing prompt history:
- For each high- or medium-confidence candidate, inspect
prompts/<skill-slug>/. - Skip an existing identical prompt file when the preserved visible prompt text and required frontmatter already match.
- When a timestamp filename collides with different content, add a deterministic short session suffix while preserving the base
skill-prompt-YYYYMMDD-HHMMSS-<short-topic>filename shape.
- For each high- or medium-confidence candidate, inspect
-
Block likely secrets before writing:
- Before any
--applywrite, scan candidate prompt text for likely secrets such as API keys, bearer tokens, private keys, cookie/session tokens, password assignments, credential-bearing URLs, database URLs, and common provider token prefixes. - If a candidate contains a likely secret, do not write it. Mark it as blocked in the report and ask the user for a sanitized prompt.
- Before any
-
Write outputs:
- In report-only mode, write a review artifact at
alignment/prompt-history-backfill-{topic}.htmlfollowingALIGNMENT-PAGE.md, plus a concise chat summary. - In
--applymode, create missing prompt files underprompts/<skill-slug>/for active skills, or underprompts/legacy/<old-slug>/for legacy skills. - Legacy skill prompt files add
legacy: trueand optionalsuccessor: <new-slug>to their YAML frontmatter (successor is included when the legacy map has a renamed/split successor). - Use this YAML frontmatter exactly for every backfilled prompt file:
skill,agent,captured_at,source, andprompt_scope: visible-user-invocation. - Use
source: user-invocationunless the user explicitly requests a more specific visible source label; put history file paths and session IDs in the report, not in prompt frontmatter. - Preserve the exact visible user prompt content after frontmatter without summarizing, redacting, or truncating.
- In report-only mode, write a review artifact at
Output
The report should include:
- Scope: repository, filters, sources read, sources missing, and mode.
- Candidate summary by confidence, skill slug, source agent, timestamp, session ID, and status.
- Missing prompt files that would be created in report-only mode.
- Prompt files created in
--applymode. - Existing identical prompt files skipped.
- Filename collisions and deterministic suffixes used.
- Low-confidence candidates excluded from writes.
- Likely-secret candidates blocked, with a sanitized-prompt request.
- Verification notes proving no hidden system/developer/tool output was used and all prompt writes stayed under
prompts/<skill-slug>/.
Constraints
- Report-only is the safe default;
--applyis the only write mode for prompt files. - Never write low-confidence candidates.
- Never write likely-secret candidates.
- Never write prompt files outside
prompts/<skill-slug>/(active skills) orprompts/legacy/<old-slug>/(legacy skills). prompts/legacy/<old-slug>/is the only valid write path for legacy skill prompts; never create top-levelprompts/<old-slug>/directories for legacy skills.- Do not summarize, redact, or truncate the visible prompt body in backfilled prompt files.
- Do not include hidden system/developer instructions, tool output, assistant messages, or unavailable model context in prompt files.
- Do not create or modify GitHub Actions workflows.
Alignment Page
When this skill produces durable deliverables (research, specs, plans, reports, prototypes, or any document output), build a full-depth HTML alignment page following ALIGNMENT-PAGE.md in this skill's directory. Output: alignment/prompt-history-backfill-{topic}.html.
Default Shipping Contract
Follow the shared shipping contract convention in CLAUDE.md.
04 同仓库更多 Skills
source-checkout-allowed
Valid source-checkout-only fixture.
deck-install-valid
Valid deck install fixture.
codex-pack-guard-valid
Valid Codex Pack Availability Guard fixture.
codex-missing-skill-valid
Valid Codex missing skill fallback fixture.
codex-base-skill-fallback-valid
Valid Codex base skill fallback fixture.
claude-pack-guard-valid
Valid Claude Pack Availability Guard fixture.