SuperAPI AI Directory

create-symlink

General & other

View repository

Updated 10-16 09:35

About this skill

Create Symlink

Instructions

When the user needs to create a symlink, first detect the operating system type, then use the corresponding command:

1. Detect the operating system

The AI determines the current system in the following ways:

  1. Check the system information in environment variables: such as process.platform(in a Node.js environment)
  2. Analyze the path format provided by the user:
    • Windows path:C:\Users\... or D:\...
    • macOS path:/Users/username/... or ~/...
    • Linux path:/home/username/... or ~/...
  3. Ask the user directly: when it cannot be determined, ask the user which operating system they are currently using

System identifier:

  • Windows: win32
  • macOS: darwin
  • Linux: linux

2. Create a directory symlink

Windows (PowerShell):

New-Item -ItemType SymbolicLink -Path "目标路径" -Target "源路径"

Windows (CMD):

mklink /D "目标路径" "源路径"

macOS / Linux:

ln -s "源路径" "目标路径"

3. Create a file symlink

Windows (PowerShell):

New-Item -ItemType SymbolicLink -Path "目标文件路径" -Target "源文件路径"

Windows (CMD):

mklink "目标文件路径" "源文件路径"

macOS / Linux:

ln -s "源文件路径" "目标文件路径"

4. Create a hard link (file)

Windows (CMD):

mklink /H "目标文件路径" "源文件路径"

macOS / Linux:

ln "源文件路径" "目标文件路径"

Use cases

Use this skill when the user:

  • Needs to share the same directory or file in different locations
  • Wants to create a shortcut but keep the original path reference
  • Needs to access files across directories without copying
  • Wants to manage configuration files or resources in a unified way
  • Links dependency directories in a development environment
  • Needs to migrate a large folder but keep the original path available

Notes

Permission requirements

  • Windows: Creating symlinks usually requires administrator privileges (developer mode can exempt this)
  • macOS / Linux: Regular users can create symlinks, but may need permissions to link to certain system directories

Path format

  • Windows: Use full paths, such as C:\Users\name\folder or "C:\Users\name\folder"
  • macOS / Linux: Use full paths, such as /home/user/folder or ~/folder
  • Avoid using relative paths, especially in scripts

Target existence

  • The source path must exist to create a symlink
  • The target path must not already exist (file or directory)

Cross-file system

  • Symlinks can be created across file systems
  • Hard links cannot be created across file systems

Examples for each platform

Windows example

Create a directory symlink

New-Item -ItemType SymbolicLink -Path "D:\shared\tools" -Target "C:\tools"

Create a file symlink

New-Item -ItemType SymbolicLink -Path "C:\Users\Public\Desktop\config.json" -Target "D:\MyConfigs\main-config.json"

macOS example

Create a directory symlink

ln -s /Users/username/Documents/work /Users/username/Desktop/work-link

Create a file symlink

ln -s ~/.config/app/settings.json ~/Desktop/settings-link.json

Linux example

Create a directory symlink

ln -s /home/user/projects/myapp /var/www/myapp

Create a file symlink

ln -s /etc/nginx/sites-available/my-site /etc/nginx/sites-enabled/my-site

Verify the link

Windows

# 查看链接详情
Get-ChildItem "链接路径"

# 查看是否为符号链接
(Get-Item "链接路径").Attributes

macOS / Linux

# 查看链接详情
ls -la "链接路径"

# 验证链接指向
readlink "链接路径"

# 查看链接和源文件
ls -la "链接路径" "源路径"

Delete the symlink

Windows

# 删除软链接(不要加 -Recurse,否则会删除源文件)
Remove-Item "链接路径"

macOS / Linux

# 删除软链接(不要加 -r,否则会删除源文件)
rm "链接路径"

# 或
unlink "链接路径"

Usage guide

Quick start

See QUICK-REF.md for a quick reference card

Detailed guide

For detailed usage instructions, refer to the USAGE.md file, which includes:

  • Various trigger keywords
  • Complete conversation examples
  • Common use cases
  • Notes and reminders