Have Claude Code refactor code while you step away
A developer left Claude Code alone on a refactor for 40 minutes, then confirmed the change by checking the tests and the diff.
- What they did
- They assigned Claude Code a refactoring task and let it continue without supervision for roughly 40 minutes. On return, the updated code was in place and the test suite was green. In comments, other users described ways to make this easier to audit, such as running the agent under a limited account and checking the git diff afterward. They also mentioned Claude Code hooks and session JSONL logs as a way to piece together what files were opened and which commands ran.
- How it went
- The refactor completed successfully and the tests passed. The downside was that the developer still lacked a clear record of the agent’s path through the work, including whether it viewed sensitive files or contacted anything outside the repo.
- Tips
- If you use this approach, plan for a separate review of diffs and logs once the run ends. For actions that could alter files, delete content, or reach outside the repo, make the agent wait for your approval first.
Try it yourself with Claude Code
You are working in [repo or code area]. Update [specific module or feature] so that it [desired outcome]. Proceed on your own, but pause and ask me before any irreversible step, including deleting files, applying changes I need to approve, sending anything out, or making external requests. While you work, keep a brief note in [PROGRESS.md or similar] listing each change and the reason for it. Check [test command] after each major change. When you are done, report the files you edited, the tests you ran, and any parts that would benefit from human review.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Test an iOS app and collect bugs automatically
Use Claude Code to drive an iOS app through its accessibility tree, visit screens, and return a structured bug report.
Investigate why a service is getting killed
Run a read-only SSH check to find the cause of a process death and rank fixes by risk.
Build Playwright tests from a live app with Claude Code
Claude Code inspected a working app, generated a Playwright test, and fixed a locator conflict before a person checked the result.
Run Microsoft Office on Linux with Wine
Use Wine and compatibility shims to get Microsoft 365 installing and opening on Linux without a virtual machine.
Audit CSS with MDN-backed browser checks
An MCP add-on let Claude Code look up MDN guidance and browser support while reviewing CSS for likely issues.
Use Claude Code to hunt flaky CI tests overnight
Claude Code tracked CI flakiness, isolated the worst tests, and suggested fixes while a human reviewed the changes each day.