beads/examples/python-agent/README.md
Steve Yegge 19cd7d1887 Prepare for public launch: comprehensive examples, docs, and tooling
This commit adds everything needed for a successful public launch:

**New Documentation**
- SECURITY.md: Security policy and best practices
- CLAUDE.md: Complete agent instructions for contributing to beads
- Enhanced README with pain points, FAQ, troubleshooting sections
- Added Taskwarrior to comparison table with detailed explanation

**Installation**
- install.sh: One-liner installation script with platform detection
- Auto-detects OS/arch, tries go install, falls back to building from source
- Updated README with prominent installation instructions

**Examples** (2,268+ lines of working code)
- examples/python-agent/: Full Python implementation of agent workflow
- examples/bash-agent/: Shell script agent with colorized output
- examples/git-hooks/: Pre-commit, post-merge, post-checkout hooks with installer
- examples/claude-desktop-mcp/: Documentation for future MCP server integration
- examples/README.md: Overview of all examples

**Dogfooding**
- Initialized bd in beads project itself (.beads/beads.db)
- Created issues for roadmap (MCP server, migrations, demos, 1.0 milestone)
- Exported to .beads/issues.jsonl for git versioning

**Visual Assets**
- Added screenshot showing agent using beads to README intro
- Placed in .github/images/ following GitHub conventions

This addresses all launch readiness items:
✅ Security policy
✅ Working agent examples (Python, Bash)
✅ Git hooks for automation
✅ FAQ addressing skeptics
✅ Troubleshooting common issues
✅ Easy installation
✅ Dogfooding our own tool
✅ Pain points that create urgency

Ready to ship! 🚀

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 11:25:29 -07:00

2.3 KiB

Python Agent Example

A simple Python script demonstrating how an AI agent can use bd to manage tasks.

Features

  • Finds ready work using bd ready --json
  • Claims tasks by updating status
  • Simulates discovering new issues during work
  • Links discovered issues with discovered-from dependency
  • Completes tasks and moves to the next one

Prerequisites

  • Python 3.7+
  • bd installed: go install github.com/steveyegge/beads/cmd/bd@latest
  • A beads database initialized: bd init

Usage

# Make the script executable
chmod +x agent.py

# Run the agent
./agent.py

What It Does

  1. Queries for ready work (no blocking dependencies)
  2. Claims the highest priority task
  3. "Works" on the task (simulated)
  4. If the task involves implementation, discovers a testing task
  5. Creates the new testing task and links it with discovered-from
  6. Completes the original task
  7. Repeats until no ready work remains

Example Output

🚀 Beads Agent starting...

============================================================
Iteration 1/10
============================================================

📋 Claiming task: bd-1
🤖 Working on: Implement user authentication (bd-1)
   Priority: 1, Type: feature

💡 Discovered: Missing test coverage for this feature
✨ Creating issue: Add tests for Implement user authentication
🔗 Linking bd-2 ← discovered-from ← bd-1
✅ Completing task: bd-1 - Implemented successfully

🔄 New work discovered and linked. Running another cycle...

Integration with Real Agents

To integrate with a real LLM-based agent:

  1. Replace simulate_work() with actual LLM calls
  2. Parse the LLM's response for discovered issues/bugs
  3. Use the issue ID to track context across conversations
  4. Export/import JSONL to share state across agent sessions

Advanced Usage

# Create an agent with custom behavior
agent = BeadsAgent()

# Find specific types of work
ready = agent.run_bd("ready", "--priority", "1", "--assignee", "bot")

# Create issues with labels
agent.run_bd("create", "New task", "-l", "urgent,backend")

# Query dependency tree
tree = agent.run_bd("dep", "tree", "bd-1")

See Also