Tracing AI-written code back to the prompt that asked for it

An AI agent changed 40 files and nobody remembers why. How Hyperpowers finds the Claude Code request behind each changed file, and what it leaves out.

To trace AI-written code back to the prompt that asked for it, look in the Claude Code session that edited the file: the request typed just before the edit is the reason for the change. Hyperpowers does this for every file in a pull request, with passwords and keys removed, and puts that request next to the change as its why.

A diff shows what changed. The reason usually lives in a chat with an agent that nobody will reread. Below is what Hyperpowers reads from those sessions, what it leaves out, what it does when a subagent edited the file, and how to turn it off.

Why can't anyone say why the AI changed this file?

Because the reason was never written down next to the code. It is in the session that produced it. A model reading only the diff can guess why a line changed. With the session, it can say what was asked just before the file was edited.

That matters most for AI-written pull requests. The author asked for a feature, the agent changed 40 files, and the author may not remember why each one changed. The request is the closest thing to a spec, and it is already on disk.

It also gives the reviewer something to check against. When the code does something nobody asked for, or misses something that was asked, the request makes that visible.

Which sessions does Hyperpowers read?

It reads the Claude Code session files under ~/.claude/projects/ for the repository, and only the parts that edited a file the pull request changed.

In more detail:

  • The folder. Claude Code names each project folder after the repository's path. Hyperpowers reads folders at that path, or a folder above or below it.
  • The time window. From a day before the pull request's first commit to ten minutes after its last. Anything said after the last commit didn't make the code in it.
  • The branch. For a session run inside the repository on a named branch, only entries on the pull request's branch count.
  • The edit. A session counts when it edits a changed file, with Edit, Write, MultiEdit or NotebookEdit, or with a shell command that names the file. The request typed just before the edit, and what Claude said, are kept for that file.

There are caps: 12 requests in all, 4 notes per file, each request cut at 400 characters and what Claude said at 300. Session files over 300 MB are skipped.

If the repository has hyperpower plugin runs that planned a changed file in the same window, their request, approach and per-file reasons are used too.

What gets removed, and where does the rest go?

Passwords, tokens, API keys, private keys, AWS, GitHub and Slack tokens, JWTs, and any run of 40 or more key-like characters are removed from the session text before anything is sent or kept.

Then the requests go into the prompt with the pull request's text, and each file's notes go beside that file's diff, marked as data. The diff, the notes and those requests go to your own Claude Code, the same as any session you run, and Claude Code sends them to Anthropic. See Anthropic's privacy policy and commercial terms for how that data is handled.

Hyperpowers has no server of its own in between.

What is the agent-brief fallback?

When a changed file isn't explained by any session or run, Hyperpowers looks at the subagents those sessions started. If a subagent edited the file, it uses that subagent's brief: the first message the subagent was given.

The rules are narrow:

  • Only subagent transcripts under <project>/<session>/subagents/ count, inside the same window, branch and repository.
  • Only an edit to the file counts, with Edit, Write, MultiEdit or NotebookEdit. A read or a command does not.
  • Only the brief is used, cut at 600 characters, with the same secrets removed. Never what the subagent said, ran or read.
  • At most 2 briefs per file, and 12 in all.

The model sees each one labelled as a brief given to an agent, not the author's own words, and is told never to quote it as the author. A brief was written by the main agent, so it is a weaker source than the author's own request, and the explanation treats it that way.

When the walkthrough is created, the progress line says what was used, such as "Using 2 Claude Code sessions, 1 agent brief and 0 hyperpower runs as the author's own words."

How do you turn it off?

In the VS Code extension, set hyperpowers.walkthrough.useClaudeSessions to false. Create Walkthrough then leaves the sessions and briefs out and explains from the diff and the pull request's text, and Review with Claude stops checking the code against what was asked.

In the hyperpower plugin for Claude Code, pass --no-sessions to /hyperpower:walkthrough explain, or set walkthrough: { use_claude_sessions: false } in hyperpower.yml for the repository.

Whose sessions does it read when I review someone else's pull request?

Only sessions on your own machine. If a teammate wrote the code with Claude Code on their laptop, your machine doesn't have those sessions, and your walkthrough is explained from the diff.

To get their reasons into your review, the author can create the walkthrough on their machine and export it. Click … on the walkthrough and choose Export walkthrough. It saves one .walkthrough file with the explanation, the changed code and any screenshots. You open it with Load Walkthrough File, and you don't need Claude Code or the repository to read it. The file holds the code of every changed file, so send it only to people who may see that code.

How does Review with Claude use the sessions?

When you ask Claude to review a file, an area or the whole pull request, it also reads what was asked while the code was written, and checks the code against it. Something asked for and not done, or done and never asked for, is flagged as a finding. You decide whether each finding becomes a comment.

Try it

Try Hyperpowers in your browser on an example pull request, or install the extension and follow Your first review on a pull request you built with Claude Code. For the review method itself, see How to review a pull request that AI wrote.

Common questions

Does Hyperpowers upload my Claude Code sessions anywhere?

It sends the parts it uses, with secrets removed, to your own Claude Code to write the explanation. Like any Claude Code session, that goes to Anthropic. There is no Hyperpowers server in between, and the walkthrough is saved in your checkout, where git ignores it.

Does it need the hyperpowers plugin?

No. The VS Code extension reads the sessions by itself. The plugin's /hyperpower:walkthrough explain reads them the same way.

What if no session matches the pull request?

Then the explanation comes from the diff and the pull request's text, as it would with the setting off. Missing or unreadable sessions never make the walkthrough fail.

Is a reason from a session always right?

It is what was asked, which isn't always what the code does. That gap is worth checking, and the explanation sits next to the diff so you can.

Related posts

← All postsHyperpowers for VS Code