Top 200 ReposEXPLORER
Browse agents, categories and pages
Back to results
Planned, not doneThe source describes an intention, not a finished result.

Allow a Coding Refactor to Run Unattended with Audit Logs

Overview

Run a long Claude Code refactor non-interactively on its own branch with a narrow tool allowlist, record every step to a log file, and review the log, tests and diff before anything is merged.

Problem or Objective

More in Coding and Code Review

AI Agents and Models

Tools and Integrations

Tools
Claude Code
Prerequisites
Claude Code with a Claude subscription or API key, a Git repository with a working test suite, and permission to add a hook to the project's Claude Code settings.

How It Works

Create a new branch or a separate clone for the refactor and make sure the test suite passes before you start. Add a hook in the project's Claude Code settings that appends each tool call and shell command to an audit log file. Then start the run with claude -p, giving a written goal and a stopping rule, an --allowedTools list that covers file edits and the test command but not deployment, pushing or network tools, and --output-format stream-json with --verbose redirected to a second log file. When it finishes, read the audit log for anything unexpected, run the tests yourself, and review the full diff before you merge.

Implementation Workflow

Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.

  1. Choose the agentSet up Claude Code.
  2. Connect the toolsConnect the tools this workflow relies on: Claude Code.
  3. Check the prerequisitesClaude Code with a Claude subscription or API key, a Git repository with a working test suite, and permission to add a hook to the project's Claude Code settings.
  4. Gather your detailsCollect what the prompt asks for: Module or folder to refactor, What the refactor should achieve, Paths the run may edit, Command that runs the tests, Retry limit for one failure.
  5. Run the starter promptPaste the starter prompt below into Claude Code and adapt it to your case.
  6. Check against the documentationCompare what you get with the documentation at code.claude.com before you rely on it.

Practical Starter Prompt: Refactor this module unattended and log every step

Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].

Preview
Refactor [Module or folder to refactor] to [What the refactor should achieve] without changing its public behaviour. Work only inside [Paths the run may edit]. After each logical step, run [Command that runs the tests] and fix failures before continuing. Do not push, deploy, install new dependencies or touch files outside the allowed paths. Stop when the tests pass and the goal is met, or after [Retry limit for one failure] attempts at the same failure, and finish with a summary of every file changed and why, so a person can review it before merging.

Start on a separate branch with a narrow --allowedTools list and the logging hook in place. Afterwards read both logs, rerun the tests and review the diff before merging.

Expected Results and Benefits

This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.

This is a suggested workflow, not a reported outcome. The Claude Code docs support non-interactive runs with claude -p, an --allowedTools flag that lets listed tools run without prompting, stream-json output, and hooks that run shell commands before or after Claude Code actions. How long a refactor takes and whether it stays on track depend on the codebase and the goal you write.

Limitations and Considerations

A -p run shows no trust dialog, so anything outside your --allowedTools list will simply not be allowed; keep the list narrow and leave out push and deploy commands. Run it on a branch or a copy so a bad result costs nothing. A passing test suite is not a full review: read the diff and the log before merging. Check your plan's limits or API budget before a long run. Results depend on your setup and were not independently reproduced by Top 200 Repos.

GitHub Repositories

AI Agent Repository

Source code of the agent that does the work.

Official Website

The official site of the main tool or project in this use case.

Visit Website (opens in a new tab)code.claude.com

Related Videos

About anthropics/claude-code

About anthropics/claude-code

Independent creators. Listing a video implies no endorsement, sponsorship or partnership.

Sources

  1. Run Claude Code programmatically - Claude Code Docs (opens in a new tab)

    Project documentation · code.claude.com · Undated · Source checked 26 Nov 2026, 17:27 UTC

    What this source supports
    • Use --allowedTools to let Claude use certain tools without prompting.
    • Use --output-format stream-json with --verbose and --include-partial-messages to receive tokens as they’re generated.
    • A -p session shows no workspace trust dialog and no per-server approval prompt.
  2. Overview - Claude Code Docs (opens in a new tab)

    Project documentation · code.claude.com · Undated · Source checked 25 Nov 2026, 11:57 UTC

    What this source supports
    • Hooks let you run shell commands before or after Claude Code actions, like auto-formatting after every file edit or running lint before a commit.
Report a problem

More with Claude Code

Planned, not done

Create Custom Store Tools Instead of Paying for Subscriptions

Use Claude Code to write small in-house tools for an online shop, such as a reply helper for support mail or a margin report, as an alternative to paying for separate apps, with testing before you rely on them.

code.claude.comanthropics/claude-code
Reported by source

Answer technical questions by letting async agents run experiments

Simon Willison sends research questions to cloud coding agents such as Claude Code for web and Codex Cloud, which write and run experiments in a dedicated repo and open a PR.

simonwillison.net · 6 Nov 2025anthropics/claude-code, openai/codex
Planned, not done

Structure Repeated Browser Research Into Evidence Tables

Give Claude Code the open-source Browser Use CLI with a local browser, ask the same research questions across a short list of pages, and keep every answer as a sourced table row.

github.comanthropics/claude-code, browser-use/browser-use

View all: Claude Code