Agent skill

Git Worktree Precommit Hook Flutter Failure

by divinevideo in divinevideo/divine-mobile

Fix git pre-commit hook failures in Flutter projects when using git worktrees.

MPL-2.0Auto-check passedDevelopment

Install Git Worktree Precommit Hook Flutter Failure

skills CLI
$ npx skills add divinevideo/divine-mobile --skill git-worktree-precommit-hook-flutter-failure -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install divinevideo/divine-mobile git-worktree-precommit-hook-flutter-failure --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/git-worktree-precommit-hook-flutter-failure .claude/skills/git-worktree-precommit-hook-flutter-failure && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
git-worktree-precommit-hook-flutter-failure
GitHub stars
265
Token cost
~1k tokens
SKILL.md length
328 words
Files
1
Skills in repo
103
Repo updated
First seen
Licence
MPL-2.0

At a glance

Fix git pre-commit hook failures in Flutter projects when using git worktrees.

  • Works in 4 steps: Make a change in a git worktree → Stage the file: git add → Commit: git commit -m "test" — hook… → …
  • Pre-commit hook with flutter analyze fails during git commit but passes when run manually
  • SKILL.md covers Problem, Root Cause, Context / Trigger Conditions and Diagnosis, plus 3 more sections
  • Calls flutter, git and dart

What it does

Git Worktree Precommit Hook Flutter Failure is an agent skill from divinevideo/divine-mobile. Fix git pre-commit hook failures in Flutter projects when using git worktrees. Use when: (1) Pre-commit hook with flutter analyze fails during git commit but passes when run manually, (2) Hook output shows "Resolving dependencies..." then immediately fails with no actual analysis errors, (3) Working in a git worktree (created via git worktree add). Root cause: git sets GITDIR to a worktree-style path during hook execution, which breaks flutter pub get (called internally by flutter analyze). Fix: unset GITDIR…

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Git worktrees and Cross-platform mobile apps. It works with Git and Flutter. The licence is MPL-2.0.

When your agent uses it

  • Pre-commit hook with flutter analyze fails during git commit but passes when run manually
  • Hook output shows Resolving dependencies... then immediately fails with no actual analysis errors
  • Working in a git worktree (created via git worktree add)

Example prompts

  • “Resolving dependencies...”
  • “/git-worktree-precommit-hook-flutter-failure”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Make a change in a git worktree
  2. Stage the file: git add
  3. Commit: git commit -m "test" — hook should pass
  4. Verify the same hook still works in the main repo checkout

What it can do on your machine

Read from SKILL.md and the folder at commit 8d5fbf2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • flutter
    • git
    • dart

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktree Precommit Hook Flutter Failure loads about 1k tokens when it runs. Until then it costs about 162 tokens; SKILL.md has 328 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~162
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from divinevideo/divine-mobile at commit 8d5fbf2, republished under its MPL-2.0 licence (© divinevideo). 328 words, ~1,000 tokens.

Download SKILL.mdSave it as .claude/skills/git-worktree-precommit-hook-flutter-failure/SKILL.md (or your agent's skills folder).
name
git-worktree-precommit-hook-flutter-failure
description
Fix git pre-commit hook failures in Flutter projects when using git worktrees. Use when: (1) Pre-commit hook with `flutter analyze` fails during `git commit` but passes when run manually, (2) Hook output shows "Resolving dependencies..." then immediately fails with no actual analysis errors, (3) Working in a git worktree (created via `git worktree add`). Root cause: git sets GIT_DIR to a worktree-style path during hook execution, which breaks `flutter pub get` (called internally by `flutter analyze`). Fix: unset GIT_DIR, GIT_INDEX_FILE, and GIT_WORK_TREE before flutter/dart commands in the hook.
author
Claude Code
version
2.0.0
date
2026-02-08

Git Worktree Pre-Commit Hook Flutter Failure

Problem

When using git worktree for parallel development, pre-commit hooks that run flutter analyze fail during git commit even though:

  • Running flutter analyze directly in the worktree passes with no issues
  • Running the pre-commit hook script manually passes
  • The hook passes in the main repo checkout

Root Cause

Git sets GIT_DIR, GIT_INDEX_FILE, and GIT_WORK_TREE environment variables during hook execution. In a worktree, GIT_DIR points to .git/worktrees/<name>/ instead of .git/. When flutter analyze internally runs flutter pub get, pub chokes on this worktree-style GIT_DIR path and fails to resolve dependencies.

The failure is invisible when the hook uses 2>/dev/null on stderr — you only see "Resolving dependencies..." then the failure message, with the actual error suppressed.

Context / Trigger Conditions

  • Using git worktree add for parallel branch development
  • Pre-commit hook runs flutter analyze or dart analyze
  • Hook output shows "Resolving dependencies..." then immediately fails
  • No actual analysis errors are reported
  • The hook uses set -e (exit on error)
  • 2>/dev/null may hide the actual failure cause

Diagnosis

Reproduce the exact failure by simulating git's hook environment:

bash
# This will FAIL (simulates hook execution in worktree)
GIT_DIR=/path/to/main/.git/worktrees/<name> \
  flutter analyze --no-fatal-infos 2>/dev/null

# This will PASS (without git env vars)
flutter analyze --no-fatal-infos

Solution

Add unset GIT_DIR GIT_INDEX_FILE GIT_WORK_TREE to the pre-commit hook after all git commands but before any flutter/dart commands.

bash
#!/bin/bash
set -e

cd "$(git rev-parse --show-toplevel)/mobile"

# Git operations (these NEED the git env vars)
STAGED_DART_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.dart$' || true)

if [ -z "$STAGED_DART_FILES" ]; then
    echo "No Dart files staged, skipping checks"
    exit 0
fi

# Unset git env vars BEFORE running flutter/dart commands.
# Git sets these during hook execution, and flutter pub get
# (called internally by flutter analyze) chokes on worktree-style
# GIT_DIR paths.
unset GIT_DIR GIT_INDEX_FILE GIT_WORK_TREE

# Now flutter/dart commands work in both main repo and worktrees
dart format --output=none --set-exit-if-changed lib test
flutter analyze --no-fatal-infos

Key points:

  • The unset MUST come after git diff --cached (which needs GIT_INDEX_FILE)
  • The unset MUST come before flutter analyze and dart format
  • Remove 2>/dev/null from flutter analyze so errors are visible

Verification

  1. Make a change in a git worktree
  2. Stage the file: git add <file>
  3. Commit: git commit -m "test" — hook should pass
  4. Verify the same hook still works in the main repo checkout

Notes

  • This affects any tool that internally runs pub get or interacts with git during hook execution (not just flutter analyze)
  • dart format may also be affected in some configurations
  • The git rev-parse --show-toplevel call at the top of the hook works correctly with GIT_DIR set — it resolves to the worktree root
  • Only unset the vars when you're done with git operations

© divinevideo, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/git-worktree-precommit-hook-flutter-failure of divinevideo/divine-mobile.

Open the folder on GitHubat commit 8d5fbf2

Compare with similar skills

Git Worktree Precommit Hook Flutter Failure next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktree Precommit Hook Flutter Failure compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree Precommit Hook Flutter Failure this skilldivinevideo/divine-mobile265—~1kAutomated safety check: PassMPL-2.0
Git Worktree Setupk8zdev/k8z155—~930Automated safety check: PassNone
Core API Changelibnativeapi/nativeapi157—~2.5kAutomated safety check: PassMIT
Reviewgetsentry/sentry-dart873—~1.3kAutomated safety check: PassMIT
Rebase Mainhyochan/flutter_calendar_carousel860—~662Automated safety check: PassMIT
Flutter Appccplugins/awesome-claude-code-plugins967—~1.1kAutomated safety check: NotesApache-2.0

Similar skills

  • Automate git worktree creation and copy private files (not tracked in git) to new workdirs.

    155 GitHub stars~930 tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • Core API Change

    libnativeapi/nativeapi

    Carry a change to the C++ public API in core/ all the way downstream — design check, header edit, six platform implementations, C ABI + Rust/Dart/C/JS/Python regeneration, per-binding verification…

    157 GitHub stars~2.5k tokensUpdated today
    MobileAuto-check passed
  • Review

    getsentry/sentry-dart

    Official

    Three-axis review of the branch diff — Standards (this repo's documented standards + public API surface), Spec (the originating Linear issue / PR), and Correctness (runtime bugs + the SDK threat…

    873 GitHub stars~1.3k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Rebase Main

    hyochan/flutter_calendar_carousel

    Safely update local main from origin/main, rebase the current fluttercalendarcarousel work branch, resolve conflicts without losing staged, unstaged, untracked, ignored, or generated work, and…

    860 GitHub stars~662 tokensUpdated 16 days ago
    MobileAuto-check passed
  • Flutter App

    ccplugins/awesome-claude-code-plugins

    Bootstrap a new Flutter mobile app with clean architecture, Riverpod, FVM-pinned SDK, current packages, and no deprecated APIs.

    967 GitHub stars~1.1k tokensUpdated 1 mo ago
    MobileAuto-check: notes
  • Ad Next

    CorridorTech/PoseCap

    Survey the project's state across the six-layer artifact stack and recommend prioritized next actions, modeled on flutter doctor.

    220 GitHub stars~3.3k tokensUpdated today
    MobileAuto-check: notes

More from divinevideo/divine-mobile

All 103 skills in this repo
  • Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y".

    265 GitHub stars~931 tokensUpdated today
    Auto-check passed
  • Art Direct

    divinevideo/divine-mobile

    Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language.

    265 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Async Await Null Race Condition

    divinevideo/divine-mobile

    Fix "Null check operator used on a null value" errors when an object is set to null during an async await.

    265 GitHub stars~881 tokensUpdated today
    Auto-check passed
  • AWS V4 Signing Custom Headers Gcs

    divinevideo/divine-mobile

    Add custom metadata headers (x-amz-meta-) to AWS v4 signed requests for GCS S3-compatible API.

    265 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Bash Herestring Newline Secrets

    divinevideo/divine-mobile

    Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings.

    265 GitHub stars~791 tokensUpdated today
    Auto-check passed
  • Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp).

    265 GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Works with

Questions about Git Worktree Precommit Hook Flutter Failure

What does Git Worktree Precommit Hook Flutter Failure do?

Fix git pre-commit hook failures in Flutter projects when using git worktrees. Git Worktree Precommit Hook Flutter Failure is an agent skill from divinevideo/divine-mobile. Fix git pre-commit hook failures in Flutter projects when using git worktrees.

When should I use Git Worktree Precommit Hook Flutter Failure?

Git Worktree Precommit Hook Flutter Failure fits situations like: pre-commit hook with flutter analyze fails during git commit but passes when run manually; hook output shows Resolving dependencies... then immediately fails with no actual analysis errors; working in a git worktree (created via git worktree add).

How do I install Git Worktree Precommit Hook Flutter Failure in Claude Code?

Run `npx skills add divinevideo/divine-mobile --skill git-worktree-precommit-hook-flutter-failure -a claude-code`. Or copy the skill folder (.agents/skills/git-worktree-precommit-hook-flutter-failure in divinevideo/divine-mobile) into .claude/skills/git-worktree-precommit-hook-flutter-failure in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktree Precommit Hook Flutter Failure in Codex?

Run `npx skills add divinevideo/divine-mobile --skill git-worktree-precommit-hook-flutter-failure -a codex`. Or copy the skill folder (.agents/skills/git-worktree-precommit-hook-flutter-failure in divinevideo/divine-mobile) into .agents/skills/git-worktree-precommit-hook-flutter-failure in your project. Codex loads it when a task matches its description.

Can I use Git Worktree Precommit Hook Flutter Failure in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add divinevideo/divine-mobile --skill git-worktree-precommit-hook-flutter-failure -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-worktree-precommit-hook-flutter-failure, .gemini/skills/git-worktree-precommit-hook-flutter-failure, .github/skills/git-worktree-precommit-hook-flutter-failure and .opencode/skills/git-worktree-precommit-hook-flutter-failure in your project.

What does Git Worktree Precommit Hook Flutter Failure need to run?

Going by SKILL.md and its folder, Git Worktree Precommit Hook Flutter Failure needs the command-line tools its instructions call (flutter, git and dart).

Does Git Worktree Precommit Hook Flutter Failure access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktree Precommit Hook Flutter Failure safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Git Worktree Precommit Hook Flutter Failure use?

Git Worktree Precommit Hook Flutter Failure is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktree Precommit Hook Flutter Failure use?

About 1k tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Worktree Precommit Hook Flutter Failure?

Skills that share tags, products or a category with Git Worktree Precommit Hook Flutter Failure: Git Worktree Setup (k8zdev/k8z, 155 stars), Core API Change (libnativeapi/nativeapi, 157 stars), Review (getsentry/sentry-dart, 873 stars) and Rebase Main (hyochan/flutter_calendar_carousel, 860 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktree Precommit Hook Flutter Failure?

divinevideo (a GitHub organization) maintains it in divinevideo/divine-mobile, which has 265 GitHub stars. The repository holds 103 skills in this directory. The repository was last updated on October 7, 2026.

Source: divinevideo/divine-mobile on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.