Skip to content

[Bug]: Claude Code prompts not saved #2293

Description

@MattiaSilvestri

What broke?

git ai blame --json correctly attributes lines to the Claude Code session/turn that wrote them, and the resulting prompts object is populated with agent_id, human_author, other_files, and commits. However:

  • total_additions, total_deletions, accepted_lines, and overriden_lines are always 0, even for a prompt that produced 60+ attributed lines.
  • git ai show-prompt <prompt_id> --commit <sha> returns the same prompt object but with no messages field at all — despite prompt_storage being explicitly set to "notes" before the commit was made.

This looks related to #1475 (closed) — same general area (prompt/transcript content not persisting into the git note), but a different manifestation: instead of an empty prompts: {}, the prompt record exists and is correctly linked to the right lines/commit, just missing the content-bearing fields. Also, mine is Claude Code specifically, not Codex/Copilot, and the prompt IDs are in the session::turn composite format rather than the flat hex ID shown in the docs' own example output.

Steps to reproduce

  1. Install/update git-ai to latest, confirm with git-ai --version → 1.7.0
  2. git ai config set prompt_storage notes
  3. Start a Claude Code session in a repo, ask it to edit a file (e.g. multi-line edit across ~60 lines)
  4. Commit the change
  5. Run git ai blame <file> --json → lines are correctly attributed to the new session/turn
  6. Run git ai show-prompt "<prompt_id>" --commit <commit_sha> on that prompt ID

Expected vs actual behavior

Expected: show-prompt returns a populated messages array with the actual prompt/response transcript, and the prompts object in blame --json reflects real total_additions/accepted_lines matching the attributed line count.

Actual:

blame --json output (I asked claude to anonymize the data):

{
  "lines": {
    "44-104": "s_aaaaaaaaaaaaaa::t_bbbbbbbbbbbbbb"
  },
  "prompts": {
    "s_aaaaaaaaaaaaaa::t_bbbbbbbbbbbbbb": {
      "agent_id": { "tool": "claude", "id": "00000000-0000-0000-0000-000000000000", "model": "claude-opus-5" },
      "human_author": "Test User <test.user@example.com>",
      "total_additions": 0,
      "total_deletions": 0,
      "accepted_lines": 0,
      "overriden_lines": 0,
      "other_files": [],
      "commits": ["0000000000000000000000000000000000000a"]
    }
  }
}

show-prompt output for the same commit/prompt ID:

{
  "commit": "0000000000000000000000000000000000000a",
  "prompt": {
    "accepted_lines": 0,
    "agent_id": { "id": "00000000-0000-0000-0000-000000000000", "model": "claude-opus-5", "tool": "claude" },
    "human_author": "Test User <test.user@example.com>",
    "overriden_lines": 0,
    "total_additions": 0,
    "total_deletions": 0
  },
  "prompt_id": "s_aaaaaaaaaaaaaa::t_bbbbbbbbbbbbbb"
}

No messages field present at all.

Diagnostics (git-ai debug)

runtime_config:
    {
      "git_path": "/usr/bin/git",
      "exclude_prompts_in_repositories": [],
      "include_prompts_in_repositories": [],
      "allow_repositories": [],
      "exclude_repositories": [],
      "telemetry_oss_disabled": false,
      "telemetry_enterprise_dsn": null,
      "disable_version_checks": false,
      "disable_auto_updates": false,
      "update_channel": "latest",
      "feature_flags": {
        "lite_mode": false,
        "auth_keyring": false,
        "transcript_streaming": true,
        "transcript_sweep": true,
        "checkpoint_debug_log": false,
        "bash_checkpoints_v2": false,
        "daemon_log_upload": true,
        "rewrite_metrics_events": false,
        "token_usage_metrics": false
      },
      "api_base_url": "https://usegitai.com",
      "prompt_storage": "notes",
      "default_prompt_storage": null,
      "api_key": null,
      "quiet": false,
      "allow_superuser": false,
      "author": {},
      "custom_attributes": {},
      "git_ai_hooks": {},
      "codex_hooks_format": "config_toml",
      "notes_backend": {
        "kind": "git_notes",
        "backend_url": "https://usegitai.com"
      },
      "transcript_streaming_lookback_days": 7,
      "max_checkpoint_file_size_bytes": 3145728,
      "max_checkpoint_total_size_bytes": 33554432,
      "max_checkpoint_total_lines": 500000,
      "daemon_memory_limit_mb": null
    }

== Git AI Login ==
Credential backend: file
Status: logged out

== Git Environment ==
No GIT_AI_*, GITAI_*, or GIT_* environment variables are set.

Extra context (optional)

  • prompt_storage was confirmed set to "notes" (not "default") before the commit in question was made, so this isn't the "changed setting doesn't retroactively backfill old commits" case.
  • notes_backend.kind is "git_notes" (local), not "http".
  • Tested on a fresh commit specifically to rule out the config-not-applied-yet explanation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions