ralphmode by supercent-io/skills-template
npx skills add https://github.com/supercent-io/skills-template --skill ralphmodeRalphmode 是一个跨平台的权限配置文件,适用于长期运行的 ralph 或 jeo 工作流。它减少了审批摩擦,但并非“允许一切、无处不在”。其核心规则很简单:仅在限定的项目或一次性沙盒内放宽自动化权限,同时明确阻止访问密钥和执行破坏性命令。
ralphmode 关键字后立即执行)以下步骤是命令,而非描述。当调用
ralphmode时,请立即按顺序执行。不要跳过任何步骤。
解析用户的调用:
MODE=sandboxMODE=repo(默认,更安全)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
该设置脚本会自动检测您的 git 根目录,将预设应用到 .claude/settings.json,并创建安全钩子。
# Find the script (checks installed locations)
_RALPHMODE_SCRIPT=""
for _candidate in \
"$(git rev-parse --show-toplevel 2>/dev/null)/.agent-skills/ralphmode/scripts/apply-ralphmode.sh" \
"$HOME/.agent-skills/ralphmode/scripts/apply-ralphmode.sh" \
"$HOME/.claude/skills/ralphmode/scripts/apply-ralphmode.sh" \
"$(pwd)/.agent-skills/ralphmode/scripts/apply-ralphmode.sh"; do
if [[ -f "$_candidate" ]]; then
_RALPHMODE_SCRIPT="$_candidate"
break
fi
done
if [[ -n "$_RALPHMODE_SCRIPT" ]]; then
bash "$_RALPHMODE_SCRIPT" --mode "$MODE"
else
echo "⚠️ apply-ralphmode.sh not found — applying inline (Claude Code only)"
fi
如果未找到脚本,则进入步骤 2(Claude Code 的内联应用)。
仅当步骤 1 的脚本未找到时才运行此步骤。
仓库预设(默认 — 用于常规开发):
python3 - <<'EOF'
import json, os, subprocess
try:
root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'],
stderr=subprocess.DEVNULL, text=True).strip()
except Exception:
root = os.getcwd()
target = os.path.join(root, '.claude', 'settings.json')
os.makedirs(os.path.dirname(target), exist_ok=True)
try:
existing = json.loads(open(target).read()) if os.path.exists(target) else {}
except Exception:
existing = {}
existing['_ralphmode_previous_permissions'] = existing.get('permissions')
existing['permissions'] = {
'defaultMode': 'acceptEdits',
'allow': [
'Bash(npm *)', 'Bash(pnpm *)', 'Bash(bun *)', 'Bash(yarn *)',
'Bash(python3 *)', 'Bash(pytest *)',
'Bash(git status)', 'Bash(git diff)', 'Bash(git add *)',
'Bash(git commit *)', 'Bash(git log *)', 'Bash(git push)',
'Read(*)', 'Edit(*)', 'Write(*)'
],
'deny': [
'Read(.env*)', 'Read(./secrets/**)',
'Bash(rm -rf *)', 'Bash(sudo *)',
'Bash(git push --force*)', 'Bash(git reset --hard*)'
]
}
with open(target, 'w') as f:
json.dump(existing, f, ensure_ascii=False, indent=2)
print(f'✓ Repo preset applied to {target}')
EOF
沙盒预设(仅用于一次性环境):
python3 - <<'EOF'
import json, os, subprocess
try:
root = subprocess.check_output(['git', 'rev-parse', 'show-toplevel'],
stderr=subprocess.DEVNULL, text=True).strip()
except Exception:
root = os.getcwd()
target = os.path.join(root, '.claude', 'settings.json')
os.makedirs(os.path.dirname(target), exist_ok=True)
try:
existing = json.loads(open(target).read()) if os.path.exists(target) else {}
except Exception:
existing = {}
existing['_ralphmode_previous_permissions'] = existing.get('permissions')
existing['permissions'] = {'defaultMode': 'bypassPermissions'}
with open(target, 'w') as f:
json.dump(existing, f, ensure_ascii=False, indent=2)
print(f'✓ Sandbox preset applied to {target}')
EOF
HOOK="$HOME/.claude/hooks/ralph-safety-check.sh"
if [[ ! -f "$HOOK" ]]; then
mkdir -p "$(dirname "$HOOK")"
cat > "$HOOK" << 'HOOKEOF'
#!/usr/bin/env bash
CMD=$(echo "$CLAUDE_TOOL_INPUT" | python3 -c \
"import sys,json; print(json.load(sys.stdin).get('command',''))" 2>/dev/null)
TIER1='(rm[[:space:]]+-rf|git[[:space:]]+reset[[:space:]]+--hard|git[[:space:]]+push.*--force|DROP[[:space:]]+TABLE|[[:space:]]sudo[[:space:]]|chmod[[:space:]]+777|\.env|secrets/)'
if echo "$CMD" | grep -qE "$TIER1"; then
echo "BLOCKED: Tier 1 dangerous command detected." >&2
echo "Command: $CMD" >&2
exit 2
fi
HOOKEOF
chmod +x "$HOOK"
echo "✓ Safety hook created: $HOOK"
else
echo "✓ Safety hook exists: $HOOK"
fi
应用完成后,告知用户:
repo 或 sandbox).claude/settings.json 路径)rm .claude/settings.json(项目本地)或恢复 ~/.claude/settings.json(全局)ralph 无需重复的审批弹窗即可进行迭代。在更改任何权限模式之前:
.env*、secrets/**、生产环境凭据、rm -rf、sudo、未经检查的 curl | sh。如果答案是“一次性沙盒”,您可以使用平台的最高自主权模式。否则,请使用仓库范围的预设。
仅使用与当前工具匹配的部分:
bypassPermissions 仅用于隔离的沙盒。permissions.allow 和 permissions.deny 代码片段视为仅用于兼容性。优先使用项目本地配置,而非用户全局默认值。
.claude/settings.json 开始。~/ 或广泛的父目录。如果必须使用用户全局默认值,请配合更严格的拒绝列表和沙盒边界一起使用。
权限配置完成后:
ralph 或 jeo 的计划-执行-验证循环。推荐的执行契约:
boundary check -> permission profile -> ralph run -> verify -> cleanup or revert
将它们视为不同的模式:
不要将它们合并为一个共享的团队默认值。
静态权限配置文件(步骤 2–3)减少了运行开始前的摩擦,但无法阻止执行过程中出现的危险操作。添加动态检查点,以便在尝试执行第 1 级操作时立即阻止或标记。
| 等级 | 操作 | 平台响应 |
|---|---|---|
| 第 1 级(始终阻止) | rm -rf、git reset --hard、git push --force、DROP TABLE、sudo、访问 .env*/secrets/**、生产环境更改 | 立即阻止,需要明确的用户批准 |
| 第 2 级(警告) | npm publish、docker push、git push(非强制)、数据库迁移 | 输出警告,仅在确认后继续 |
| 第 3 级(允许) | 文件读取/编辑、测试、本地构建、代码检查 | 自动允许 |
| 平台 | 钩子 | 是否阻止 | 推荐模式 |
|---|---|---|---|
| Claude Code | PreToolUse (Bash) | 是 — 退出码 2 | Shell 脚本模式匹配命令;阻止第 1 级 |
| Gemini CLI | BeforeTool | 是 — 非零退出码 | Shell 脚本阻止工具;stderr 反馈到下一轮 |
| Codex CLI | notify(轮次后) | 否 | approval_policy="unless-allow-listed" + 提示契约 |
| OpenCode | 无 | 否 | 在 opencode.json 说明中的提示契约 |
原则:将静态配置文件(步骤 2–3)与动态检查点(此步骤)结合使用。
approval_policy 和明确的提示契约,指示智能体输出 CHECKPOINT_NEEDED: <原因> 并在继续执行第 1 级操作前等待。每个平台的完整钩子脚本模板请参见 references/permission-profiles.md。
使用 references/permission-profiles.md 中的 Claude 沙盒预设,然后仅在该隔离仓库内运行 Ralph:
/ralph "fix all failing tests" --max-iterations=10
对于沙盒 ralph 运行,直接使用 CLI 标志:
codex -c model_reasoning_effort="high" --dangerously-bypass-approvals-and-sandbox -c model_reasoning_summary="detailed" -c model_supports_reasoning_summaries=true
对于仓库范围(非沙盒)的运行,使用 references/permission-profiles.md 中的配置文件方法:
approval_policy = "never"
sandbox_mode = "workspace-write"
将此内容放入 ~/.codex/config.toml(或项目本地覆盖文件)中,并在运行 Ralph 之前重启 Codex。
对于沙盒 ralph 运行,使用 --yolo 模式:
gemini --yolo
对于常规仓库自动化,通过明确文件选择信任当前项目文件夹,并仅针对该仓库运行 Ralph 工作流。详情请参见 references/permission-profiles.md。
每周安装量
3.2K
仓库
GitHub 星标数
88
首次出现
2026年3月6日
安全审计
已安装于
codex3.1K
gemini-cli3.1K
opencode3.1K
kimi-cli3.1K
github-copilot3.1K
cursor3.1K
Ralphmode is a cross-platform permission profile for long-running ralph or jeo workflows. It reduces approval friction, but it is not "allow everything everywhere." The core rule is simple: widen automation only inside a bounded project or disposable sandbox, and keep secrets plus destructive commands explicitly blocked.
ralphmode keyword detection)The following steps are commands, not descriptions. Execute them in order immediately when
ralphmodeis invoked. Do not skip steps.
Parse the user's invocation:
MODE=sandboxMODE=repo (default, safer)The setup script auto-detects your git root, applies the preset to .claude/settings.json, and creates the safety hook.
# Find the script (checks installed locations)
_RALPHMODE_SCRIPT=""
for _candidate in \
"$(git rev-parse --show-toplevel 2>/dev/null)/.agent-skills/ralphmode/scripts/apply-ralphmode.sh" \
"$HOME/.agent-skills/ralphmode/scripts/apply-ralphmode.sh" \
"$HOME/.claude/skills/ralphmode/scripts/apply-ralphmode.sh" \
"$(pwd)/.agent-skills/ralphmode/scripts/apply-ralphmode.sh"; do
if [[ -f "$_candidate" ]]; then
_RALPHMODE_SCRIPT="$_candidate"
break
fi
done
if [[ -n "$_RALPHMODE_SCRIPT" ]]; then
bash "$_RALPHMODE_SCRIPT" --mode "$MODE"
else
echo "⚠️ apply-ralphmode.sh not found — applying inline (Claude Code only)"
fi
If the script is not found, fall through to STEP 2 (inline application for Claude Code).
Only run this if the script from STEP 1 was not found.
Repo preset (default — for normal development):
python3 - <<'EOF'
import json, os, subprocess
try:
root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'],
stderr=subprocess.DEVNULL, text=True).strip()
except Exception:
root = os.getcwd()
target = os.path.join(root, '.claude', 'settings.json')
os.makedirs(os.path.dirname(target), exist_ok=True)
try:
existing = json.loads(open(target).read()) if os.path.exists(target) else {}
except Exception:
existing = {}
existing['_ralphmode_previous_permissions'] = existing.get('permissions')
existing['permissions'] = {
'defaultMode': 'acceptEdits',
'allow': [
'Bash(npm *)', 'Bash(pnpm *)', 'Bash(bun *)', 'Bash(yarn *)',
'Bash(python3 *)', 'Bash(pytest *)',
'Bash(git status)', 'Bash(git diff)', 'Bash(git add *)',
'Bash(git commit *)', 'Bash(git log *)', 'Bash(git push)',
'Read(*)', 'Edit(*)', 'Write(*)'
],
'deny': [
'Read(.env*)', 'Read(./secrets/**)',
'Bash(rm -rf *)', 'Bash(sudo *)',
'Bash(git push --force*)', 'Bash(git reset --hard*)'
]
}
with open(target, 'w') as f:
json.dump(existing, f, ensure_ascii=False, indent=2)
print(f'✓ Repo preset applied to {target}')
EOF
Sandbox preset (only for disposable environments):
python3 - <<'EOF'
import json, os, subprocess
try:
root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'],
stderr=subprocess.DEVNULL, text=True).strip()
except Exception:
root = os.getcwd()
target = os.path.join(root, '.claude', 'settings.json')
os.makedirs(os.path.dirname(target), exist_ok=True)
try:
existing = json.loads(open(target).read()) if os.path.exists(target) else {}
except Exception:
existing = {}
existing['_ralphmode_previous_permissions'] = existing.get('permissions')
existing['permissions'] = {'defaultMode': 'bypassPermissions'}
with open(target, 'w') as f:
json.dump(existing, f, ensure_ascii=False, indent=2)
print(f'✓ Sandbox preset applied to {target}')
EOF
HOOK="$HOME/.claude/hooks/ralph-safety-check.sh"
if [[ ! -f "$HOOK" ]]; then
mkdir -p "$(dirname "$HOOK")"
cat > "$HOOK" << 'HOOKEOF'
#!/usr/bin/env bash
CMD=$(echo "$CLAUDE_TOOL_INPUT" | python3 -c \
"import sys,json; print(json.load(sys.stdin).get('command',''))" 2>/dev/null)
TIER1='(rm[[:space:]]+-rf|git[[:space:]]+reset[[:space:]]+--hard|git[[:space:]]+push.*--force|DROP[[:space:]]+TABLE|[[:space:]]sudo[[:space:]]|chmod[[:space:]]+777|\.env|secrets/)'
if echo "$CMD" | grep -qE "$TIER1"; then
echo "BLOCKED: Tier 1 dangerous command detected." >&2
echo "Command: $CMD" >&2
exit 2
fi
HOOKEOF
chmod +x "$HOOK"
echo "✓ Safety hook created: $HOOK"
else
echo "✓ Safety hook exists: $HOOK"
fi
After applying, tell the user:
repo or sandbox).claude/settings.json path)rm .claude/settings.json (project-local) or restore ~/.claude/settings.json (global)ralph to iterate without repeated approval popups.Before changing any permission mode:
.env*, secrets/**, production credentials, rm -rf, sudo, unchecked curl | sh.If the answer is "disposable sandbox," you may use the platform's highest-autonomy mode. If not, use the repo-scoped preset instead.
Use only the section that matches the current tool:
bypassPermissions only for isolated sandboxes.permissions.allow and permissions.deny snippets as compatibility-only.Detailed templates live in references/permission-profiles.md.
Prefer project-local configuration over user-global defaults.
.claude/settings.json.~/ or broad parent directories.If you must use a user-global default, pair it with a stricter denylist and a sandbox boundary.
After permissions are configured:
ralph or the jeo plan-execute-verify loop.Recommended execution contract:
boundary check -> permission profile -> ralph run -> verify -> cleanup or revert
Treat these as different modes:
Do not collapse them into one shared team default.
Static permission profiles (Steps 2–3) reduce friction before a run starts, but they do not stop dangerous operations that arise during execution. Add dynamic checkpoints so that Tier 1 actions are blocked or flagged at the moment they are attempted.
| Tier | Action | Platform response |
|---|---|---|
| Tier 1 (always block) | rm -rf, git reset --hard, git push --force, DROP TABLE, sudo, .env*/secrets/** access, production environment changes | Block immediately, require explicit user approval |
| Tier 2 (warn) | npm publish, , (non-force), DB migrations |
| Platform | Hook | Blocking | Recommended pattern |
|---|---|---|---|
| Claude Code | PreToolUse (Bash) | Yes — exit 2 | Shell script pattern-matches command; blocks Tier 1 |
| Gemini CLI | BeforeTool | Yes — non-zero exit | Shell script blocks tool; stderr fed to next turn |
| Codex CLI | notify (post-turn) | No | approval_policy="unless-allow-listed" + prompt contract |
| OpenCode | None | No |
Principle : Combine static profiles (Steps 2–3) with dynamic checkpoints (this step).
approval_policy and explicit prompt contracts that instruct the agent to output CHECKPOINT_NEEDED: <reason> and wait before proceeding with Tier 1 actions.See references/permission-profiles.md for full hook script templates per platform.
Use the Claude sandbox preset from references/permission-profiles.md, then run Ralph only inside that isolated repo:
/ralph "fix all failing tests" --max-iterations=10
For sandbox ralph runs, use the CLI flags directly:
codex -c model_reasoning_effort="high" --dangerously-bypass-approvals-and-sandbox -c model_reasoning_summary="detailed" -c model_supports_reasoning_summaries=true
For repo-scoped (non-sandbox) runs, use the config file approach from references/permission-profiles.md:
approval_policy = "never"
sandbox_mode = "workspace-write"
Place this in ~/.codex/config.toml (or a project-local override) and restart Codex before running Ralph.
For sandbox ralph runs, use --yolo mode:
gemini --yolo
For normal repo automation, trust the current project folder with explicit file selection and run the Ralph workflow for that repo only. See references/permission-profiles.md for details.
Weekly Installs
3.2K
Repository
GitHub Stars
88
First Seen
Mar 6, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
codex3.1K
gemini-cli3.1K
opencode3.1K
kimi-cli3.1K
github-copilot3.1K
cursor3.1K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
docker pushgit push| Output warning, continue only with confirmation |
| Tier 3 (allow) | File reads/edits, tests, local builds, lint | Allow automatically |
Prompt contract in opencode.json instructions |