formatter-hook

Automate staged-file formatting and lint checks for Git and GitButler workflows.

33|2|Updated Feb 21, 2025
One-click install
npx skills add https://github.com/yspreen/dotfiles --skill formatter-hook
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: formatter-hook
Source: https://github.com/yspreen/dotfiles/tree/main/.agents/skills/formatter-hook
Command: npx skills add https://github.com/yspreen/dotfiles --skill formatter-hook

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This hook helps ensure code formatting and lint checks happen only on files staged for commit, preventing changes to un-staged files and keeping both plain Git and GitButler workflows in sync.

Core Features & Use Cases

  • Staged-only formatting: Run formatters and linters only on files that are staged for commit.
  • Git + GitButler compatibility: Works with both standard Git hooks and GitButler-managed wrappers, preserving installation paths and behavior.
  • Xcode/iOS integration: Recognizes common iOS/Xcode project hook scenarios and installs hooks accordingly to support build steps that install or invoke hooks.

Quick Start

Run the installer to configure staged-file hooks that work with both Git and GitButler in your repository.

Frequently Asked Questions about formatter-hook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run pre-commit formatters only on staged files in git?

To run pre-commit formatters only on staged files, this hook collects a deterministic staged-file diff and applies per-language tool filtering. This ensures formatters and linters modify exclusively committed changes, preventing unintended edits to un-staged files.

Can I use pre-commit hooks with both Git and GitButler?

Yes, you can use pre-commit hooks with both Git and GitButler. This hook preserves compatibility by managing installation paths in hooks/ and running runtime hooks via .githooks/, ensuring both standard Git and GitButler workflows stay synchronized.

How do I set up staged-file formatting hooks for Xcode iOS projects?

To set up staged-file formatting hooks for Xcode iOS projects, run the installer to configure hooks that recognize common iOS build phases. This supports environments that install or invoke hooks during Xcode build steps.

Does GitButler support backup-based auto-fix for pre-commit lint checks?

GitButler supports backup-based auto-fix for pre-commit lint checks through this hook's integration. It automatically applies fixes to staged files and provides clear re-stage guidance so you can review and finalize changes before committing.

Why does my formatter modify un-staged files during a git commit?

Formatters modify un-staged files during a git commit when hooks run against the entire working directory. This staged-file hook restricts formatting to the deterministic staged-file diff, ensuring un-staged files remain untouched.

What is the best way to sync git hooks between plain Git and GitButler workflows?

The best way to sync git hooks is to use a staged-file hook that installs wrappers in hooks/ and executes runtime hooks via .githooks/. This maintains consistent behavior and installation paths across plain Git and GitButler repositories.