cross-platform
Skill288 starsChanged 9 months agoMITView on GitHub
Cross-platform development patterns for macOS, Windows, and Linux
We split this skill into the rules it gives an agent
3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 229
Use .gitattributes to enforce line endings
- Very specific: line 232
Use variables like $HOME instead of hardcoded paths
- Very specific: line 238
Always check with command -v before use
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cross-Platform Development
When to Use
- Adding new platform support
- Writing platform-specific code
- Testing across platforms
Platform Detection
Bash (macOS/Linux)
detect_os() {
case "$(uname -s)" in
Darwin*) echo "macos" ;;
Linux*)
# Check for WSL
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
else
echo "linux"
fi
;;
CYGWIN*|MINGW*|MSYS*) echo "windows" ;;
*) echo "unknown" ;;
esac
}PowerShell (Windows)
function Get-Platform {
if ($IsWindows -or $env:OS -eq "Windows_NT") {
return "windows"
} elseif ($IsLinux) {
return "linux"
} elseif ($IsMacOS) {
return "macos"
}
return "unknown"
}Notification Tools by Platform
| Platform | Primary | Fallback |
| macOS | terminal-notifier | osascript |
| Linux | notify-send | zenity, wall |
| Windows | BurntToast | System.Windows.Forms |
| WSL | wsl-notify-send | notify-send |
Platform-Specific Patterns
macOS
send_macos_notification() {
local title="$1"
local message="$2"
if command -v terminal-notifier &> /dev/null; then
terminal-notifier \
-title "$title" \
-message "$message" \
-sound "Glass"
else
osascript -e "display notification \"$message\" with title \"$title\""
fi
}Linux
send_linux_notification() {
local title="$1"
local message="$2"
if command -v notify-send &> /dev/null; then
notify-send "$title" "$message" \
--urgency=normal \
--app-name="Code-Notify"
elif command -v zenity &> /dev/null; then
zenity --notification --text="$title\n$message"
else
echo "[$title] $message" | wall 2>/dev/null
fi
}Windows (PowerShell)
function Send-WindowsNotification {
param(
[string]$Title,
[string]$Message
)
if (Get-Module -ListAvailable -Name BurntToast) {
New-BurntToastNotification -Text $Title, $Message
} else {
Add-Type -AssemblyName System.Windows.Forms
$notification = New-Object System.Windows.Forms.NotifyIcon
$notification.Icon = [System.Drawing.SystemIcons]::Information
$notification.BalloonTipTitle = $Title
$notification.BalloonTipText = $Message
$notification.Visible = $true
$notification.ShowBalloonTip(10000)
}
}WSL
send_wsl_notification() {
local title="$1"
local message="$2"
if command -v wsl-notify-send.exe &> /dev/null; then
wsl-notify-send.exe --category "$title" "$message"
else
# Fall back to Linux notification
send_linux_notification "$title" "$message"
fi
}Path Handling
Unix vs Windows Paths
# Convert Unix path to Windows path (in WSL)
to_windows_path() {
local unix_path="$1"
wslpath -w "$unix_path"
}
# Convert Windows path to Unix path (in WSL)
to_unix_path() {
local win_path="$1"
wslpath -u "$win_path"
}Home Directory
# Bash
HOME_DIR="$HOME"
# PowerShell
$HomeDir = $env:USERPROFILEGit Handling Across Platforms
Safe Git Commands
# Works on all platforms
get_project_name() {
local git_root
if git rev-parse --git-dir &> /dev/null; then
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
if [[ -n "$git_root" ]]; then
basename "$git_root"
return 0
fi
fi
basename "$PWD"
}PowerShell Git Handling
function Get-ProjectName {
try {
$gitRoot = & git rev-parse --show-toplevel 2>$null
if ($LASTEXITCODE -eq 0 -and $gitRoot) {
return Split-Path $gitRoot -Leaf
}
} catch {
# Not in git repo
}
return Split-Path (Get-Location) -Leaf
}Testing Strategy
CI/CD Matrix
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]Platform-Specific Tests
# test/test-platform.sh
test_current_platform() {
local os=$(detect_os)
case "$os" in
macos) test_macos_notification ;;
linux) test_linux_notification ;;
wsl) test_wsl_notification ;;
*) echo "Unknown platform: $os" ;;
esac
}Common Pitfalls
- Line Endings: Windows uses CRLF, Unix uses LF
- Use
.gitattributesto enforce line endings
- Use
- Path Separators: Windows uses
\, Unix uses/- Use variables like
$HOMEinstead of hardcoded paths
- Use variables like
- Case Sensitivity: Windows is case-insensitive
- Be consistent with file naming
- Command Availability: Commands differ by platform
- Always check with
command -vbefore use
- Always check with
Success Metrics
- Works on macOS 10.14+
- Works on Ubuntu 20.04+
- Works on Windows 10+ (PowerShell 5.1+)
- Works on WSL2
- Graceful fallback when tools missing
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- Automattic/pocket-casts-ios★ 1.8ksame name
- Kangentic/kangentic★ 139same name
- BrentRector/claude-skills★ 6same name
- foxgeeek/adskills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- shell-scriptingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

