Custom OpenClaw skill that exposes Claude Code CLI (~/.local/bin/claude) via Telegram command /claude_code, with rate limiting.
| Item | Value |
|---|---|
| Skill name | claude-code |
| Telegram command | /claude_code |
| Rate limit | 5 calls per rolling hour |
| Requirements | claude (Claude Code CLI), python3 |
| Deploy to | ~/.openclaw/skills/claude-code/ |
- User sends
/claude_code <prompt>in Telegram - OpenClaw matches the command to the
claude-codeskill - The agent reads
SKILL.mdinstructions and runsclaude-wrapper.sh - Wrapper checks
.rate-state.json— if 5+ calls in the last hour, blocks with wait time - Otherwise, records the timestamp and
execs~/.local/bin/claude -p '<prompt>' - Output is relayed back to Telegram
Uses a rolling window (not fixed hourly reset):
- Each call timestamp is stored in
.rate-state.json - On invocation, timestamps older than 1 hour are pruned
- If 5+ remain, the call is rejected with a countdown
- This prevents burst abuse (e.g. 5 at :59 + 5 at :01)
Reference copies of the deployed skill files are in claude_code/:
| File | Description |
|---|---|
SKILL.md |
Skill definition — YAML frontmatter + agent prompt |
claude-wrapper.sh |
Rate-limited wrapper script (chmod +x) |
.rate-state.json |
Call timestamp state (auto-managed) |
/claude_code 幫我看 ~/.local/bin/claude --version
/claude_code Review this Python script for bugs: <paste code>
/claude_code Explain what this error means: <paste error>
# 1. Copy skill files to openclaw
cp -r docs/skills/claude_code/ ~/.openclaw/skills/claude-code/
chmod +x ~/.openclaw/skills/claude-code/claude-wrapper.sh
# 2. Allowlist the wrapper in exec approvals
openclaw approvals allowlist add ~/.openclaw/skills/claude-code/claude-wrapper.sh
# 3. Restart gateway
bash scripts/stop_gateway.sh && bash scripts/start_gateway.sh# Check remaining quota
cat ~/.openclaw/skills/claude-code/.rate-state.json
# Reset rate limit
echo '{"calls":[]}' > ~/.openclaw/skills/claude-code/.rate-state.json
# Adjust limit: edit MAX_CALLS or WINDOW_SECS in claude-wrapper.sh| Problem | Fix |
|---|---|
/claude_code not in Telegram menu |
Restart gateway |
| Bot asks clarifying questions instead of executing | Check SKILL.md has "immediately run" directive; restart gateway |
| Rate limit hit unexpectedly | Check .rate-state.json timestamps; reset if stale |
claude not found |
Verify ~/.local/bin/claude exists and is in PATH |