Skip to main content Accueil Créateurs zscole bagman-skill bagman
bagman Secure key management for AI agents. Multi-backend support (macOS Keychain, 1Password, encrypted file, env vars). Use when handling private keys, API secrets, wallet credentials, or when building systems that need agent-controlled funds.
Aller à l'installation Skills Marketplace Découvrez et explorez les compétences IA créées par la communauté.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Copier le promptAfficher les détails du prompt Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
npx skills add https://github.com/zscole/bagman-skill --skill bagmanLa commande reste sur une seule ligne. Faites défiler horizontalement pour la vérifier avant de la copier.
Vous préférez une copie locale ? Téléchargez les fichiers actuellement disponibles dans SkillsMP.
Télécharger Zip Téléchargement... Métiers associés SOC
Basé sur la classification professionnelle SOC
Explorateur de fichiers
5 fichiers name bagman version 2.0.0 description Secure key management for AI agents. Multi-backend support (macOS Keychain, 1Password, encrypted file, env vars). Use when handling private keys, API secrets, wallet credentials, or when building systems that need agent-controlled funds. homepage https://github.com/zscole/bagman-skill metadata {"openclaw":{"emoji":"🔐","requires":{},"suggests":{"bins":["op","age","security"]},"tags":["security","wallet","keys","crypto","secrets"]}}
Bagman
Secure key management patterns for AI agents handling private keys and secrets.
Supported Backends
Bagman auto-detects the best available backend. No 1Password required.
Backend Command Setup Best For macOS Keychain securityNone (native) macOS, zero setup 1Password opbrew install 1password-cliTeams, rich metadata
Encrypted File agebrew install agePortable, git-friendly
Environment - None CI/CD, containers
Core Principles
Never store raw private keys in config, env vars, or memory files
Use session keys / delegated access instead of full control
All secret access goes through a secure backend
Validate all outputs before sending to prevent key leakage
Quick Reference
Retrieve Secrets (Auto-detect Backend) from examples.secret_manager import get_secret, get_session_key
api_key = get_secret("openai-key" )
creds = get_session_key("trading-bot" )
if creds.is_expired():
raise ValueError("Session expired" )
Backend-Specific Examples macOS Keychain (no setup):
security add-generic-password -s bagman-agent -a my-key -w "secret-value"
from examples.backends import get_backend
backend = get_backend("keychain" )
secret = backend.get("my-key" )
op item create \
--vault "Agent-Credentials" \
--category "API Credential" \
--title "trading-bot" \
--field "password=0xsession..." \
--field "expires=2026-02-15T00:00:00Z"
export BAGMAN_PASSPHRASE="your-passphrase"
age-keygen -o ~/.bagman/identity.txt
export BAGMAN_TRADING_BOT_KEY="0x1234..."
DO ✅
from examples.secret_manager import get_secret
key = get_secret("my-agent-wallet" )
DON'T ❌
echo "PRIVATE_KEY=0x123..." > .env
print (f"Key: {private_key}" )
Architecture ┌─────────────────────────────────────────────────────┐
│ AI Agent │
├─────────────────────────────────────────────────────┤
│ Session Key (time/value bounded) │
│ - Expires after N hours │
│ - Spending cap per operation │
│ - Whitelist of allowed contracts │
├─────────────────────────────────────────────────────┤
│ Secret Manager (Auto-detect) │
│ - macOS Keychain (native) │
│ - 1Password (rich metadata) │
│ - Encrypted file (portable) │
│ - Environment vars (fallback) │
├─────────────────────────────────────────────────────┤
│ ERC-4337 Smart Account │
│ - Programmable permissions │
│ - Recovery without private key exposure │
└─────────────────────────────────────────────────────┘
Output Sanitization Apply to ALL agent outputs before sending anywhere:
import re
KEY_PATTERNS = [
r'0x[a-fA-F0-9]{64}' ,
r'sk-[a-zA-Z0-9]{48,}' ,
r'sk-ant-[a-zA-Z0-9\-_]{80,}' ,
r'gsk_[a-zA-Z0-9]{48,}' ,
]
def sanitize_output (text: str ) -> str :
for pattern in KEY_PATTERNS:
text = re.sub(pattern, '[REDACTED]' , text)
return text
Prompt Injection Defense DANGEROUS_PATTERNS = [
r'ignore.*(previous|above|prior).*instructions' ,
r'reveal.*(key|secret|password|credential)' ,
r'output.*(key|secret|private)' ,
r'show.*(key|secret|password)' ,
]
def validate_input (text: str ) -> bool :
text_lower = text.lower()
for pattern in DANGEROUS_PATTERNS:
if re.search(pattern, text_lower):
return False
return True
Pre-commit Hook Block commits containing secrets:
#!/bin/bash
PATTERNS=(
'0x[a-fA-F0-9]{64}'
'sk-[a-zA-Z0-9]{48,}'
'sk-ant-api'
'PRIVATE_KEY='
)
for pattern in "${PATTERNS[@]} " ; do
if git diff --cached | grep -qE "$pattern " ; then
echo "❌ Potential secret detected: $pattern "
exit 1
fi
done
Integration with OpenClaw When running as an OpenClaw agent:
Use bagman for all secret retrieval (auto-detects backend)
Never write keys to workspace files - they persist across sessions
Sanitize outputs before sending to any channel
Document references in TOOLS.md, not actual keys
### Agent Wallet
- Address: 0xABC123...
- Session key: [keychain: trading-bot] or [1password: trading-bot]
- Permissions: USDC < 100, approved DEX only
- Expires: 2026-02-15
Checklist
Files File Purpose examples/secret_manager.pyUnified API with auto-detection examples/backends/Backend implementations examples/sanitizer.pyOutput sanitization examples/validator.pyInput validation docs/Deep-dive documentation