Skip to content

feat: add opt-in Codex skill deduplication (Draft RFC) - #284

Closed
hhh2210 wants to merge 2 commits into
runkids:mainfrom
hhh2210:docs/codex-skill-dedup
Closed

hhh2210 wants to merge 2 commits into
runkids:mainfrom
hhh2210:docs/codex-skill-dedup

Conversation

@hhh2210

@hhh2210 hhh2210 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Experimental implementation / Draft RFC

Problem and resulting behavior

Codex can discover the same skill through multiple synced roots and nested reference copies, even when each Skillshare target is healthy. Add an explicit repair command that operates on Codex's actual catalog without changing ordinary sync behavior:

skillshare dedup codex          # preview
skillshare dedup codex --json   # structured plan and manual-review cases
skillshare dedup codex --apply  # back up, disable duplicate paths, verify

The command starts the installed codex app-server and uses catalog/config methods only; it does not start a model thread or turn. It compares complete same-name user skill folders, including supporting files, invocation metadata, empty directories, and executable bits. It prefers the shared source, then the shallower path, then lexical order. An entire group is left for manual review if variants differ or include plugin/repository/system entries, internal symlinks/special files, or parent-relative Markdown references.

On apply, it rechecks the preview, saves a private config backup, writes per-path disables through Codex's native API, and verifies expected enabled states, including unaffected entries. Repeating a successful repair is a no-op. Skill files and Skillshare sync settings are preserved. JSON errors include acknowledged writes and verification state; partial failures do not blindly restore an entire config over concurrent edits.

Linked issue and scope

Refs #135; reproduction and design discussion.

This is runnable reference code for maintainer discussion, not a request to silently enable deduplication during sync. It does not implement adopt, resolve conflicting variants, manage plugin catalogs, or guarantee that the remaining description catalog fits Codex's context budget. Overrides are path-specific; installations that introduce new paths require a fresh preview. Existing Codex sessions may need a restart.

Validation

  • make check passed on macOS, plus focused checks after the final folder-fingerprint adjustment:
    • go test -race ./internal/codexskills
    • SKILLSHARE_TEST_BINARY=.../bin/skillshare go test -race ./tests/integration -run '^TestDedup' -count=1
  • Offline CLI/protocol fixture: four identical entries → one; preview leaves settings untouched; apply preserves the original settings and skill files; repeat performs zero writes. The fixture rejects any unexpected method, including model thread/turn calls.
  • Regression coverage: reference/metadata/content/permission/empty-directory differences, aliases, disabled entries, protected scopes, parent-relative references, stale previews, incomplete catalogs, partial write failures, failed verification, and JSON argument errors.
  • Real Codex CLI 0.155.0: temporarily re-enabled one previously identified identical copy, verified preview, ran the new command with --apply, observed one acknowledged disable and successful native catalog verification, then confirmed a repeated apply wrote nothing. The original 83 disabled paths were restored and unrelated settings were unchanged. Codex's native API normalizes default-enabled overrides, so config array order can change.
  • Bash/zsh completion syntax and git diff --check passed.
  • Docker/devcontainer was unavailable locally; local checks used Go 1.27.1. GitHub CI passed on the current head: unit tests, Linux/macOS integration tests, Docker offline sandbox, and red-team. Website build passed. Fork-restricted jobs and deployment were skipped.

Diff accounting: production +520/-1; tests +549/-0; docs +93/-0. No new dependencies.

Checklist

  • Read CONTRIBUTING.md; this is an explicitly scoped Draft RFC implementation for discussion
  • Linked to the existing issue
  • Local checks and meaningful regression tests passed
  • No unrelated changes
  • Default sync behavior unchanged

@hhh2210 hhh2210 changed the title docs: document Codex-only workaround for duplicate skill entries feat: add opt-in Codex skill deduplication (Draft RFC) Sep 18, 2026
@runkids

runkids commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Thanks for digging into this — the duplicate entries in Codex are a real problem.

After checking Codex's docs and source, I think the cause is on our side rather than something to clean up after the fact:

  • Codex's Build skills docs list $HOME/.agents/skills as the only user-level location. ~/.codex/skills is still read, but the source marks it as deprecated and kept only for backward compatibility.
  • The same docs page says: "If two skills share the same name, Codex doesn't merge them; both can appear in skill selectors."
  • skillshare init adds universal (~/.agents/skills) next to codex (~/.codex/skills), which writes every skill into both places Codex reads.

So I've changed the built-in codex target to use ~/.agents/skills, matching the official docs (69d6435, on main, in the next release). New setups then write each skill once and the duplicates never appear. Existing configs aren't touched.

If you're hitting this today, the fix is to drop the codex target — Codex already picks everything up through universal:

skillshare target remove codex --dry-run   # preview
skillshare target remove codex
skillshare sync

skillshare doctor will suggest the same thing when it sees this overlap.

Because of that I'd rather not add a Codex-specific dedup command: it depends on Codex's app-server, so it can't cover other tools with overlapping paths, and it treats the symptom while the default config keeps producing it. I'll leave this PR open for reference until the path change is released, then close it. Thanks again for the detailed write-up.

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.

2 participants