run-presubmit-checks
Skill566 starsChanged 15 days agoApache-2.0View on GitHub
Run presubmit checks on each commit in a stack, automatically fixing any issues. This prepares a stack of commits for submission to Gerrit.
- Commits and pushes
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- pw_ghish/AGENTS.mdAGENTS.md
- pw_ide/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- BluetoothSkill
- Code ReviewSkill
- crankSkill
- docsSkill
- freshenSkill
- ghishSkill
- learn-pigweedSkill
- manual-cli-testSkill
- oncallSkill
- pw_async2Skill
- Pigweed Kernel TestingSkill
- C++ Pigweed RPC ServicesSkill
- respondSkill
- reviewSkill
- saleae-analyzerSkill
- Use Pigweed Toolchain ToolsSkill
- Multi-Agent Worktree & Bazel Cache ManagementSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Ensure the working tree is clean before starting auto mode.
- Very specific: line 21
Run git rev-parse HEAD to get the current commit hash (referred to as <COMMIT>).
- Very specific: line 43
Failures: If a check fails and cannot be automatically fixed, the script stops the rebase at the failing commit and saves its state.
- Distinctive: line 47
When the script fails on a commit:
- Distinctive: line 49
Identify the failure: Look at the output to see which step failed and why.
- Very specific: line 62
Resume: Run the presubmit command again with the --resume flag and the path to the saved state file.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Presubmit Stack Fix Skill
This skill describes how to use Pigweed's presubmit script in auto mode to automatically run checks, apply fixes, and continue a rebase across a stack of commits (CLs).
Overview
The auto mode in pw_presubmit streamlines the process of fixing presubmit issues across multiple commits. It starts an interactive rebase and runs checks on each commit. If a check fails but has an automatic fix, it applies the fix and amends the commit. If a check fails and cannot be fixed automatically, it stops and allows the user to fix it manually before resuming.
Usage
Prepare for Presubmit
- Ensure the working tree is clean before starting
automode. If it is not clean, abort and tell the user to clean the working tree before starting. - Run
git rev-parse HEADto get the current commit hash (referred to as<COMMIT>). - Message the user to explain what will happen and warn them that it will change their branch (by amending commits).
- Provide the user with the command to fully undo the changes:
git rebase --abort; git reset <COMMIT> --hard. - Example message to the user:
I am starting an interactive rebase at
<COMMIT>. This will run presubmit checks on each commit in your stack. If a check fails but has an automatic fix, it will apply the fix and amend your commit. This will change your branch history.If you need to abort and fully restore your branch to its original state, you can run:
git rebase --abort; git reset <COMMIT> --hard
Running Presubmit in Auto Mode
To run presubmit in auto mode on a stack of commits, use the following command:
$ ./pw presubmit --mode auto --ui minimal --program full --base <BASE>Replace <BASE> with the base commit of the stack (e.g., origin/main or a specific commit hash).
Interacting with the Script
- Automatic Fixes: The script automatically applies fixes for checks that support them (e.g., formatting, copyright notice) and amends the current commit.
- Failures: If a check fails and cannot be automatically fixed, the script stops the rebase at the failing commit and saves its state. It outputs a message indicating failure and provide a path to a resume file (e.g.,
resume.json).
Workflow for Failures
When the script fails on a commit:
- Identify the failure: Look at the output to see which step failed and why.
Fix the issues: Manually fix the issues, if feasible. Stop and ask the user for input before proceeding if you encounter any of the following:
- Merge conflicts during the rebase that you are unsure how to resolve.
- Presubmit failures that require significant design changes or user input.
- The script failing repeatedly on the same commit after manual fixes.
- Issues that would require changing files unrelated to the current commit to fix.
- Stage and Amend: You MUST amend the commit with your fixes before resuming. The script requires a clean working tree.
$ git add <fixed_files> $ git commit --amend --no-edit - Resume: Run the presubmit command again with the
--resumeflag and the path to the saved state file.
Replace$ ./pw presubmit --resume /tmp/pw_presubmit_auto_XXXXXX/resume.json/tmp/pw_presubmit_auto_XXXXXX/resume.jsonwith the path provided in the failure message.
Uploading the Verified Stack to Gerrit (./gh)
Once ./pw presubmit --mode auto succeeds across all commits in the stack, upload the stack to Gerrit using ./gh:
# Update existing Gerrit CLs in the stack:
$ ./gh pr push --stack --cq
# Create new Gerrit CLs for the stack:
$ ./gh pr create --stack --cqDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

