Repository navigation
Description
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, andBashis 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_historyhas 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/antigravityholds 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-blobandatis-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
devopsfailures 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):
- A failing signature that occurs in three sessions appears once, with a count of 3 and a pointer for each session.
- A secret in a fixture line is masked in the report and in the stored counts.
- A record type that the parser does not know does not stop the run.
- A second run over the same files does not change the stored counts.
- A
devopswarning that an open issue names is not reported as new. --dry-runreads 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
/insightsof 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-analyzerand 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.atuinkeeps shell history in SQLite with the exit status and the duration, andatuin statsranks 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 noghp_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-blobbefore 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-runover 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-runand--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
--sourceflag 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_secretsdefined and what does it mask?: It is defined atsrc/devops_cli/security/sanitizer.py:454and imported asdevops_cli.security.sanitizer.mask_secrets. It masks a GitHub token such asghp_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, asdevops roadmap intakedoes. (best practice) [sources: docs/ROUTINE_TASKS.md:86, CHANGELOG.md:3362]- Chosen:
--planby 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:
--confirmby 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.
- Chosen:
- Can
--dry-runand--confirmbe combined in one run?: No. The command refuses the run with a usage error and makes no request.devops roadmap returnalready refuses--dry-runwith--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
--confirmfiles issues, so the two flags contradict, and the project already refuses this pair ondevops roadmap return. - Rejected: Let
--dry-runwin. The run would silently ignore--confirmand file nothing. - Rejected: Let
--confirmwin. The run would make the requests that--dry-runforbids.
- Chosen: Refuse the pair. A dry run makes no request and
- 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.
- Chosen: A daily JSON file under
- 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.ymlorbug_report.yml. It calls onedevops aimodel 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
--sourceflag takesshell,filesorallto 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 allopts 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.
- 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.
- How does the audit keep a transcript private?: The read stage runs
mask_secretson 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-logreads 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-logas 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
atuinfor the shell history. It needs a host install, and its import of the existing zsh history has no exit status.
- Rejected: Use
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 27, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate proposes a new command-line tool feature for AI agent auditing.This feature adds value by identifying recurring problems in agent sessions and can improve developer productivity.The feature helps identify recurring issues and patterns, which can significantly reduce time spent on repeated problems.Implementing the command requires integrating with existing AI tools, parsing various data sources, and building a reporting system.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.dan-petty commentedon Oct 28, 2026
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.
devops-cli-service commentedon Nov 3, 2026
Alternatives check: partly
Tool: daaain/claude-code-log (https://github.com/daaain/claude-code-log)
Covers:
Lacks:
Searches run:
Sources:
Checked on 2026-11-03. A person decides what this means for the item. The check changes no label and closes no issue.
[-]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[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 97 characters, and the limit is 60. The type and the scope stay.
feat(ai): add devops ai agent-audit that mines agent transcripts and command history for recurring problemsfeat(ai): add devops ai agent-audit for recurring problems68 remaining items
feat(ai): Count the findings across sessions and rank them (#2346)
feat(ai): Store the counts of the day and keep a second run unchanged (…
feat(ai): Mark a warning that an open issue names as tracked (#2346)
feat(ai): Group the findings with one model call at a time (#2346)
feat(ai): Read the shell history and the agent files as named sources (…
feat(ai): File each draft through devops roadmap intake (#2346)
feat(ai): Add devops ai agent-audit command (#2346)
fix(ai): Resolve data path invariants and startup imports (#2346)
devops-cli-service commentedon Nov 15, 2026
Released in v0.149.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.149.0
devops-cli-service commentedon Nov 15, 2026
Live since 2026-11-15 05:17 UTC