Executable Default Values - Quick Reference
This document provides quick examples of executable default values for common use cases.
Table of Contents
- Git Information
- Node.js & Package Managers
- Environment Detection
- System Information
- File System Checks
- Cross-Platform Commands
Git Information
Current Branch
{
"type": "execute",
"value": "git branch --show-current"
}
Remote URL
{
"type": "execute",
"value": "git config --get remote.origin.url"
}
User Name
{
"type": "execute",
"value": "git config user.name"
}
User Email
{
"type": "execute",
"value": "git config user.email"
}
Default Branch Name
{
"type": "execute",
"value": "git config init.defaultBranch || echo 'main'"
}
Check if Git Repository Exists
{
"type": "execute",
"value": "test -d .git && echo 'true' || echo 'false'"
}
Node.js & Package Managers
Node.js Version
{
"type": "execute",
"value": "node --version"
}
npm Version
{
"type": "execute",
"value": "npm --version"
}
Detect Available Package Manager (Unix/macOS)
{
"type": "execute",
"value": "command -v pnpm > /dev/null && echo 'pnpm' || (command -v yarn > /dev/null && echo 'yarn' || echo 'npm')"
}
Detect Available Package Manager (Cross-platform using Node.js)
{
"type": "execute",
"value": "node -e \"try { require.resolve('pnpm'); console.log('pnpm'); } catch { try { require.resolve('yarn'); console.log('yarn'); } catch { console.log('npm'); } }\""
}
Get Current Package Name from package.json
{
"type": "execute",
"value": "node -p \"require('./package.json').name\""
}
Environment Detection
Check if Running in CI
{
"type": "execute",
"value": "test -n \"$CI\" && echo 'true' || echo 'false'"
}
Get Environment Variable
{
"type": "execute",
"value": "node -p \"process.env.MY_VAR || 'default-value'\""
}
Operating System (Cross-platform)
{
"type": "execute",
"value": "node -p \"process.platform\""
}
System Information
Current Directory Name (Cross-platform)
{
"type": "execute",
"value": "node -p \"require('path').basename(process.cwd())\""
}
Home Directory (Cross-platform)
{
"type": "execute",
"value": "node -p \"require('os').homedir()\""
}
Username (Cross-platform)
{
"type": "execute",
"value": "node -p \"require('os').userInfo().username\""
}
CPU Count
{
"type": "execute",
"value": "node -p \"require('os').cpus().length\""
}
File System Checks
Check if Directory Exists (Unix/macOS)
{
"type": "execute",
"value": "test -d src && echo 'true' || echo 'false'"
}
Check if File Exists (Unix/macOS)
{
"type": "execute",
"value": "test -f package.json && echo 'true' || echo 'false'"
}
Check if Directory Exists (Cross-platform)
{
"type": "execute",
"value": "node -e \"console.log(require('fs').existsSync('src'))\""
}
Count Files in Directory (Unix/macOS)
{
"type": "execute",
"value": "ls -1 | wc -l"
}
Cross-Platform Commands
For maximum compatibility across Windows, macOS, and Linux, use Node.js commands:
Current Working Directory
{
"type": "execute",
"value": "node -p \"process.cwd()\""
}
Timestamp
{
"type": "execute",
"value": "node -p \"Date.now()\""
}
Current Date (ISO format)
{
"type": "execute",
"value": "node -p \"new Date().toISOString()\""
}
Current Year
{
"type": "execute",
"value": "node -p \"new Date().getFullYear()\""
}
Random UUID
{
"type": "execute",
"value": "node -p \"require('crypto').randomUUID()\""
}
Tips
- Use Node.js for cross-platform compatibility: Node.js is guaranteed to be available since itβs required to run the tool
- Keep commands simple: Complex commands are harder to debug and may fail
- Provide fallbacks: Use
||to provide fallback values if commands fail - Test on multiple platforms: Windows, macOS, and Linux may behave differently
- Use JSON output when possible: Commands that output JSON are automatically parsed
- Remember the 10-second timeout: Commands must complete within 10 seconds