gitclaw
Back up the OpenClaw agent workspace to a GitHub repo and keep it synced via a cron-driven commit/push script.
Install
mkdir -p .claude/skills/gitclaw && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8957" && unzip -o skill.zip -d .claude/skills/gitclaw && rm skill.zipInstalls to .claude/skills/gitclaw
About this skill
GitClaw: Agent self-backup to GitHub
When to use
Use this skill automatically when it's installed or reference, and also when the user asks to:
- back up / sync / mirror the OpenClaw workspace
- set up periodic commits and pushes
- install/configure GitHub backup automation for the agent
Behavioral rule (important)
- Do everything automatically and quietly.
- Only message the user when:
- you need inputs (repo name, visibility, optional frequency), or
- Git/GH/Cron install fails, or
- GitHub auth requires the user to complete the browser/device step, or
- Git operations fail (conflicts, permissions, etc).
Inputs to ask the user for
Ask the user for:
- Repository name (e.g.,
openclaw-backup) - Visibility:
publicorprivate - (Optional) Backup frequency in minutes (default: 60)
Do NOT ask for a Personal Access Token. We use gh auth.
Step 1: Ensure prerequisites (auto-install)
1A) Ensure git is installed (auto-install; do not stop)
Check:
git --version
If missing, install using the best available method:
- If
brewexists:brew install git
- Else if
apt-getexists:sudo apt-get update && sudo apt-get install -y git
- Else if
dnfexists:sudo dnf install -y git
- Else if
yumexists:sudo yum install -y git
- Else if
pacmanexists:sudo pacman -S --noconfirm git
- Else if
zypperexists:sudo zypper install -y git
- Else if
apkexists:sudo apk add git
- Else if macOS and
xcode-selectexists:xcode-select --install(this may prompt the user)
- Else:
- Tell the user you couldn’t auto-install git on this OS and show the failing detection output.
Re-check:
git --version
Only notify the user if install failed.
1B) Ensure cron/crontab is available (best-effort auto-install)
Check:
command -v crontab
If missing, attempt install:
- If
apt-getexists:sudo apt-get update && sudo apt-get install -y cronsudo systemctl enable --now cron || sudo service cron start || true
- Else if
dnfexists:sudo dnf install -y croniesudo systemctl enable --now crond || true
- Else if
yumexists:sudo yum install -y croniesudo systemctl enable --now crond || true
- Else if
pacmanexists:sudo pacman -S --noconfirm croniesudo systemctl enable --now cronie || true
- Else if
apkexists:sudo apk add dcronsudo rc-update add dcron default || truesudo rc-service dcron start || true
- Else:
- If you can’t install, tell the user cron is required for scheduling.
Re-check:
command -v crontab
Step 2: Ensure GitHub CLI (gh) is installed (auto-install)
Check:
gh --version
If missing, install:
-
If
brewexists:brew install gh
-
Else if
apt-getexists (official GitHub CLI packages; preferred):- Install using the official apt repo steps:
(type -p wget >/dev/null || (sudo apt-get update && sudo apt-get install -y wget))sudo mkdir -p -m 755 /etc/apt/keyringsout=$(mktemp) && wget -nv -O"$out" https://cli.github.com/packages/githubcli-archive-keyring.gpgcat "$out" | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/nullsudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpgsudo mkdir -p -m 755 /etc/apt/sources.list.decho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/nullsudo apt-get update && sudo apt-get install -y gh
- Install using the official apt repo steps:
-
Else if
dnfexists:sudo dnf install -y 'dnf-command(config-manager)' || sudo dnf install -y dnf5-plugins || truesudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo || sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo || truesudo dnf install -y gh --repo gh-cli || sudo dnf install -y gh || true
-
Else if
yumexists:type -p yum-config-manager >/dev/null || sudo yum install -y yum-utilssudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.reposudo yum install -y gh
-
Else if
zypperexists:sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo || truesudo zypper refsudo zypper install -y gh
-
Else if
pacmanexists:sudo pacman -S --noconfirm github-cli
-
Else if
apkexists:sudo apk add github-cli
-
Else:
- Tell the user you can’t auto-install
ghon this OS.
- Tell the user you can’t auto-install
Re-check:
gh --version
Only notify the user if install failed.
Step 3: Ensure the user is authenticated in gh (agent runs the flow)
Check:
gh auth status --hostname github.com
If NOT authenticated:
-
Run:
gh auth login --hostname github.com --git-protocol https
-
The terminal flow will show a one-time code and ask the user to authorize.
- Tell the user to open https://github.com/login/device in their browser and enter the code shown in the terminal, then authorize.
-
After login:
gh auth setup-git
-
Verify again:
gh auth status --hostname github.com
If auth fails, stop and report the exact terminal output.
Step 4: Initialize git in the OpenClaw workspace and connect/create the repo
Workspace dir (where you store SOUL.md, AGENTS.md, etc.):
- Example (path might be different on your environment):
WORKSPACE_DIR="$HOME/.openclaw/workspace"
-
Ensure the workspace exists:
mkdir -p "$WORKSPACE_DIR"cd "$WORKSPACE_DIR"
-
Initialize repo if needed:
- If
.gitdoes not exist:git init git branch -M main
- If
-
Configure a deterministic commit identity (local-only):
git config user.name "gitclaw.ai"git config user.email "[email protected]"
-
Determine the authenticated GitHub username (owner):
OWNER="$(gh api user --jq .login)"- (Do not print unless debugging is needed)
-
Repo name and visibility:
REPO="<repo name from user>"- Visibility:
public=>--publicprivate=>--private
-
Ensure there is at least one commit (required for first push/cron):
- Create a tiny marker file if needed:
test -f .gitclaw.keep || printf "gitclaw initialized: %s\n" "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" > .gitclaw.keep
git add -Agit commit -m "gitclaw: initial backup" || true
- Create a tiny marker file if needed:
-
Create or reuse the target repo:
- If it exists:
gh repo view "$OWNER/$REPO" >/dev/null 2>&1- Set remote:
REMOTE_URL="https://github.com/$OWNER/$REPO.git"- If origin exists:
git remote set-url origin "$REMOTE_URL" - Else:
git remote add origin "$REMOTE_URL"
- Try to fast-forward sync (avoid overwriting remote history):
git fetch origin main || truegit merge --ff-only origin/main || true
- If it does NOT exist:
- Create it non-interactively and connect it:
- Public:
gh repo create "$REPO" --public --confirm
- Private:
gh repo create "$REPO" --private --confirm
- Public:
- Set remote:
REMOTE_URL="https://github.com/$OWNER/$REPO.git"git remote add origin "$REMOTE_URL" || git remote set-url origin "$REMOTE_URL"
- Create it non-interactively and connect it:
- If it exists:
-
Initial push:
git push -u origin main
If push fails due to conflicts or non-fast-forward:
- Do NOT force-push automatically.
- Report the exact error and stop (user decision required).
Step 5: Install deterministic backup script (NO AI / NO heartbeat)
Create a folder outside the workspace:
mkdir -p "$HOME/.openclaw/gitclaw"
Create this script EXACTLY:
Path:
$HOME/.openclaw/gitclaw/auto_backup.sh
Contents:
#!/usr/bin/env bash
set -euo pipefail
# GitClaw deterministic backup (no AI)
export PATH="/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:$PATH"
WORKSPACE_DIR="${HOME}/.openclaw/workspace"
STATE_DIR="${HOME}/.openclaw/gitclaw"
LOG_FILE="${STATE_DIR}/backup.log"
LOCK_DIR="${STATE_DIR}/lock"
mkdir -p "${STATE_DIR}"
timestamp() { date -u '+%Y-%m-%dT%H:%M:%SZ'; }
# Simple lock to prevent overlapping runs
if ! mkdir "${LOCK_DIR}" 2>/dev/null; then
echo "$(timestamp) Skip: already running." >> "${LOG_FILE}"
exit 0
fi
trap 'rmdir "${LOCK_DIR}" >/dev/null 2>&1 || true' EXIT
if ! command -v git >/dev/null 2>&1; then
echo "$(timestamp) ERROR: git not found on PATH. Install git first." >> "${LOG_FILE}"
exit 2
fi
if [ ! -d "${WORKSPACE_DIR}/.git" ]; then
echo "$(timestamp) ERROR: ${WORKSPACE_DIR} is not a git repo. Run GitClaw setup first." >> "${LOG_FILE}"
exit 3
fi
cd "${WORKSPACE_DIR}"
# Stage everything
git add -A
# If nothing staged, exit quietly
if git diff --cached --quiet; then
echo "$(timestamp) No changes." >> "${LOG_FILE}"
exit 0
fi
# Commit + push
git commit -m "gitclaw backup: $(timestamp)" >> "${LOG_FILE}" 2>&1
git push origin main >> "${LOG_FILE}" 2>&1
echo "$(timestamp) Backup OK." >> "${LOG_FILE}"
Write the script to:
$HOME/.openclaw/gitclaw/auto_backup.sh
Then:
chmod +x "$HOME/.openclaw/gitclaw/auto_backup.sh"
Step 6: Configure crontab (idempotent)
Default schedule: hourly (0 * * * *). If user provided a different frequency, convert it to a cron expression.
- Define:
CRON_CMD="$HOME/.openclaw/gitclaw/auto_backup.sh"CRON_LINE="0 * * * * $CRON_CMD"
- Install without duplicates:
crontab -l 2>/dev/null | grep -F "$CRON_CMD" >/dev/null- If not found, append:
(crontab -l 2>/dev/null; echo "$CRON_LINE") | crontab -
- Confirm:
crontab -l | grep -F "$CRON_CMD"
Step 7: Final validation
- Run once:
$HOME/.openclaw/gitclaw/auto_backup.sh
- Show the log:
tail -n 50 "$HOME/.openclaw/gitclaw/backup.log" || true
- Tell the user:
- Repo:
https://github.com/$OWNER/$REPO - Schedule: hourly (or the chosen cadence)
- Script path
Content truncated.
More by openclaw
View all skills by openclaw →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversInteractive MCP server for collecting text & image feedback, executing commands, and managing sessions during AI-assiste
Control Gmail, Google Calendar, Docs, Sheets, Slides, Chat, Forms, Tasks, Search, and Drive with AI. Comprehensive Googl
Cometix Indexer — local code indexer for fast semantic code search. Index workspaces and run incremental searches with a
Qwen Package Manager is a Node.js package manager with npm and Bower package support, transactional installs, rollback,
Extend your developer tools with GitHub MCP Server for advanced automation, supporting GitHub Student and student packag
Boost productivity with Task Master: an AI-powered tool for project management and agile development workflows, integrat
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.