Skip to content

feat(ai): add devops ai agent-audit for recurring problems #2346

Closed

Description

@dan-petty

Problem or Motivation

Agents do most of the work on this project, and the same problems come back in session after session. Nobody counts them. A warning that every uv run prints, a command that agents get wrong in the same way, a check that agents run again and again, or a manual sequence that should be one command: each costs time in every session, and none of it reaches an issue until a person notices.

One session showed the pattern. In it, the same VIRTUAL_ENV ... does not match the project environment path warning appeared in the output of every uv run from a worktree. An unquoted glob (--include=*.py) failed twice with no matches found. A test run ended with exit status 1 because a file changed during the run (the workspace tripwire). None of these was counted, and AGENTS.md rule 11 says that each failure or warning of a devops command becomes an issue.

The data exists on this host, and only part of it can answer the question:

  • Claude Code transcripts: ~/.claude/projects/<project>/*.jsonl. This project has 22 session files, and the oldest is 30 days old, so older ones are already gone. Each line is a record. Tool calls and their results are in the records, and Bash is 202 of the 243 tool calls of the newest file. This is the only source that holds a command together with its output and its failure.
  • Shell history: ~/.zsh_history has 1219 lines, 883 in the extended format : <epoch>:<seconds>;<command>. It holds no exit status, so it shows repeated commands and not failures.
  • .data/logs/audit.jsonl: 420 records of 4 distinct commands. It is a config audit trail, not a command history.
  • Agent files: .data/agent/ (45 entries) holds logs, scripts and bodies that agents wrote.
  • Other agent tools keep their own histories (~/.gemini/antigravity holds protobuf files). Their formats differ, and they are out of scope here.

Proposed Solution & Architectural Design

Add devops ai agent-audit [--since <days>] [--source transcripts|shell|files|all] [--repo-dir <path>] [--json] [--plan|--confirm] [--dry-run].

1. A deterministic stage that uses no model. It follows the review direction: tools find, a model only groups.

  • Read the sources on this host only. For transcripts, read the directories of the repository and of its worktrees. Tolerate record types it does not know: the files already hold api-request-blob and atis-latch, which this repository does not describe.
  • Reduce each command to a signature (the program, the subcommand and the flags, with paths, numbers and values replaced) and each failure to an error signature (the exit status and the first error line, normalized).
  • Count, across sessions and not only inside one: failing signatures, warning lines that repeat in outputs, the same command run again with small changes, commands over the 5-minute budget of AGENTS.md rule 5, permission denials, and devops failures or warnings that no open issue names.
  • Rank by recurrences, sessions and time spent. Each finding carries pointers (file, line, time) and never raw text.

2. Privacy first. A transcript holds prompts, file contents and possibly secrets and personal data.

  • The read stage runs mask_secrets (security/sanitizer.py) on every line it keeps. Nothing leaves this host, and the report holds signatures, not transcripts.
  • The audit stores only counts and pointers in .data/agent/audit/<date>.json, never a copy of a transcript. Because transcripts expire after 30 days, the stored counts keep the trend. A second run counts a session and a line once.

3. An optional model stage. It calls one devops ai model at a time (AGENTS.md rule 13). The model gets the redacted signatures. It groups related findings and drafts an issue body in the shape of feature_request.yml or bug_report.yml.

4. Modes as in the rest of the project. Without a mode flag the command prints the report and files nothing (--plan). --confirm files each draft through devops roadmap intake, which flags a possible duplicate and never drops a candidate. --dry-run makes no request, to a model or to GitHub, and lists the requests a run makes. A run with --dry-run and --confirm is refused.

Acceptance criteria (each one runs offline on fixture transcripts):

  1. A failing signature that occurs in three sessions appears once, with a count of 3 and a pointer for each session.
  2. A secret in a fixture line is masked in the report and in the stored counts.
  3. A record type that the parser does not know does not stop the run.
  4. A second run over the same files does not change the stored counts.
  5. A devops warning that an open issue names is not reported as new.
  6. --dry-run reads no file outside the named sources and makes no request.

Out of scope: the histories of other agent tools, a schedule for the audit, and the fix of any finding. Each finding becomes its own issue.

Target Subsystem

AI & Agentic Review Pipeline

Existing Tool Considered

  • /insights of Claude Code scans the local sessions and asks a Claude model to write an HTML usage report. It sends session content to a model, covers Claude Code only, does not know the commands or the issues of this project, and files nothing.
  • agent-forensics, claude-session-analyzer (lucemia), claude-code-stats, claude-token-analyzer and Claudoscope (a macOS application) read the same JSONL files. They report cost, tool use and behavior signals for one session or one user. None of them matches an error signature across sessions to the commands of a project, and none of them files an issue. Claudoscope runs on macOS only. The change could take a parser from one of them, but the file is one JSON object per line and the standard library reads it, so no parser dependency is needed.
  • atuin keeps shell history in SQLite with the exit status and the duration, and atuin stats ranks commands. It needs a host install. Its import of the existing zsh history has no exit status either, and the transcripts already hold the commands that agents ran, with their output and their failures. The change does not use it.
  • Cost of building, as an estimate: about 200,000 tokens and one working day for the reader, the signatures, the ranking and the tests. About 20,000 tokens a quarter to follow changes of the undocumented transcript format. The tools above cannot give the match to this project's commands and issues, which is the value of the audit.

Alternatives check of 2026-11-03: partly.
Tool: daaain/claude-code-log (https://github.com/daaain/claude-code-log), MIT, last activity 2026-11-03, maintained.

Proposed design

Problem statement

Agents on this project meet the same problems in session after session. A warning, a failed command, or a repeated manual sequence costs time every time, and nothing counts these problems, so none reaches an issue until a person notices. This issue adds devops ai agent-audit. The command reads local Claude Code transcripts, reduces commands and failures to signatures, and counts recurrences across sessions. It can group the findings with one model and file drafts through devops roadmap intake.

Acceptance criteria

Requirement: Cross-session failure count

The audit SHALL report a failing signature that occurs in three sessions as one finding with a count of 3.

Scenario: Same failure in three sessions

  • WHEN The audit reads three fixture transcripts that each hold the same failing command with the same exit status and first error line.
  • THEN The report holds one finding for that signature, the count is 3, and the finding holds three pointers, one for each session file.

Requirement: Secret masking in report and store

The audit SHALL mask every secret in a kept line before it writes the report or the stored counts.

Scenario: GitHub token in a transcript line

  • WHEN A fixture transcript line holds a ghp_ token.
  • THEN The report and the stored counts file hold <masked-github-token> and no ghp_ token.

Requirement: Unknown record type

The audit MUST continue when it reads a record type that the parser does not know.

Scenario: Unknown record type before a known record

  • WHEN A fixture transcript holds a record of type api-request-blob before a record of a known type.
  • THEN The run exits 0 and the report holds the finding from the known record.

Requirement: Idempotent stored counts

The audit SHALL keep each signature's count unchanged when a second run reads the same session and line.

Scenario: Second run over the same files

  • WHEN Two runs read the same fixture files on the same date.
  • THEN The stored counts file holds the same count for each signature after each run.

Requirement: Warning named by an open issue

The audit SHALL NOT report a devops warning as a new finding when an open issue names that warning.

Scenario: Warning named by an open issue

  • WHEN A fixture warning matches the title or body of an open issue that the stub GitHub client returns.
  • THEN The warning is absent from the new findings and the report marks it as tracked.

Requirement: Dry run makes no request

A run with --dry-run MUST make no request to a model or to GitHub and MUST read no file outside the named source.

Scenario: Dry run over a fixture

  • WHEN The audit runs with --dry-run over a fixture directory.
  • THEN The stub clients record no call and every opened path is under the fixture directory.

Requirement: Refused flag pair

The command MUST refuse a run that holds both --dry-run and --confirm.

Scenario: Dry run with confirm

  • WHEN The audit runs with --dry-run and --confirm.
  • THEN The command exits with a usage error and files no issue.

Requirement: Model stage grouping

The model stage SHALL send only masked signatures to one devops ai model and SHALL attach the returned groups to the findings.

Scenario: Grouping with a stub model

  • WHEN The audit runs with a stub model client that records its request.
  • THEN The request holds no raw transcript line and the report holds the group that the stub returns.

Requirement: Ranking by sessions

The audit SHALL rank a finding with more sessions above a finding with fewer sessions.

Scenario: Two signatures with different session counts

  • WHEN A fixture holds signature A in three sessions and signature B in one session.
  • THEN Signature A comes before signature B in the report.

Requirement: Default source

The audit SHALL read only Claude Code transcripts when the run names no --source.

Scenario: No source flag

  • WHEN The audit runs over a fixture directory with no --source flag and a shell-history fixture sits beside the transcripts.
  • THEN The report holds the transcript finding and the shell-history fixture is never opened.

Existing Tool Considered

daaain/claude-code-log (https://github.com/daaain/claude-code-log, MIT, last commit 2026-11-11, maintained) reads Claude Code JSONL transcripts, one file or a whole ~/.claude/projects/ hierarchy, filters by date range and emits JSON for tooling. It lacks command and error signatures, cross-session counting and ranking, secret masking before output or storage, the check against open issues, shell-history and agent-file sources, and the --plan, --confirm and --dry-run modes. No other checked tool covers these either. The plan keeps the item and builds the reader, the signatures, the ranking and the issue match. The standard library reads one JSON object per line, so no parser dependency is needed. Cost to build: about 200,000 tokens and one working day for the reader, the signatures, the ranking and the tests. Cost to keep and fix: about 20,000 tokens a quarter, to follow changes of the undocumented transcript format.

Key questions

  • What is the format of a Claude Code transcript file?: JSON Lines. Each line is one JSON object that holds a record. The records hold user and assistant messages, tool use and tool results, thinking content and images. The project directories sit under ~/.claude/projects/, and a directory name is the project path with its separators turned into dashes. The files hold record types that this repository does not describe, so the parser must skip a type it does not know. [sources: https://github.com/daaain/claude-code-log]
  • Where is mask_secrets defined and what does it mask?: It is defined at src/devops_cli/security/sanitizer.py:454 and imported as devops_cli.security.sanitizer.mask_secrets. It masks a GitHub token such as ghp_ as <masked-github-token>. It masks the other credential patterns of the module. [sources: src/devops_cli/security/sanitizer.py:454, docs/ROUTINE_TASKS.md:98]
  • What is the default mode when the command gets no mode flag?: --plan. The command prints the report and files nothing. A run that files issues needs --confirm, as devops roadmap intake does. (best practice) [sources: docs/ROUTINE_TASKS.md:86, CHANGELOG.md:3362]
    • Chosen: --plan by default. The report alone changes nothing, and the project's writing commands file only under --confirm, so a person keeps the decision to file issues.
    • Rejected: --confirm by default. An audit run would file issues with no review of the drafts.
    • Rejected: Refuse a run with no mode flag. The report alone is useful and makes no request.
  • Can --dry-run and --confirm be combined in one run?: No. The command refuses the run with a usage error and makes no request. devops roadmap return already refuses --dry-run with --confirm, and a dry run sends no external request and prints the requests a real run would send. (best practice) [sources: CHANGELOG.md:3362, ARCHITECTURE.md:170]
    • Chosen: Refuse the pair. A dry run makes no request and --confirm files issues, so the two flags contradict, and the project already refuses this pair on devops roadmap return.
    • Rejected: Let --dry-run win. The run would silently ignore --confirm and file nothing.
    • Rejected: Let --confirm win. The run would make the requests that --dry-run forbids.
  • Where does the audit store its results?: In .data/agent/audit/<YYYY-MM-DD>.json. The file holds counts, signatures and pointers, never a transcript line. .data/agent/ is the agent data directory and it is gitignored, so no private data reaches the repository. (best practice) [sources: AGENTS.md:20, CONTRIBUTING.md:196]
    • Chosen: A daily JSON file under .data/agent/audit/. AGENTS.md rule 12 puts agent files under .data/agent/, and JSON needs no new dependency.
    • Rejected: A SQLite database. It adds a schema and a migration for a small daily file.
    • Rejected: A copy of each transcript. A transcript holds secrets and personal data.
  • What does the optional model stage produce?: It groups related signatures and drafts an issue body in the shape of .github/ISSUE_TEMPLATE/feature_request.yml or bug_report.yml. It calls one devops ai model at a time. The model gets masked signatures only, and it never creates or ranks a finding. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, .github/ISSUE_TEMPLATE/feature_request.yml, .github/ISSUE_TEMPLATE/bug_report.yml, AGENTS.md:21]
    • Chosen: The model groups and drafts. ADR 0005 puts the finding in the tools and lets a model explain and plan from them.
    • Rejected: The model finds and ranks the problems. ADR 0005 rejects model-found defects.
    • Rejected: No model stage. A person reads a grouped report faster than a flat list, and the stage is optional.
  • Which sources does the command read by default?: Claude Code transcripts only. The --source flag takes shell, files or all to add the shell history and the agent files. The transcripts are the only source that holds a command together with its output and its failure, and the shell history and agent files hold no exit status and can hold personal data, so a default run reads the one source that carries the signal. (best practice) [sources: AGENTS.md:18, SECURITY.md:40, ARCHITECTURE.md:170]
    • Chosen: Transcripts only. It is the only source that pairs a command with its output and exit status, and the default read stays as small as the signal needs. --source all opts in to the wider host files.
    • Rejected: All three sources. A default run would read the whole shell history and .data/agent/ on every audit, which adds personal data and repeated commands but no exit status.
    • Rejected: Require one source on each run. It adds a flag to the common run and hides the source that carries the value.
  • How does the audit keep a transcript private?: The read stage runs mask_secrets on every kept line. The store holds counts, signatures and pointers only. No transcript leaves the host, and a secret or personal data never goes to a model. (best practice) [sources: src/devops_cli/security/sanitizer.py:454, SECURITY.md:40, AGENTS.md:18]
    • Chosen: Mask each kept line and store counts. The report needs the signature, not the text, and the store keeps no private data.
    • Rejected: Store the transcripts. A transcript holds prompts, file contents and possibly secrets.
    • Rejected: Send raw lines to the model. A raw line can hold a secret or personal data, and SECURITY.md rule 13 forbids that, while the model needs the signature only.
  • How does the audit know that an open issue names a warning?: It reads the open issues of the repository. It matches the normalized warning text against their titles and bodies. A match marks the warning as tracked and keeps it out of the new findings. (best practice) [sources: AGENTS.md:19]
    • Chosen: Match the title and the body. A warning is often named in the body, not in the title.
    • Rejected: Match the title only. It reports a tracked warning as new and files a duplicate.
    • Rejected: Do not check the issues. AGENTS.md rule 11 asks for a comment on a matching issue, not a duplicate.
  • Does an open, maintained tool cover the audit?: No. daaain/claude-code-log reads the JSONL transcripts, filters by date and emits JSON, and it is maintained. It has no command or error signatures, no cross-session counts or ranking, no masking, no open-issue check, no shell-history or agent-file source and no filing or mode flags. The audit keeps the item and builds the reader and the signatures on the standard library. (best practice) [sources: https://github.com/daaain/claude-code-log]
    • Rejected: Use daaain/claude-code-log as the audit. It lacks the match to this project's commands and issues, which is the value of the audit.
    • Chosen: Build the reader and the signatures. The standard library reads JSONL, and the signatures and the issue match are the new work.
    • Rejected: Use atuin for the shell history. It needs a host install, and its import of the existing zsh history has no exit status.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    on Oct 27, 2026
  2. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/feature. The candidate proposes a new command-line tool feature for AI agent auditing.
    • Priority: P2-Medium. This feature adds value by identifying recurring problems in agent sessions and can improve developer productivity.
    • Value: High. The feature helps identify recurring issues and patterns, which can significantly reduce time spent on repeated problems.
    • Effort: Medium. Implementing the command requires integrating with existing AI tools, parsing various data sources, and building a reporting system.
    • Related: feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137, which asks for a different change. Both items involve AI tools and code review, but the candidate focuses on auditing agent transcripts while item 1137 focuses on evidence-first code review.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at bb46660 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • What is the transcript file format? (missing verified source)
  4. added
    priority/p2-medium
    status/new
    effort/medium
    value/high
    scope/ai
    on Oct 28, 2026
  5. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Tool: daaain/claude-code-log (https://github.com/daaain/claude-code-log)

    • License: MIT
    • Last activity: 2026-11-03
    • Maintained: yes

    Covers:

    • Reads Claude Code JSONL transcripts, a single file or a whole project directory.
    • Filters sessions by date range, which maps to the proposed --since window.
    • Emits structured JSON for tooling, alongside Markdown and HTML.

    Lacks:

    • No reduction of commands to signatures or of failures to error signatures (exit status plus first error line).
    • No cross-session counting or ranking of recurring failures, warnings or repeated commands.
    • No secret masking or redaction before output or storage.
    • No check against open issues and no filing of drafts through the project's intake.
    • No shell history or agent-file sources, and no --plan/--confirm/--dry-run modes.

    Searches run:

    • tool analyze Claude Code JSONL transcripts across sessions recurring errors aggregate
    • analyze shell history and AI agent session logs find recurring failing commands signatures
    • github claude-code-session-analyzer recurring errors patterns across sessions report
    • "claude code" transcript analysis tool detect repeated mistakes warnings across sessions open source
    • open source tool deduplicate and file GitHub issues from recurring error logs automatically
    • claude-code-log python tool parse JSONL transcripts extract tool calls errors
    • mine AI coding agent sessions repeated failures warning patterns tool github "sessions" "recurring"
    • continua-ai happy-paths trace-driven learning loop recurring sad paths sessions tool readme
    • aggregate Bash command failures across claude code sessions normalize error signature dedupe report
    • agent-forensics github claude code transcript analysis tool

    Sources:

    Checked on 2026-11-03. A person decides what this means for the item. The check changes no label and closes no issue.

  6. changed the title [-]feat(ai): add devops ai agent-audit that mines agent transcripts and command history for recurring problems[/-] [+]feat(ai): add devops ai agent-audit for recurring problems[/+] on Nov 6, 2026
  7. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 97 characters, and the limit is 60. The type and the scope stay.

    • Before: feat(ai): add devops ai agent-audit that mines agent transcripts and command history for recurring problems
    • After: feat(ai): add devops ai agent-audit for recurring problems
    • Source of the summary: the background model
  8. removed
    status/new
    on Nov 12, 2026
  9. 68 remaining items

  10. added
    status/in-review
    and removed
    status/blocked
    on Nov 15, 2026
  11. removed
    status/in-review
    owner/service
    on Nov 15, 2026
  12. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 05:17 UTC

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

    effort/mediumpriority/p2-mediumscope/aisource/agenttype/featurevalue/high

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions