Skip to content

Conversation

@Cygnusfear
Copy link

@Cygnusfear Cygnusfear commented Jan 18, 2026

Enables skill discovery to follow symlinked directories, allowing developers to symlink skills from shared locations (dotfiles repos, cross-agent skill collections).

Key Changes

  • Follow symlinked directories for User and Repo scoped skills
  • System skills still skip symlinks (security: managed by the tool)
  • Add cycle detection via visited set to prevent infinite loops
  • Add 3 unit tests covering all scenarios

How Symlink Following Works

flowchart TD
    A[Discover Skills] --> B{Is Symlink?}
    B -->|No| C[Process normally]
    B -->|Yes| D{Scope?}
    D -->|System| E[Skip - security]
    D -->|User/Repo| F{Points to dir?}
    F -->|No| G[Skip file symlinks]
    F -->|Yes| H{Already visited?}
    H -->|Yes| I[Skip - cycle detection]
    H -->|No| J[Add to queue & visited set]
Loading

Related Issues

Related (upstream):

This PR brings the symlink fix to Every Code, since the upstream Codex rejected it.

Testing

  • Unit tests added: follows_symlinked_directory_for_user_scope, ignores_symlinked_directory_for_system_scope, handles_circular_symlink_without_infinite_loop
  • Manual testing: symlinked skill directory successfully discovered and loaded

Files Changed

  • code-rs/core/src/skills/loader.rs - Symlink following logic + tests
  • docs/skills.md - Updated docs to reflect new behavior

Previously, symlinks were unconditionally skipped during skill discovery.
This made it impossible to symlink skill directories from a shared location
(e.g., a dotfiles repo or cross-agent skill collection).

Changes:
- Follow symlinked directories for User and Repo scoped skills
- System skills still skip symlinks (security: managed by the tool)
- Add cycle detection to prevent infinite loops from circular symlinks
- Symlinked files are not followed (only symlinked directories)
- Add unit tests for all three scenarios

This aligns with user expectations - if you can write to ~/.code/skills/,
you can already create real directories there, so symlinks pose no
additional security risk for user-scoped skills.

Fixes common workflow where developers symlink skills from:
- A shared dotfiles repository
- A cross-agent skills collection (Claude Code, Codex, Cursor, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 593d2a3815

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 324 to 326
use super::*;
use std::os::unix::fs::symlink;
use tempfile::TempDir;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard Unix-only symlink use in tests

These new tests unconditionally import std::os::unix::fs::symlink, which is unavailable on Windows. As a result, cargo test on Windows will fail to compile this module even before running tests. If Windows CI/devs run tests (the repo ships Windows builds), this becomes an immediate test break. Consider adding #[cfg(unix)] to the test module or providing a Windows-specific symlink helper (e.g., std::os::windows::fs::symlink_dir) to keep tests portable.

Useful? React with 👍 / 👎.

Uses std::os::unix::fs::symlink on Unix and std::os::windows::fs::symlink_dir
on Windows, allowing tests to run on both platforms.
@Cygnusfear Cygnusfear force-pushed the feat/follow-symlinked-skills branch from 2e2f32d to 10cbe90 Compare January 18, 2026 09:47
@Cygnusfear
Copy link
Author

Thanks for the review! Fixed in 10cbe90.

Added a cross-platform symlink_dir helper that uses:

  • std::os::unix::fs::symlink on Unix
  • std::os::windows::fs::symlink_dir on Windows

Tests now run on both platforms.

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.

1 participant