worktree-outer-ls-mistaken-for-main-state

Verify file existence on origin/main using git plumbing instead of outer-repo filesystem listings.

3|Updated May 8, 2026
One-click install
npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill worktree-outer-ls-mistaken-for-main-state-wan-huiyan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: worktree-outer-ls-mistaken-for-main-state
Source: https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/worktree-outer-ls-mistaken-for-main-state
Command: npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill worktree-outer-ls-mistaken-for-main-state-wan-huiyan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? In a multi-worktree git setup, running ls or find on the outer repo's path shows whatever branch that working tree happens to be on — not main. Handoff docs and PR bodies that cite files as "on main" based on those listings ship fabricated claims that fail reviewer dead-reference checks. The same frame inversion makes git diff/git status run after a cd to the base repo show a different branch's working tree, making your own changes appear to vanish. ## Core Features & Use Cases - Ref-exact verification: Replace outer-repo ls/find with git ls-tree origin/main, git show origin/main:<path>, and git log --all to check whether a file truly exists on main. - Pre-PR citation audit: A grep-driven loop that extracts every cited path from a handoff doc or PR body and checks each against origin/main, flagging anything missing before push. - Wrong-cwd diagnosis: Discipline for the v1.1 variant — run git from your worktree (or git -C <worktree>), never cd to the base repo, and confirm with git rev-parse --show-toplevel before concluding a parallel session reverted your work. - Use Case: Before merging a handoff doc that claims "session_184 prompt is on main, unconsumed", run the citation audit, discover the file lives only in a sibling worktree, and rewrite the claim before review catches it. ## Quick Start Ask the agent to verify whether a specific file exists on origin/main using git ls-tree instead of listing the outer repo directory.

Frequently Asked Questions about worktree-outer-ls-mistaken-for-main-state

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if a file exists on origin/main in git?▼

Use git ls-tree --name-only origin/main <path> to check existence, or git show origin/main:<path> to read its content. Run git fetch origin main first so the local ref is current, and never rely on ls of a working tree.

Why does ls of my repo show files that are not on main?▼

In a multi-worktree setup, the outer repo's working tree is checked out to whatever branch someone last switched it to, which may be a sibling worktree's feature branch. Listing that directory shows that branch's files, not main's state.

Why did my git changes disappear after running git status?▼

If you cd'd into the base repo before running git status or git diff, git reports that working tree's branch and uncommitted edits, not your worktree's. Check git rev-parse --show-toplevel and run git from your worktree or use git -C <worktree-path>.

How do I find which branch contains a file in git?▼

Run git log --all --oneline -- <path> to find commits touching the file, then git branch -a --contains <commit> to list every ref that includes it. If origin/main is absent, the file is not on main.

Can I verify remote main files without trusting local git refs?▼

Yes, use gh api repos/<owner>/<repo>/contents/<path>?ref=main as a remote-only fallback when the local origin/main ref may be stale. It is heavier than git ls-tree, so prefer fetching and using local plumbing when possible.