Extend LoopCode
GitHub reviews and fixes
Set LoopCode up in GitHub Actions to review every pull request, fix things when you ask with @loopcode, and turn issues into pull requests.
What it does
Once installed in a repository:
- New pull requests get a review. LoopCode reads the change and the code around it, and comments with the real problems it finds — each with the file and line, a severity and a fix. Drafts are skipped until they are ready for review.
@loopcode reviewon a pull request asks for a review again.@loopcode fix it— or any request — on a pull request or one of its review comments: LoopCode makes the change and commits it to the pull request's branch.@loopcode …on an issue, or the labelloopcode: LoopCode works on the issue and opens a pull request.
LoopCode acts only for people who can push to the repository (write, maintain or admin access), and ignores comments from bots. Its commits are made as loopcode[bot].
Install
From the repository, with the GitHub CLI (gh) installed and signed in:
loopcode github install
This does two things:
- Creates an access token on your LoopCode plan and stores it as the repository secret
LOOPCODE_TOKEN. - Writes
.github/workflows/loopcode.yml.
Commit and push the workflow, and it starts on the next pull request. Run loopcode github install --force to rewrite the workflow.
The workflow
The workflow runs on pull requests, issue and review comments that mention @loopcode, and issues that are labelled loopcode or opened with a mention. It checks out the repository, installs the LoopCode CLI, and runs loopcode github run, which reads the GitHub event and acts on it:
- name: Install LoopCode
run: |
curl -fsSL https://loopcode.heksync.in/cli.sh | LOOPCODE_NO_LOGIN=1 LOOPCODE_NO_MODIFY_PATH=1 sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run LoopCode
run: loopcode github run
env:
LOOPCODE_TOKEN: ${{ secrets.LOOPCODE_TOKEN }}
GH_TOKEN: ${{ github.token }}
Runs for the same pull request or issue queue rather than overlap, and each job has a 45-minute limit. The GitHub token is passed only to gh and git, never left where the agent's commands would inherit it.
Usage and limits
GitHub runs draw on the plan of the account that created the token, like any other LoopCode use. Revoke the token with loopcode token revoke <id> to switch the integration off at once.
Tips
- Put the commands for tests and lint in
LOOPCODE.md, so reviews and fixes can run them. See Instructions and memory. - Be specific in a mention: "@loopcode handle the empty-cart case in this function and add a test".
- Use hooks and permission rules in the repository's settings to keep CI runs within bounds.