Skip to content

Commit 78582ba

Browse files
committed
Merge branch 'feature/common'
2 parents bbeb191 + 7d4ddc1 commit 78582ba

16 files changed

Lines changed: 1149 additions & 2029 deletions

File tree

.agents/skills/repo-diff-commit-planner/SKILL.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Analyze repository differences, group related changes into logical
77

88
## Overview
99

10-
Use this skill to inspect current repository differences, decide what is ready to commit, split the work into logical commit groups, and then execute the git staging and commit steps for all commit-ready groups. It focuses on clean grouping, safe execution, and a buildable commit sequence.
10+
Use this skill to inspect current repository differences, decide how to group them, and then execute the git staging and commit steps so tracked worktree changes are fully resolved by default. It first checks whether the local branch should be synced from its remote upstream, then proceeds with clean grouping, safe execution, and a buildable commit sequence with no leftover tracked modifications unless the user explicitly says not to commit something or a real blocker prevents normal staging. Ignored local-only files are not candidates for normal commits.
1111

1212
## When To Use
1313

@@ -24,24 +24,40 @@ Use this skill to inspect current repository differences, decide what is ready t
2424
## Inputs Needed
2525

2626
- Current branch and repository context.
27+
- Upstream tracking and remote status for the current branch when available.
2728
- `git status` and diff summaries for changed files.
2829
- Any known constraints, such as release urgency or risky files.
2930
- Build or test command when verification is expected.
3031

3132
## Workflow
3233

34+
### 0. Upstream Sync Check
35+
36+
- At the start, inspect the current branch, its upstream tracking branch, and whether a normal remote sync is possible.
37+
- If a remote and upstream are configured, fetch first so ahead/behind state is current.
38+
- If the upstream branch is ahead and the branch has not diverged, sync before planning by attempting a normal non-interactive fast-forward pull such as `git pull --ff-only`, even when the worktree is already dirty.
39+
- If that pull fails because local changes would be overwritten, files would conflict, or Git refuses the fast-forward update, stop and report the sync blocker instead of guessing a recovery strategy.
40+
- If the branch has diverged from upstream, stop and report it instead of choosing a merge or rebase strategy automatically.
41+
- If there is no upstream tracking branch or no reachable remote, continue with the local repository state and mention that assumption in the final report.
42+
3343
### 1. Inventory Repository Differences
3444

3545
- List changed, untracked, deleted, and renamed files.
3646
- Summarize change scope by area (feature, bugfix, docs, config, tests, refactor).
3747
- Identify potentially sensitive or generated files that should not be committed.
48+
- Check whether any candidate file is ignored by `.gitignore`, `.git/info/exclude`, or a global excludes file before staging it.
3849

3950
### 2. Commit-Readiness Analysis
4051

4152
- Mark each change as `commit-now`, `hold`, or `needs-review`.
4253
- Check dependency links between files to avoid broken intermediate commits.
4354
- Highlight risky changes needing explicit confirmation.
44-
- Aim to commit every `commit-now` group before finishing the task.
55+
- Default every discovered change to `commit-now`.
56+
- Use `hold` only when the user explicitly says a path or group must not be committed.
57+
- Use `needs-review` only for a true technical blocker that prevents normal staging or would require a non-trivial policy change.
58+
- Ignored untracked files stay local-only by default and do not need to be committed.
59+
- Ignored tracked files should be treated as repository hygiene issues: remove them from version control and commit that removal unless the user explicitly says otherwise.
60+
- Aim to finish with no leftover tracked modified or staged files unless the user explicitly excluded them or a blocker was reported.
4561

4662
### 3. Logical Grouping
4763

@@ -69,6 +85,11 @@ Use this skill to inspect current repository differences, decide what is ready t
6985

7086
- Stage only the files that belong to the current group.
7187
- Commit each group with the drafted message using non-interactive git commands.
88+
- If `git add` reports that a path is ignored, do not use `git add -f` or any force-add switch as a shortcut.
89+
- When an ignored file seems to be showing up in status anyway, diagnose whether it is already tracked with `git ls-files` and confirm the matching ignore rule with `git check-ignore -v --no-index` before changing anything.
90+
- If an ignored file is already tracked, do not recommit it as normal content. Prefer removing it from version control with `git rm --cached`, then commit that removal so the file becomes local-only and ignored again.
91+
- If an ignored file is untracked, leave it local-only and ignored. Do not treat it as a commit blocker unless the user explicitly asks to version it or to change ignore policy.
92+
- If the user explicitly wants an ignored tracked file to remain versioned, stop and call out that this conflicts with the ignore policy before proceeding.
7293
- If a git command fails because of `.git/index.lock` or a likely concurrent git process, wait a few seconds and retry before treating it as a blocker.
7394
- Preferred retry behavior for transient git locking:
7495
- wait about 2 to 5 seconds
@@ -78,6 +99,7 @@ Use this skill to inspect current repository differences, decide what is ready t
7899
- After each commit, verify the worktree and confirm the next group is still valid.
79100
- If build or tests are part of the expected verification, run them at the appropriate point.
80101
- Continue until all `commit-now` groups are committed or a real blocker is reached.
102+
- Do not stop early just because some changes look secondary; if they are still modified and not explicitly excluded, they must be grouped and committed before finishing.
81103

82104
### 7. Final Reporting
83105

@@ -93,18 +115,29 @@ Use this skill to inspect current repository differences, decide what is ready t
93115
- Report any deferred `hold` or `needs-review` items left in the worktree.
94116
- State any verification commands that were run and their result.
95117
- State whether push succeeded or failed.
118+
- If anything remains tracked and modified or staged at the end, explain exactly why it was not committed and whether that came from an explicit user instruction or a blocking constraint.
119+
- If ignored local-only files remain, mention them only when they are relevant to explain an untrack action or a policy conflict.
120+
- Prefer a short close-out when the run is clean: brief repository summary, compact list of created commits, push result, and any truly relevant leftover note.
121+
- Expand to the fuller report structure only when there are deferred items, blockers, non-obvious grouping decisions, risky files, sync problems, or a failed push.
96122

97123
## Output Format
98124

99125
Keep the final report concise by default. Compress file-by-file detail unless it is needed to explain grouping or a deferred risk.
100126

101-
Provide results using this structure:
127+
For clean runs, prefer a compact format such as:
128+
129+
- short repository change summary
130+
- compact execution results like `<hash> [YYYY-MM-DD] <subject>`
131+
- push result
132+
- deferred items only if any remain
133+
134+
Use the fuller structure below only when the run is not clean or when the user explicitly asks for more detail:
102135

103136
1. Repository change summary
104137
2. Commit readiness table (`commit-now` / `hold` / `needs-review`)
105138
3. Proposed commit groups with short rationale
106139
4. Ordered commit plan
107-
5. Draft commit messages (subject and optional body when needed)
140+
5. Draft commit messages when they add value
108141
6. Execution result per committed group
109142
7. Push result
110143
8. Deferred items and assumptions
@@ -115,17 +148,23 @@ Prefer:
115148
- compact execution results like `<hash> [YYYY-MM-DD] <subject>`
116149
- compact push result like `push succeeded` or `push failed: non-fast-forward`
117150
- brief deferred-item notes
151+
- omit sections such as draft messages or readiness tables when they add no signal in a clean run
118152

119153
Only expand beyond that when:
120154
- a group boundary is non-obvious
121155
- a risky file is being held back
156+
- the run was blocked or partially complete
122157
- the user explicitly asks for a detailed breakdown
123158

124159
## Execution Guardrails
125160

126161
- Do not use destructive commands such as `git reset --hard`, `git checkout --`, or force-push unless explicitly requested.
162+
- Do not use `git add -f`, `git add --force`, or similar overrides to stage ignored files unless the user has explicitly confirmed that bypassing ignore rules is intended.
127163
- Do not amend commits unless explicitly requested.
128-
- Do not commit files marked `hold` or `needs-review` just to empty the worktree.
164+
- Do not leave tracked modifications behind by default; commit them unless the user explicitly excluded them.
165+
- Do not commit ignored files as normal repository content.
166+
- If a tracked file is covered by ignore rules, prefer untracking it and committing the removal rather than recommitting its contents.
167+
- Do not commit files marked `hold` or `needs-review` just to empty the worktree, but also do not invent `hold` items unless the user explicitly asked for them or a real blocker exists.
129168
- If unexpected changes appear during execution, stop and report the issue before continuing.
130169
- Keep commits scoped, reviewable, and logically ordered.
131170
- Treat transient git lock errors as retryable first, not as immediate hard failures.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: repo-sync-branch-into-main
3+
description: Verify a branch is fully synced, switch to mainline, refresh mainline, and merge the branch into main locally.
4+
---
5+
6+
# Repo Branch Into Main Sync
7+
8+
## Overview
9+
10+
Use this skill when the goal is to bring the current non-main branch onto the repository's mainline branch. The skill verifies that the source branch is fully synced with its remote upstream first, switches to the detected mainline branch, refreshes mainline from remote again, and then merges the source branch into mainline locally. The default outcome is a local mainline merge result that can be reviewed and pushed afterward.
11+
12+
## When To Use
13+
14+
- You want to bring the current feature, fix, or release branch onto `main` or `master`.
15+
- You want a repeatable promotion flow with explicit upstream checks before touching mainline.
16+
- You want mainline refreshed from remote immediately before merging the source branch.
17+
- You want the branch promotion captured locally on mainline, typically as an explicit merge commit.
18+
19+
## When Not To Use
20+
21+
- Do not use this skill for rebases, cherry-picks, or history rewrites.
22+
- Do not use this skill when the source branch still needs local commits, push, or pull work before promotion.
23+
- Do not use this skill when you want automatic mainline push as part of the default flow.
24+
- Do not use this skill to guess a source branch while already on `main` or `master` unless the user explicitly names the branch to merge.
25+
26+
## Inputs Needed
27+
28+
- Current branch name.
29+
- Upstream tracking state for the current branch.
30+
- Detected mainline branch, preferring `main`, then `master`, then the remote default branch when discoverable.
31+
- Optional explicit source branch if the current branch is already the detected mainline branch.
32+
33+
## Workflow
34+
35+
### 0. Detect Branch Roles
36+
37+
- Detect the mainline branch in this order:
38+
- local `main`
39+
- local `master`
40+
- the branch pointed to by `origin/HEAD`, if available
41+
- If no mainline branch can be determined, stop and report that blocker.
42+
- If the current branch is not the detected mainline branch, treat the current branch as the source branch.
43+
- If the current branch is already the detected mainline branch, require the user to explicitly name the source branch to merge. Do not guess from checkout history or reflog.
44+
45+
### 1. Source Branch Sync Gate
46+
47+
- Fetch remotes first so branch status is current.
48+
- Verify that the source branch has an upstream tracking branch.
49+
- Verify that the source branch is fully synced with upstream: ahead `0` and behind `0`.
50+
- If the source branch is ahead, behind, or diverged, stop and report that the branch must be fully synced before promotion.
51+
- Verify the worktree has no tracked modifications or staged changes before switching branches.
52+
- Ignored local-only files may remain as long as they do not block checkout or merge.
53+
- If checkout would be blocked by local files, stop and report the exact blocker instead of stashing automatically.
54+
55+
### 2. Switch To Mainline And Refresh It
56+
57+
- Checkout the detected mainline branch.
58+
- Fetch again after switching so mainline state is current at the moment of promotion.
59+
- If mainline has an upstream and is behind but not diverged, sync it with a normal non-interactive fast-forward pull such as `git pull --ff-only`.
60+
- If mainline is ahead of upstream, leave those local mainline commits intact and continue unless the user explicitly wants a different policy.
61+
- If mainline has diverged from upstream, stop and report it instead of choosing merge or rebase automatically.
62+
63+
### 3. Bring Source Branch Onto Mainline
64+
65+
- Merge the source branch into mainline locally.
66+
- Default to an explicit local merge commit by using a non-interactive merge such as `git merge --no-ff --no-edit <source-branch>`.
67+
- If the source branch is already fully contained in mainline, report that mainline is already up to date and stop without creating a new commit.
68+
- If Git reports merge conflicts, stop and report the conflicted state clearly. Do not auto-resolve conflicts.
69+
70+
### 4. Post-Merge State
71+
72+
- After a successful merge, report the resulting mainline commit state and whether the branch is now ahead of remote.
73+
- Do not push mainline by default. The default endpoint of this skill is a local mainline merge result ready for review or a later explicit push.
74+
- If the user explicitly asks to push after the merge, only then perform a normal push and report the result.
75+
76+
## Final Reporting
77+
78+
- For a clean successful run, keep the summary short:
79+
- source branch
80+
- detected mainline branch
81+
- whether source was already fully synced
82+
- whether mainline was refreshed from remote
83+
- resulting merge commit or "already up to date"
84+
- whether mainline is now ahead of remote locally
85+
- Expand only when there are blockers, sync mismatches, conflicts, or the user asks for more detail.
86+
87+
## Execution Guardrails
88+
89+
- Do not use destructive commands such as `git reset --hard`, `git checkout --`, force-push, or history rewriting unless explicitly requested.
90+
- Do not auto-stash or auto-commit local work to make the branch switch succeed.
91+
- Do not promote a source branch that is not fully synced with its remote upstream.
92+
- Do not guess a merge strategy beyond the default local merge commit flow.
93+
- Do not auto-push mainline unless the user explicitly asks for it.
94+
- Do not suppress checkout, pull, or merge blockers; report them clearly.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Repo Branch Into Main Sync"
3+
short_description: "Sync a branch and bring it onto main"
4+
default_prompt: "Use $repo-sync-branch-into-main to verify the current branch is fully synced with remote, switch to the detected mainline branch, refresh mainline from remote, and merge the branch into main locally."

0 commit comments

Comments
 (0)