Configure gitattributes

From laurigates/claude-plugins · View interactive version

Configure gitattributes is an AI agent skill from the GitHub repository laurigates/claude-plugins. Configure .gitattributes: union-merge for append-only tables, linguist-generated for build output, LF normalization. Use when setting up .gitattributes or taming append-only merge conflicts.

How to use this skill

Skill file

/configure:gitattributes

Audit or create a repo's .gitattributes, applying the three high-value

attributes — merge=union for append-only tables, linguist-generated for

build output, and LF normalization — while never applying merge=union to a

file it would corrupt. See .claude/rules/gitattributes.md for the convention.

When to Use This Skill

| Use this skill when... | Use another approach when... |

|------------------------|------------------------------|

| A repo has no .gitattributes and wants the standard baseline | Changing a single setting in an existing file — edit it directly |

| Parallel PRs keep conflicting on an append-only table/changelog | The conflict is semantic (same line edited) — that needs a real merge |

| Onboarding a repo (also reachable via /configure:repo) | Configuring Claude Code settings — use /configure:repo |

| Build output (changelogs, lockfiles, generated trees) clutters PR diffs | — |

| — | A tool-rewritten JSON/YAML file conflicts on timestamps or counters — write a custom driver with git-plugin:git-merge-driver |

Context

Parameters

| Parameter | Description |

|-----------|-------------|

| --check-only | Report the proposed additions without writing any file |

| --fix | Apply the safe (zero-risk) additions without prompting |

Default (no flag): propose the additions, write them, and git add the file (staged, not committed).

Execution

Execute this .gitattributes configuration workflow:

Step 1: Read existing state

If a .gitattributes exists (from Context), Read it and record which paths are

already covered. Otherwise plan to create one with a header comment.

Step 2: Classify candidates into the three buckets

Build the proposed line set from the Context detections, skipping any path

already covered:

  1. LF normalization — if any *.sh is present, add * text=auto eol=lf

and *.sh text eol=lf. (No-op on an all-LF tree; protects shell shebangs.)

  1. linguist-generated (always safe — display-only, no merge effect) — add

one line per present group: **/CHANGELOG.md, .release-please-manifest.json

(if present), each */generated/** tree, docs/diagrams/*.svg, and each

lockfile found.

  1. merge=union (the risky one) — do NOT auto-apply. Identify

candidate one-line-per-entry, append-only files (e.g. a Markdown table

every PR appends a single row to). Run the one-line test from

.claude/rules/gitattributes.md. Exclude changelogs (multi-line entries),

JSON, and code.

Step 3: Decide union marks interactively

For each merge=union candidate, confirm with AskUserQuestion ("Mark

<path> as merge=union? It must be append-only with one logical entry per

line."). Apply only confirmed paths. Under --fix, skip union entirely (apply

only the zero-risk buckets) and list the candidates as recommendations.

Step 4: Write or report

create it with a header), each non-obvious line carrying a # comment for

why it qualifies. Then git add .gitattributes.

Step 5: Verify any new union mark

For each newly added merge=union line, confirm it took effect:

git check-attr merge -- <path> should report merge: union. Recommend a

sandbox check (git merge --no-ff of two divergent single-row appends → zero

conflict markers, both rows present) before relying on it.

Step 6: Report

Print a summary: lines added per bucket, union candidates deferred, and the

git diff --cached hint. If --check-only, prefix with "DRY RUN — no files modified".

Important Notes

both sides of a conflicted hunk, so on an edited line it duplicates content,

and on JSON it breaks syntax. When unsure, leave it off — the

resolve-additive-conflicts.py pre-pass (in repos that have it) union-merges

additive conflicts generically without the mark.

display and language stats, never merge behavior.

commit from breaking a shell shebang.

Agentic Optimizations

| Context | Command |

|---------|---------|

| Propose + apply safe attributes | /configure:gitattributes |

| Dry-run, no file changes | /configure:gitattributes --check-only |

| Apply zero-risk set headless (skip union prompts) | /configure:gitattributes --fix |

| Confirm a union mark took effect | git check-attr merge -- <path> |

| Review staged change | git diff --cached |

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.