agentleFS
pigweed-projectpigweed-project/pigweed/.agents/skills/run_presubmit_checks/SKILL.md

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

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
  1. Very specific:

    Ensure the working tree is clean before starting auto mode.

    line 20
  2. Very specific:

    Run git rev-parse HEAD to get the current commit hash (referred to as <COMMIT>).

    line 21
  3. Very specific:

    Failures: If a check fails and cannot be automatically fixed, the script stops the rebase at the failing commit and saves its state.

    line 43
  4. Distinctive:

    When the script fails on a commit:

    line 47
  5. Distinctive:

    Identify the failure: Look at the output to see which step failed and why.

    line 49
  6. Very specific:

    Resume: Run the presubmit command again with the --resume flag and the path to the saved state file.

    line 62

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 auto mode. If it is not clean, abort and tell the user to clean the working tree before starting.
  • Run git rev-parse HEAD to 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:

  1. Identify the failure: Look at the output to see which step failed and why.
  2. 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.
  3. 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
  4. Resume: Run the presubmit command again with the --resume flag and the path to the saved state file.
    $ ./pw presubmit --resume /tmp/pw_presubmit_auto_XXXXXX/resume.json
    Replace /tmp/pw_presubmit_auto_XXXXXX/resume.json with 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 --cq

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.