trim-related-i18n-diffs
Skill3 starsChanged 8 months agoMITView on GitHub
Use when the user wants to keep only the still-uncommitted i18n changes in sibling language files that truly correspond to a known change range in one baseline Simplified Chinese file, such as any `*_zh_CN.js` file, while dropping unrelated edits from other language files in the same directory.
In this repository8 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. About 0 are common, 19 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when a commit range in one Simplified Chinese language file is the source of truth, and the task is to keep only the current …
- Distinctive: line 44
After the script finishes, proceed to Verify the trimmed result (step 6 below).
- Distinctive: line 63
If the user does not say otherwise, assume the baseline file is only used for analysis and you should trim the other currently modified …
- Distinctive: line 69
Run a diff for the baseline file over the requested range and determine the real changed keys.
- Distinctive: line 77
Do not rely on line numbers alone.
- Distinctive: line 84
When reading the patch, extract the i18n keys from changed object entries, for example lines that look like:
- Distinctive: line 92
Create the smallest possible key set from the baseline diff.
- Distinctive: line 101
Do not include unrelated neighbors just because they share nearby line numbers.
- Distinctive: line 122
Start from the baseline file's parent directory
- Very specific: line 125
If the directory contains multiple Chinese baselines such as foo_zh_CN.js and bar_zh_CN.js, only use the one the user named, or the one …
- Very specific: line 131
Use HEAD as the clean baseline
- Distinctive: line 133
Keep only edits for keys inside the relevant key set
- Very specific: line 150
If a relevant key exists in HEAD and in working tree, copy the working tree line back onto the HEAD structure
- Distinctive: line 151
If a relevant key exists only in working tree, insert it near its natural neighboring keys
- Very specific: line 152
If a relevant key exists only in HEAD and was intentionally removed in working tree, keep that removal
- Distinctive: line 154
Do not reorder the whole file unless the file was already reordered.
- Distinctive: line 158
After editing, verify that the remaining diff is limited to the relevant key set.
- Distinctive: line 170
Never revert unrelated files outside the intended i18n target set
- Distinctive: line 171
Never trust line-number overlap by itself
- Distinctive: line 172
Prefer key-based matching over hunk-based matching
- Very specific: line 181
Read each target file from HEAD
- Distinctive: line 182
Read each target file from working tree
- Distinctive: line 184
Write back only if the rebuilt file differs from the current working tree
- Distinctive: line 190
When reporting back to the user, summarize:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
Trim Related I18n Diffs
Use this skill when a commit range in one Simplified Chinese language file is the source of truth, and the task is to keep only the current uncommitted changes in sibling i18n files that correspond to those real changes.
Typical requests:
- "Keep only the uncommitted translation changes in sibling language files that truly correspond to the real changes in a baseline
*_zh_CN.jsfile." - "Use the diff of a
*_zh_CN.jsfile as the source of truth, then trim unrelated pending edits from other language files in the same directory." - "Extract the actual changed i18n keys from a Chinese baseline file and preserve only those still-uncommitted edits in other locale files."
- "Do not keep changes by raw line-number overlap alone; determine which keys were really changed and keep only matching edits in sibling translations."
Goal
Turn a noisy set of uncommitted i18n edits into a focused diff that keeps only the changes that are semantically tied to a baseline file's real modifications.
Quick Start — Automated Script
A shell script automates steps 1-5 of the workflow below. Run it directly:
# Resolve paths relative to the repo root
SKILL_DIR="<skill-directory>"
# Auto-discover all modified sibling .js files
bash "$SKILL_DIR/trim-i18n-diffs.sh" path/to/lang_zh_CN.js abc123..HEAD
# Or pass explicit target files
bash "$SKILL_DIR/trim-i18n-diffs.sh" path/to/lang_zh_CN.js abc123..HEAD \
path/to/lang_ja.js path/to/lang_ko.jsThe script will:
- Extract changed keys from the baseline diff
- Auto-discover modified sibling
.jsfiles (or use explicit targets) - Trim each target: keep only uncommitted edits for relevant keys, revert everything else to HEAD
- Print a summary of trimmed files and remaining diff stats
After the script finishes, proceed to Verify the trimmed result (step 6 below).
To verify that the remaining diff only touches relevant keys, run:
bash "$SKILL_DIR/verify-trim.sh" path/to/lang_zh_CN.js abc123..HEADThe script exits 0 when every target file is clean and exits 1 if unexpected keys are found.
Inputs To Identify
Gather these inputs before editing:
- A commit range, usually
A..B - One baseline i18n file inside that range, matching
*_zh_CN.js - The current uncommitted target files, discovered from sibling language files in the same directory
- Whether the baseline file itself should stay untouched
If the user does not say otherwise, assume the baseline file is only used for analysis and you should trim the other currently modified sibling language files in the same directory.
Workflow
1. Inspect the baseline diff
Run a diff for the baseline file over the requested range and determine the real changed keys.
Preferred command pattern:
git diff <range> -- <baseline-file>Do not rely on line numbers alone. Treat these as the real changes:
- Added keys
- Removed keys
- Renamed keys
- Existing keys whose values changed and therefore imply corresponding translation updates elsewhere
When reading the patch, extract the i18n keys from changed object entries, for example lines that look like:
'reset' : '重置',2. Build the relevant key set
Create the smallest possible key set from the baseline diff.
Include:
- Added keys
- Removed keys
- Replacement pairs such as
foo.oldandfoo.new - Existing keys whose text changed in the baseline file
Do not include unrelated neighbors just because they share nearby line numbers.
3. Find the uncommitted candidate files
List the currently modified sibling language files in the same directory as the baseline file and narrow to the intended scope.
Preferred command pattern:
git diff --name-only -- <baseline-dir>/*.js
git status --shortUsually this means:
all `*.js` language files in the same directory as the chosen `*_zh_CN.js`Selection rules:
- Start from the baseline file's parent directory
- Discover sibling files in that directory instead of hardcoding one filename pattern when possible
- Exclude the baseline
*_zh_CN.jsitself unless the user explicitly asks to trim it too - If the directory contains multiple Chinese baselines such as
foo_zh_CN.jsandbar_zh_CN.js, only use the one the user named, or the one whose diff range was explicitly provided
4. Trim each target file against HEAD
For each modified target file:
- Use
HEADas the clean baseline - Compare
HEADcontent with the working tree content - Keep only edits for keys inside the relevant key set
- Revert all other uncommitted edits in that file
This is the important rule:
- Preserve current working tree content for relevant keys
- Preserve
HEADcontent for irrelevant keys
That means the output file should effectively be:
HEADfile content- plus only the working tree edits for relevant keys
5. Handle add, remove, rename correctly
Key-specific handling:
- If a relevant key exists in
HEADand in working tree, copy the working tree line back onto theHEADstructure - If a relevant key exists only in working tree, insert it near its natural neighboring keys
- If a relevant key exists only in
HEADand was intentionally removed in working tree, keep that removal
Do not reorder the whole file unless the file was already reordered. Prefer minimal diffs.
6. Verify the trimmed result
After editing, verify that the remaining diff is limited to the relevant key set.
Recommended checks:
git diff --stat -- <targets>git diff -- <sample-target>- spot-check 2 to 3 representative files
The remaining hunks should only touch keys from the relevant key set. If unrelated strings like search, AI, or text mode keys remain, the trim was too broad and should be corrected.
Safe Editing Rules
- Never revert unrelated files outside the intended i18n target set
- Never trust line-number overlap by itself
- Prefer key-based matching over hunk-based matching
- Preserve file encoding, LF endings, and existing formatting
- Make the smallest possible diff that satisfies the user's request
Practical Strategy
For many sibling language files, scripting the trim is safer than manual editing. Use the provided trim-i18n-diffs.sh script when possible. If manual editing is needed, a reliable approach is:
- Extract relevant keys from the baseline range diff
- Read each target file from
HEAD - Read each target file from working tree
- Rebuild the output from
HEAD, overlaying only relevant key changes from the working tree - Write back only if the rebuilt file differs from the current working tree
This approach is especially useful when many language files contain mixed relevant and irrelevant edits.
Output Expectations
When reporting back to the user, summarize:
- Which baseline file and commit range were used
- Which key groups were identified as real changes
- Which target files were trimmed
- That unrelated uncommitted edits in those files were removed
- Any assumptions you made
Example Fit
This skill is a strong fit for workflows like:
- baseline: any sibling file matching
*_zh_CN.js - targets: other modified language files in the same directory
- range:
<sha>..HEAD
Where the goal is to keep only the still-uncommitted translation changes in sibling files that truly map to the baseline file's changed keys.
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
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.

