Repository navigation
Closed
Labels
Description
Problem
Work can be lost when commits are made directly on main and then overwritten by sync operations. This was discovered when issue #78's implementation was lost:
19:44 - commit: fix(skills): make sub-agent usage mandatory # Made on main
19:46 - reset: moving to origin/main # 2 min later - WIPED
The commit existed only locally and was never pushed. When git reset --hard origin/main was run to sync, the work was lost. The issue was closed manually, assuming the work was done.
Root Causes
- Work done directly on main - bypassed worktree isolation
- No warning before destructive reset -
git reset --hardran without checking for unpushed commits - No verification on issue close - issues can be closed without merged PRs
Proposed Safeguards
1. Pre-reset hook (HIGH PRIORITY)
Add to pre-tool.sh - block git reset --hard if there are unpushed commits on main:
if [[ "$TOOL_INPUT" =~ "reset --hard" ]] || [[ "$TOOL_INPUT" =~ "reset.*origin" ]]; then
# Check for unpushed commits on main
unpushed=$(git log origin/main..HEAD --oneline 2>/dev/null | wc -l | xargs)
if [[ "$unpushed" -gt 0 ]]; then
echo "HOOK_BLOCKED: $unpushed unpushed commit(s) on main would be lost"
echo "Push first: git push origin main"
echo "Or stash: git stash"
exit 1
fi
fi2. Force worktree for issue work (MEDIUM PRIORITY)
Update /exec skill to REQUIRE worktree creation:
- Check if working from main at start of exec
- If on main, create worktree before any implementation
- Block implementation directly on main
3. Issue close verification (LOW PRIORITY)
Add sequant verify-closed command or post-close hook:
- For each closed issue, verify a merged PR or commit exists in main
- Alert if issue closed without evidence of merged work
Acceptance Criteria
-
git reset --hard origin/mainis blocked when unpushed commits exist on main - Warning message shows number of commits that would be lost
- Hook log records blocked reset attempts
-
/execskill refuses to implement on main without worktree - Documentation updated with worktree workflow requirements
Immediate Recovery
The lost #78 commit can be recovered from reflog:
git cherry-pick 259bfdeThis should be done to restore the sub-agent mandatory language to skills.
Related
- Issue fix: Make sub-agent usage mandatory in skills #78 - The work that was lost
- Pre-tool hook cleanup logic (lines 385-410)
Activity
fix(#85): add safeguards against losing unpushed work on main
admarble commentedon Jan 16, 2026
/fullsolve Complete
Issue: #85 - Add safeguards against losing unpushed work on main
Status: READY_FOR_MERGE
AC Coverage
git reset --hardblocked when unpushed commits on main/tmp/claude-hook.log/execskill now checks for main branch before implementationFiles Changed
.claude/hooks/pre-tool.sh- Hard reset protection hooktemplates/hooks/pre-tool.sh- Same for new installations.claude/skills/exec/SKILL.md- Main branch safeguarddocs/concepts/worktree-isolation.md- Safety documentationQuality Metrics
anytypes introducedIterations
PR: #98
Ready for human review and merge.
fix(#85): add safeguards against losing unpushed work on main (#98)