Back up the OpenClaw agent workspace to a GitHub repo and keep it synced via a cron-driven commit/push script.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install gitclaw或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install gitclaw⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/gitclaw/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: gitclaw description: Back up the OpenClaw agent workspace to a GitHub repo and keep it synced via a cron-driven commit/push script. homepage: https://gitclaw.ai metadata: { "openclaw": { "emoji": "🐙", "homepage": "https://gitclaw.ai" } } ---
Use this skill automatically when it's installed or reference, and also when the user asks to:
- 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).
Ask the user for:
openclaw-backup)public or privateDo NOT ask for a Personal Access Token. We use gh auth.
---
Check:
git --versionIf missing, install using the best available method:
brew exists: - brew install git
apt-get exists: - sudo apt-get update && sudo apt-get install -y git
dnf exists: - sudo dnf install -y git
yum exists: - sudo yum install -y git
pacman exists: - sudo pacman -S --noconfirm git
zypper exists: - sudo zypper install -y git
apk exists: - sudo apk add git
xcode-select exists: - xcode-select --install (this may prompt the user)
- Tell the user you couldn’t auto-install git on this OS and show the failing detection output.
Re-check:
git --versionOnly notify the user if install failed.
Check:
command -v crontabIf missing, attempt install:
apt-get exists: - sudo apt-get update && sudo apt-get install -y cron - sudo systemctl enable --now cron || sudo service cron start || true
dnf exists: - sudo dnf install -y cronie - sudo systemctl enable --now crond || true
yum exists: - sudo yum install -y cronie - sudo systemctl enable --now crond || true
pacman exists: - sudo pacman -S --noconfirm cronie - sudo systemctl enable --now cronie || true
apk exists: - sudo apk add dcron - sudo rc-update add dcron default || true - sudo rc-service dcron start || true
- If you can’t install, tell the user cron is required for scheduling.
Re-check:
command -v crontab---
gh) is installed (auto-install)Check:
gh --versionIf missing, install:
brew exists: - brew install gh
apt-get exists (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/keyrings - out=$(mktemp) && wget -nv -O"$out" https://cli.github.com/packages/githubcli-archive-keyring.gpg - cat "$out" | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null - sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg - sudo mkdir -p -m 755 /etc/apt/sources.list.d - echo "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/null - sudo apt-get update && sudo apt-get install -y gh
dnf exists: - sudo dnf install -y 'dnf-command(config-manager)' || sudo dnf install -y dnf5-plugins || true - sudo 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 || true - sudo dnf install -y gh --repo gh-cli || sudo dnf install -y gh || true
yum exists: - type -p yum-config-manager >/dev/null || sudo yum install -y yum-utils - sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo - sudo yum install -y gh
zypper exists: - sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo || true - sudo zypper ref - sudo zypper install -y gh
pacman exists: - sudo pacman -S --noconfirm github-cli
apk exists: - sudo apk add github-cli
- Tell the user you can’t auto-install gh on this OS.
Re-check:
gh --versionOnly notify the user if install failed.
---
gh (agent runs the flow)Check:
gh auth status --hostname github.comIf NOT authenticated:
- gh auth login --hostname github.com --git-protocol https
- Tell the user to open https://github.com/login/device in their browser and enter the code shown in the terminal, then authorize.
- gh auth setup-git
- gh auth status --hostname github.com
If auth fails, stop and report the exact terminal output.
---
Workspace dir (where you store SOUL.md, AGENTS.md, etc.):
WORKSPACE_DIR="$HOME/.openclaw/workspace" - mkdir -p "$WORKSPACE_DIR" - cd "$WORKSPACE_DIR"
- If .git does not exist: git init - git branch -M main
- git config user.name "gitclaw.ai" - git config user.email "[email protected]"
- OWNER="$(gh api user --jq .login)" - (Do not print unless debugging is needed)
- REPO=" - Visibility: - public => --public - private => --private
- 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 -A - git commit -m "gitclaw: initial backup" || true
- 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 || true - git 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 - Set remote: - REMOTE_URL="https://github.com/$OWNER/$REPO.git" - git remote add origin "$REMOTE_URL" || git remote set-url origin "$REMOTE_URL"
- git push -u origin main
If push fails due to conflicts or non-fast-forward:
---
Create a folder outside the workspace:
mkdir -p "$HOME/.openclaw/gitclaw"...
安装 GitClaw 后,可以对 AI 说这些话来触发它
Help me get started with GitClaw
Explains what GitClaw does, walks through the setup, and runs a quick demo based on your current project
Use GitClaw to back up the OpenClaw agent workspace to a GitHub repo and keep it s...
Invokes GitClaw with the right parameters and returns the result directly in the conversation
What can I do with GitClaw in my developer & devops workflow?
Lists the top use cases for GitClaw, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/gitclaw/ 目录(个人级,所有项目可用),或 .claude/skills/gitclaw/(项目级)。重启 AI 客户端后,用 /gitclaw 主动调用,或让 AI 根据上下文自动发现并使用。
GitClaw 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
GitClaw 可免费安装使用。请查阅仓库了解许可证信息。
Back up the OpenClaw agent workspace to a GitHub repo and keep it synced via a cron-driven commit/push script.
GitClaw 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using GitClaw
Identifies repetitive steps in your workflow and sets up GitClaw to handle them automatically