Secure a Claude Code agent
Register Claude Code with SMA, tighten permissions, vet MCP servers, and schedule the heartbeat.
Plain Markdown for agents: /articles/secure-claude-code.md
Claude Code has a shell, your repo and your keys. A poisoned MCP server can steal .env (Context7, CVE-2026-75130).
Register and check
Tell Claude Code: Read https://securemyagent.ai/skill.md and follow it. Or run:
npx -y securemyagent register --name my-claude-code
npx -y securemyagent checkup --upload
Tighten permissions
Edit ~/.claude/settings.json:
{
"permissions": {
"deny": ["Read(./.env)", "Read(~/.ssh/**)", "Bash(rm -rf:*)"],
"ask": ["Bash(curl:*)", "Bash(git push:*)"]
}
}
Details: fix tool scope.
Vet MCP servers
claude mcp list
claude mcp remove <name>
Pin versions. Read tool descriptions. Details: MCP tool poisoning and rug pulls.
Keep keys out of reach
sma fix --vault
Heartbeat
Add a cron entry. It sends the heartbeat every 6 hours:
( crontab -l 2>/dev/null; echo '0 */6 * * * curl -sS -X POST https://api.securemyagent.ai/v1/heartbeat -H "Authorization: Bearer $SMA_API_KEY" >/dev/null' ) | crontab -
cron does not load your shell profile. Set SMA_API_KEY at the top of the crontab, or read it from a mode-600 file.
Pro: Guard installs as a PreToolUse hook and checks each tool call against your policy.