Skip to content

fix: avoid duplicate Codex skill discovery#236

Closed
shichangs wants to merge 2 commits into
garrytan:mainfrom
shichangs:codex/fix-codex-duplicate-skills
Closed

fix: avoid duplicate Codex skill discovery#236
shichangs wants to merge 2 commits into
garrytan:mainfrom
shichangs:codex/fix-codex-duplicate-skills

Conversation

@shichangs

@shichangs shichangs commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix duplicate Codex skill discovery when gstack is installed directly into ~/.codex/skills/gstack.

This changes the Codex setup flow so we no longer expose the full repo under the Codex skills root, which was letting Codex recursively discover both:

  • source skill directories in the repo checkout
  • generated Codex skills linked at the top level

That produced duplicate entries in the skill picker because both copies shared the same name: frontmatter.

What changed

  • migrate direct Codex installs from ~/.codex/skills/gstack to ~/.gstack/repos/gstack during ./setup --host codex
  • create a minimal ~/.codex/skills/gstack runtime root instead of symlinking the whole repo
  • keep only the runtime assets Codex skills actually need in that runtime root:
    • root SKILL.md
    • bin/
    • browse/bin
    • browse/dist
    • gstack-upgrade/SKILL.md
    • review/checklist.md, review/design-checklist.md, review/greptile-triage.md, review/TODOS-format.md (individual files, not the whole review/ dir which contains its own SKILL.md)
  • update the Codex install docs to recommend cloning outside ~/.codex/skills
  • add setup validation tests that lock in the new layout and migration behavior

Why this fixes the issue

Codex scans ~/.codex/skills recursively. Before this change, a direct install left the full gstack repo under ~/.codex/skills/gstack, so Codex could discover both the source SKILLs and the generated gstack-* Codex skills.

After this change:

  • generated Codex skills still live at the top level in ~/.codex/skills
  • ~/.codex/skills/gstack is now only a runtime sidecar, not a second discoverable skill tree
  • review assets are symlinked as individual files (not the whole review/ dir) to avoid re-introducing duplicate discovery via review/SKILL.md

That removes the duplicate discovery path without changing the absolute paths referenced by generated Codex skills.

Testing

Automated

  • bash -n setup
  • bun test test/gen-skill-docs.test.ts ✅ (88 tests pass)
  • bun run gen:skill-docs --dry-run
  • bun run gen:skill-docs --host codex --dry-run

Manual regression

  • direct-install scenario:
    • cloned gstack into ~/.codex/skills/gstack
    • ran ./setup --host codex
    • verified setup migrated the repo to ~/.gstack/repos/gstack
    • verified ~/.codex/skills/gstack became a minimal runtime root
    • verified generated gstack-* Codex skills were linked at the top level
  • normal-install scenario:
    • cloned gstack into a normal directory outside ~/.codex/skills
    • ran ./setup --host codex
    • verified the same clean Codex layout was produced

Not run

  • bun run test:e2e
  • bun run test:evals

These remain gated by the project's Tier 2 / Tier 3 eval setup.

Closes #235

liaoshichang02 and others added 2 commits March 20, 2026 13:59
Migrate direct ~/.codex/skills/gstack installs into ~/.gstack/repos/gstack during setup.\n\nCreate a minimal Codex runtime root that only exposes runtime assets and generated SKILL.md files so Codex no longer discovers duplicate source skills recursively.
Generated Codex skills (review, ship, plan-ceo-review, plan-eng-review)
reference checklist.md, design-checklist.md, greptile-triage.md, and
TODOS-format.md under .agents/skills/gstack/review/. Symlink these
individual files instead of the whole review/ dir (which contains
SKILL.md and would re-introduce duplicate discovery).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shichangs

Copy link
Copy Markdown
Contributor Author

@wmzhai @garrytan This PR is ready for review. It fixes the duplicate Codex skill discovery issue (#235) by:

  1. Migrating direct ~/.codex/skills/gstack installs to ~/.gstack/repos/gstack
  2. Creating a minimal runtime root that only exposes the specific assets Codex skills need
  3. Symlinking review assets as individual files (not the whole review/ dir) to avoid re-introducing duplicates via review/SKILL.md

@wmzhai — could you verify this fixes the duplicate skills you were seeing? After pulling, run ./setup --host codex and check the Codex skill picker.

@shichangs

Copy link
Copy Markdown
Contributor Author

@garrytan Friendly ping — this is ready for review. No conflicts with main, tests included. Happy to adjust anything.

@benpixel

Copy link
Copy Markdown

This would be useful! I have ended up with duplicate skills in codex by running:

git clone https://github.com/garrytan/gstack.git ~/.codex/skills/gstack
cd ~/.codex/skills/gstack && ./setup --host codex

garrytan added a commit that referenced this pull request Mar 23, 2026
Adds migrate_direct_codex_install() to move old direct installs from
~/.codex/skills/gstack to ~/.gstack/repos/gstack. Adds
create_codex_runtime_root() to expose only runtime assets (bin/, browse/,
review files) via symlinks instead of symlinking the entire repo.

Fixes #235

Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
garrytan added a commit that referenced this pull request Mar 23, 2026
…l installs, kiro support (v0.11.2.0) (#346)

* fix: cap gstack skill descriptions for codex (#251)

Compresses SKILL.md.tmpl root description to <1024 chars (Codex token limit).
Adds description-length validation test. Includes /autoplan in compressed
skill list (added since PR was branched).

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: skip sidecar dir in Codex skill linking (#269)

Adds guard to skip .agents/skills/gstack in link_codex_skill_dirs() —
it's a runtime asset sidecar, not a standalone skill. Prevents duplicate
skill discovery and symlink overwriting.

Fixes #261

Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: generate .agents directory at setup time instead of shipping duplicates (#308)

Removes 14K+ lines of committed generated Codex skill files from git.
.agents/ is now gitignored and generated at setup time via
`bun run gen:skill-docs --host codex`. Updates CI workflow to validate
generation instead of checking committed file freshness.

Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: avoid duplicate Codex skill discovery (#236)

Adds migrate_direct_codex_install() to move old direct installs from
~/.codex/skills/gstack to ~/.gstack/repos/gstack. Adds
create_codex_runtime_root() to expose only runtime assets (bin/, browse/,
review files) via symlinks instead of symlinking the entire repo.

Fixes #235

Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: support repo-local Codex installs (#317)

Changes gen-skill-docs.ts to use dynamic $GSTACK_ROOT/$GSTACK_BIN/$GSTACK_BROWSE
variables in generated Codex preambles instead of hardcoded ~/.codex/ paths.
Renames GSTACK_DIR → SOURCE_GSTACK_DIR/INSTALL_GSTACK_DIR throughout setup for
clarity. Supports both global (~/.codex/skills/) and repo-local (.agents/skills/)
Codex installs.

Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add --host kiro support to setup script (#309)

Adds Kiro CLI as a supported agent platform. Setup detects kiro-cli,
copies+sed-rewrites SKILL.md paths from Codex/Claude to Kiro format,
and symlinks runtime assets (bin/, browse/).

Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add sidecar skip, GSTACK_ROOT, and kiro coverage (T1-T3)

Adds 3 tests identified during CEO/Eng review:
- T1: link_codex_skill_dirs() contains sidecar skip guard
- T2: generated Codex preambles use dynamic $GSTACK_ROOT paths
- T3: setup supports --host kiro with INSTALL_KIRO and sed rewrites

Also fixes existing test to expect kiro in --host case statement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: review fixes — ETHOS.md, runtime root, repo-local guard, kiro assets, upgrade paths

Paranoid 4-pass review found 7 issues, all fixed:
- Add ETHOS.md to create_codex_runtime_root
- Clean old real dirs (not just symlinks) on upgrade
- Skip runtime root for repo-local installs (prevent self-referential symlinks)
- Add review/, ETHOS.md, gstack-upgrade/ to Kiro install
- Update gstack-upgrade to detect ~/.gstack/repos/ and .agents/skills/
- Guard --host without value from silent exit
- Fix Kiro sed patterns + timeout instruction in gen-skill-docs.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: bump version and changelog (v0.11.2.0)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove last tracked .agents/ file from git index

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
@shichangs shichangs closed this by deleting the head repository Mar 26, 2026
rapidstartup pushed a commit to rapidstartup/gstack that referenced this pull request Mar 29, 2026
…l installs, kiro support (v0.11.2.0) (garrytan#346)

* fix: cap gstack skill descriptions for codex (garrytan#251)

Compresses SKILL.md.tmpl root description to <1024 chars (Codex token limit).
Adds description-length validation test. Includes /autoplan in compressed
skill list (added since PR was branched).

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: skip sidecar dir in Codex skill linking (garrytan#269)

Adds guard to skip .agents/skills/gstack in link_codex_skill_dirs() —
it's a runtime asset sidecar, not a standalone skill. Prevents duplicate
skill discovery and symlink overwriting.

Fixes garrytan#261

Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: generate .agents directory at setup time instead of shipping duplicates (garrytan#308)

Removes 14K+ lines of committed generated Codex skill files from git.
.agents/ is now gitignored and generated at setup time via
`bun run gen:skill-docs --host codex`. Updates CI workflow to validate
generation instead of checking committed file freshness.

Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: avoid duplicate Codex skill discovery (garrytan#236)

Adds migrate_direct_codex_install() to move old direct installs from
~/.codex/skills/gstack to ~/.gstack/repos/gstack. Adds
create_codex_runtime_root() to expose only runtime assets (bin/, browse/,
review files) via symlinks instead of symlinking the entire repo.

Fixes garrytan#235

Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: support repo-local Codex installs (garrytan#317)

Changes gen-skill-docs.ts to use dynamic $GSTACK_ROOT/$GSTACK_BIN/$GSTACK_BROWSE
variables in generated Codex preambles instead of hardcoded ~/.codex/ paths.
Renames GSTACK_DIR → SOURCE_GSTACK_DIR/INSTALL_GSTACK_DIR throughout setup for
clarity. Supports both global (~/.codex/skills/) and repo-local (.agents/skills/)
Codex installs.

Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add --host kiro support to setup script (garrytan#309)

Adds Kiro CLI as a supported agent platform. Setup detects kiro-cli,
copies+sed-rewrites SKILL.md paths from Codex/Claude to Kiro format,
and symlinks runtime assets (bin/, browse/).

Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add sidecar skip, GSTACK_ROOT, and kiro coverage (T1-T3)

Adds 3 tests identified during CEO/Eng review:
- T1: link_codex_skill_dirs() contains sidecar skip guard
- T2: generated Codex preambles use dynamic $GSTACK_ROOT paths
- T3: setup supports --host kiro with INSTALL_KIRO and sed rewrites

Also fixes existing test to expect kiro in --host case statement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: review fixes — ETHOS.md, runtime root, repo-local guard, kiro assets, upgrade paths

Paranoid 4-pass review found 7 issues, all fixed:
- Add ETHOS.md to create_codex_runtime_root
- Clean old real dirs (not just symlinks) on upgrade
- Skip runtime root for repo-local installs (prevent self-referential symlinks)
- Add review/, ETHOS.md, gstack-upgrade/ to Kiro install
- Update gstack-upgrade to detect ~/.gstack/repos/ and .agents/skills/
- Guard --host without value from silent exit
- Fix Kiro sed patterns + timeout instruction in gen-skill-docs.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: bump version and changelog (v0.11.2.0)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove last tracked .agents/ file from git index

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
24601 pushed a commit to 24601/gastack that referenced this pull request Mar 29, 2026
Adds migrate_direct_codex_install() to move old direct installs from
~/.codex/skills/gstack to ~/.gstack/repos/gstack. Adds
create_codex_runtime_root() to expose only runtime assets (bin/, browse/,
review files) via symlinks instead of symlinking the entire repo.

Fixes garrytan#235

Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex: duplicate skills appear because setup installs nested SKILL.md sidecars under ~/.codex/skills/gstack

2 participants