Skip to content

Instantly share code, notes, and snippets.

@oilbeater
Last active January 29, 2026 10:38
Show Gist options
  • Select an option

  • Save oilbeater/ece9aa88d5ec47676cd47c669bac2502 to your computer and use it in GitHub Desktop.

Select an option

Save oilbeater/ece9aa88d5ec47676cd47c669bac2502 to your computer and use it in GitHub Desktop.
loop-agent-refactor.sh
#!/usr/bin/env bash
set -e
PROMPT="I hope you will read the entire project code and look for areas that can be refactored. Refactoring directions include code structure, readability, extensibility, maintainability, and performance.
If the file list does not exist in .context/File.md, first list all the files, recording the filenames in todo format in .context/File.md.
Then, perform the following operations for each file one by one:
1. Sequentially select a file from .context/File.md that has not been completed as a todo, read it, look for refactoring points, and record them in todo format in .context/REFACTOR.md.
2. If the file is too long, slice it for reading.
3. If there are no refactoring suggestions for the file, there is no need to record refactoring points.
4. Mark the currently read file as completed in the file list in .context/File.md.
**Note**
1. File.md records progress; do not mark all files as completed at once—only mark files that have been reviewed.
2. You do not need to complete all review tasks at once; unfinished tasks will be handled by other agents later.
3. Each file should be read as thoroughly and critically as possible."
round=1
while true; do
echo "========== round $round =========="
agent -p -f "$PROMPT" || true
((round++))
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment