소스 정보
- 저장소
- Cogni-AI-OU/github-git-ops
- 최근 소스 활동
- 2026년 1월 16일 22:18
- 감지된 SKILL.md 언어
- 영어
- 스타
- 0
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/Cogni-AI-OU/github-git-ops --skill robust-commands명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | robust-commands |
| description | Resilient command execution with automatic fallbacks and error recovery |
| license | MIT |
This skill provides patterns for executing commands with automatic error recovery, fallback mechanisms, and installation of missing dependencies. Never give up when a command fails - try alternatives!
If a command doesn't work, don't just report failure - fix it!
Process for handling command failures:
# Method 1: which
which command_name
# Method 2: command -v (POSIX-compliant, more reliable)
command -v command_name
# Method 3: type
type command_name
# Best practice - silent check
if command -v jq &> /dev/null; then
echo "jq is available"
else
echo "jq is not installed"
fi
# Find first available command from list
for cmd in jq python3 python; do
if command -v "$cmd" &> /dev/null; then
echo "Using $cmd"
break
fi
done
# Update package lists first
apt-get update
# Install single package
apt-get install -y package-name
# Search for package
apt-cache search keyword
# Install with error handling
if ! command -v jq &> /dev/null; then
echo "Installing jq..."
apt-get update && apt-get install -y jq
fi
# JSON processing
apt-get install -y jq
# YAML processing
apt-get install -y yq
# HTTP requests
apt-get install -y curl wget
# Text processing
apt-get install -y sed gawk grep
# Build tools
apt-get install -y build-essential
# Python tools
apt-get install -y python3 python3-pip
# Node.js tools
apt-get install -y nodejs npm
# Install with pip
pip install package-name
# Install specific version
pip install package-name==1.2.3
# Install from requirements
pip install -r requirements.txt
# Common Python tools
pip install pyyaml requests black pylint
# Try jq first, fallback to python
if command -v jq &> /dev/null; then
jq . file.json
else
python3 -m json.tool < file.json
fi
# Or one-liner with ||
jq . file.json 2>/dev/null || python3 -m json.tool < file.json
# Try yq, fallback to python
if command -v yq &> /dev/null; then
yq eval file.yaml
else
python3 -c "import yaml, sys; print(yaml.safe_load(open('file.yaml')))"
fi
# Try curl, fallback to wget
if command -v curl &> /dev/null; then
curl -s https://example.com
else
wget -q -O - https://example.com
fi
# Or with Python as final fallback
curl -s https://example.com 2>/dev/null || \
wget -q -O - https://example.com 2>/dev/null || \
python3 -c "import urllib.request; print(urllib.request.urlopen('https://example.com').read().decode())"
# Line counting alternatives
wc -l file.txt 2>/dev/null || \
cat file.txt | wc -l 2>/dev/null || \
awk 'END {print NR}' file.txt
# Grep alternatives
grep "pattern" file.txt 2>/dev/null || \
awk '/pattern/' file.txt 2>/dev/null || \
python3 -c "import sys; [print(line, end='') for line in open('file.txt') if 'pattern' in line]"
# Check if file is readable
if [ -r file.txt ]; then
cat file.txt
else
echo "File not readable"
fi
# Check if file is writable
if [ -w file.txt ]; then
echo "data" > file.txt
else
echo "File not writable"
fi
# Check if file is executable
if [ -x script.sh ]; then
./script.sh
else
echo "File not executable"
fi
# Make file readable
chmod +r file.txt
# Make file writable
chmod +w file.txt
# Make file executable
chmod +x script.sh
# Common permission patterns
chmod 644 file.txt # rw-r--r--
chmod 755 script.sh # rwxr-xr-x
chmod 600 secret.key # rw-------
# Try normal command, fall back to sudo if needed
cat /etc/secret 2>/dev/null || sudo cat /etc/secret
# Check if sudo is available
if command -v sudo &> /dev/null && sudo -n true 2>/dev/null; then
sudo command
else
echo "Cannot elevate privileges"
fi
# Check file exists
if [ -f file.txt ]; then
echo "File exists"
fi
# Check directory exists
if [ -d /path/to/dir ]; then
echo "Directory exists"
fi
# Check path exists (file or directory)
if [ -e /path/to/something ]; then
echo "Path exists"
fi
# Create directory if missing
mkdir -p /path/to/dir
# Create file if missing
touch file.txt
# Create with error handling
if [ ! -d /path/to/dir ]; then
mkdir -p /path/to/dir || {
echo "Failed to create directory"
exit 1
}
fi
#!/bin/bash
# Function to run command with fallbacks
run_robust() {
local cmd=$1
shift
local args="$@"
# Check if command exists
if ! command -v "$cmd" &> /dev/null; then
echo "Command '$cmd' not found. Attempting to install..."
# Try to install
case "$cmd" in
jq)
apt-get update && apt-get install -y jq
;;
yq)
apt-get update && apt-get install -y yq
;;
curl)
apt-get update && apt-get install -y curl
;;
*)
echo "Don't know how to install '$cmd'"
return 1
;;
esac
# Check again after install
if ! command -v "$cmd" &> /dev/null; then
echo "Failed to install '$cmd'"
return 1
fi
fi
# Run the command
"$cmd" $args
}
# Usage
run_robust jq . file.json
# Retry command up to N times
retry_command() {
local max_attempts=3
local timeout=2
local attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt of $max_attempts..."
if "$@"; then
return 0
fi
echo "Command failed. Retrying in ${timeout}s..."
sleep $timeout
timeout=$((timeout * 2))
attempt=$((attempt + 1))
done
echo "Command failed after $max_attempts attempts"
return 1
}
# Usage
retry_command curl -f https://api.example.com
# Run command with timeout
timeout 30s long_running_command || {
echo "Command timed out after 30 seconds"
}
# Or with fallback
timeout 10s risky_command || echo "Command failed or timed out"
# Capture both stdout and stderr
output=$(command 2>&1) || {
echo "Command failed with output:"
echo "$output"
# Try alternative
alternative_command
}
# Check exit code explicitly
command
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Command failed with exit code $exit_code"
# Handle error
fi
# Detect OS
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "OS: $NAME"
echo "Version: $VERSION"
fi
# Or use uname
case "$(uname -s)" in
Linux*)
echo "Linux system"
;;
Darwin*)
echo "macOS system"
;;
*)
echo "Unknown system"
;;
esac
# Find available package manager
if command -v apt-get &> /dev/null; then
PKG_MANAGER="apt-get"
elif command -v yum &> /dev/null; then
PKG_MANAGER="yum"
elif command -v brew &> /dev/null; then
PKG_MANAGER="brew"
else
echo "No known package manager found"
fi
# Check if running in Docker
if [ -f /.dockerenv ]; then
echo "Running in Docker"
fi
# Check if running in GitHub Actions
if [ -n "$GITHUB_ACTIONS" ]; then
echo "Running in GitHub Actions"
fi
# Check if running in GitLab CI
if [ -n "$GITLAB_CI" ]; then
echo "Running in GitLab CI"
fi
# Read file
cat file.txt || head -n 99999 file.txt || python3 -c "print(open('file.txt').read())"
# Write file
echo "data" > file.txt || python3 -c "open('file.txt', 'w').write('data')"
# Append to file
echo "data" >> file.txt || python3 -c "open('file.txt', 'a').write('data\n')"
# Download file
curl -O url || wget url || python3 -c "import urllib.request; urllib.request.urlretrieve('url', 'file')"
# Check if URL is reachable
curl -I url || wget --spider url || python3 -c "import urllib.request; urllib.request.urlopen('url')"
# Extract tar.gz
tar -xzf file.tar.gz || python3 -m tarfile -e file.tar.gz
# Create tar.gz
tar -czf archive.tar.gz files/ || python3 -m tarfile -c archive.tar.gz files/
# Extract zip
unzip file.zip || python3 -m zipfile -e file.zip .
command -v before executingcommand -v over whichCommands fail for many reasons - most are fixable!