agentleFS
softwareone-platformsoftwareone-platform/mpt-extension-skills/skills/mpt-ext-task-fix-pre-commit-failures/SKILL.md

mpt-ext-task-fix-pre-commit-failures

Skill3 starsChanged 24 days agoApache-2.0View on GitHub

Fix failures raised by the pre-commit hook during `git commit` (not standalone make/test runs). Reads hook output, fixes one failure at a time, reruns, and retries the commit; max 5 iterations.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 14 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read repository-specific docs when they exist, because they may extend or override shared guidance.

    line 46
  2. Very specific:

    Read shared docs only when the repository explicitly points to them.

    line 47
  3. Distinctive:

    Use repository commit and validation docs as the source of truth for commit-time hooks.

    line 50
  4. Distinctive:

    Read the failed hook output.

    line 53
  5. Distinctive:

    Keep hook-generated fixes unless there is a clear reason they are incorrect.

    line 56
  6. Distinctive:

    If a hook failure reflects a broader repository check failure, run the relevant underlying validation command before retrying the commit.

    line 60
  7. Distinctive:

    Avoid speculative edits unrelated to the failing hook.

    line 61
  8. Very specific:

    Before each attempt, state the iteration explicitly: Iteration N/5 — failing hook: <hook>.

    line 65
  9. Distinctive:

    Stop early, without consuming the remaining iterations, when there is no progress: the same hook fails the same way after a fix attempt, or …

    line 69
  10. Distinctive:

    Stop when the commit is still blocked after 5 fix-and-retry iterations, and report the remaining hook output as the blocker.

    line 70
  11. Very specific:

    Never ignore a failed pre-commit run and pretend the commit succeeded.

    line 85
  12. Distinctive:

    Never discard hook-generated file rewrites without inspecting them first.

    line 86
  13. Distinctive:

    Never retry commits blindly without addressing the current hook failures.

    line 87
  14. Distinctive:

    Never run more than 5 pre-commit fix-and-retry iterations before stopping with a blocker, and stop sooner when the loop stops converging.

    line 88
  15. Distinctive:

    Never let the caller re-loop this task.

    line 89
  16. Distinctive:

    Never mix PR creation or Jira transitions into this task.

    line 90
  17. Distinctive:

    Never bypass repository-required hooks unless the user explicitly directs that and repository policy allows it.

    line 91

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Fix Pre-commit Failures

Purpose

Resolve pre-commit hook failures that block a git commit, one hook failure at a time, stopping when the commit is clean, when the loop stops converging, or after at most 5 fix-and-retry iterations.

Use When

  • git commit triggered pre-commit and the hooks failed.
  • pre-commit rewrote files and the user wants to continue safely.
  • The task requires inspecting hook output and fixing the remaining blockers before retrying commit.

Do Not Use When

  • The task is only to run the repository validation flow before commit.
  • The task is to fix normal checks or tests that failed outside the git commit hook run.
  • The task is to create or update a pull request.
  • The task is to ignore or bypass hook failures.

Inputs

  • The failed pre-commit hook output from the attempted git commit.
  • Current repository diff, including any hook-generated file changes.
  • Repository validation rules from repo docs.
  • Installed shared package root:
${MPT_EXTENSION_SKILLS_HOME:-$HOME/.mpt-extension-skills}/current

Assumptions

  • The target repository is available locally and Git commands can be executed.
  • Repository-required hook tooling is installed or otherwise available in the current environment.
  • The failed pre-commit output being handled matches the current repository state.

Workflow

  1. Build repository context first.
  • Read the target repository AGENTS.md once per session. If you already loaded it earlier in this session and still have its full contents, reuse them instead of re-reading; if the context was summarized or you are unsure it is complete, read it again. Do not pre-load shared docs in this step; read them lazily only when the repository points to them.
  • Read repository-specific docs when they exist, because they may extend or override shared guidance.
  • Read shared docs only when the repository explicitly points to them. Resolve those shared docs from ${MPT_EXTENSION_SKILLS_HOME:-$HOME/.mpt-extension-skills}/current when available; otherwise read them from the main branch of the shared GitHub repository.
  1. Confirm the pre-commit requirement.
  • Use repository commit and validation docs as the source of truth for commit-time hooks.
  • For repositories that follow this shared package guidance, read knowledge/build-and-checks.md using the shared-doc resolution rule from the repository context step instead of restating the policy in this skill.
  1. Read the failed hook output.
  • Identify which hook failed and whether any hooks rewrote files automatically.
  • Inspect hook-generated file changes before making more edits.
  • Keep hook-generated fixes unless there is a clear reason they are incorrect.
  1. Fix one remaining hook blocker at a time.
  • Apply the smallest change needed to satisfy the currently failing hook.
  • If a hook failure reflects a broader repository check failure, run the relevant underlying validation command before retrying the commit.
  • Avoid speculative edits unrelated to the failing hook.
  1. Revalidate and retry the commit.
  • One iteration = one scoped hook fix + one commit retry. Confirming a clean automatic pre-commit run after the loop is not a separate iteration.
  • Before each attempt, state the iteration explicitly: Iteration N/5 — failing hook: <hook>.
  • Rerun the narrowest safe validation needed to confirm the hook-related fix.
  • Retry the commit only after the current hook blockers are addressed.
  • Confirm that the automatic pre-commit run triggered by the retried commit passes cleanly.
  • Stop early, without consuming the remaining iterations, when there is no progress: the same hook fails the same way after a fix attempt, or a fix re-introduces a previously-passing hook. Report it as a non-converging blocker.
  • Stop when the commit is still blocked after 5 fix-and-retry iterations, and report the remaining hook output as the blocker.
  1. Report the result clearly.
  • State which hooks failed and which were fixed.
  • State whether hook-generated file changes were kept.
  • State whether the commit is now unblocked or what blocker remains.
  • End with exactly one classified outcome the caller can act on, chosen by this precedence (success first):
    • committed — the commit completed with a clean automatic pre-commit run, even when reached on the final allowed iteration.
    • needs-user-input — a remaining hook failure needs user direction or a broader design decision.
    • environment-blocker — the remaining failure is environment or hook-setup related, not product code.
    • non-converging — the same hook failed the same way after a fix, or a fix reintroduced a previously-passing hook.
    • iteration-limit-reached — 5 fix-and-retry iterations were spent without reaching any of the above.

Guardrails

  • Never ignore a failed pre-commit run and pretend the commit succeeded.
  • Never discard hook-generated file rewrites without inspecting them first.
  • Never retry commits blindly without addressing the current hook failures.
  • Never run more than 5 pre-commit fix-and-retry iterations before stopping with a blocker, and stop sooner when the loop stops converging.
  • Never let the caller re-loop this task; this task owns the bounded fix-and-retry loop and returns a single classified outcome.
  • Never mix PR creation or Jira transitions into this task.
  • Never bypass repository-required hooks unless the user explicitly directs that and repository policy allows it.

Expected Outcome

The pre-commit failures triggered by git commit are resolved step by step, hook-generated fixes are handled safely, and the commit is retried only when the automatic hook run is expected to pass cleanly, up to the 5-iteration limit or until the loop stops converging, and the task returns a single classified outcome (committed, needs-user-input, environment-blocker, non-converging, or iteration-limit-reached) for the caller to act on.

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.