Skip to content

Conversation

@jeremyeder
Copy link
Collaborator

@jeremyeder jeremyeder commented Jan 9, 2026

Summary

Adds GitHub Actions deployment for the Codebase Agent pattern with flexible authentication supporting both Anthropic API and Vertex AI.

Key Features:

  • 🤖 @mentions: Type @cba please review in any issue/PR comment
  • 🏷️ Labels: Add cba-review or cba-help labels for automatic review
  • 📦 Modular Python: Extracted to .github/scripts/codebase_agent/ for testability
  • 🔒 Production-ready: Error handling, timeouts, proper exception handling
  • 🔄 Dual Authentication: Vertex AI with automatic Anthropic API fallback
  • 🎯 Template-friendly: Self-contained, no external dependencies required
  • 💡 Smart defaults: Hardcoded agent context with quality principles

Implementation:

  • 56-line workflow (73% reduction from 207-line inline version)
  • 223-line Python package (modular, testable, maintainable)
  • Hardcoded context (no file I/O, works out-of-box)
  • Flexible auth: Choose Anthropic API (quick) or Vertex AI (advanced)

Architecture

User types @cba → GitHub Actions → Try Vertex AI → Fallback to Anthropic API → Response posted

Module Structure:

.github/scripts/codebase_agent/
├── __init__.py           # Package initialization
├── main.py              # Entry point with error handling
├── github_parser.py     # Context extraction
└── ai_client.py         # Vertex AI + Anthropic fallback logic

Authentication Flow:

GCP_PROJECT_ID set?
  ↓ Try Vertex AI
  ↓ Success? → Use Vertex AI ✅
  ↓ Failure? → Fall back to Anthropic API ⚠️

ANTHROPIC_API_KEY set? → Use Anthropic API ✅
  ↓ Not set? → Error ❌

What Changed

New Files:

  • .github/workflows/codebase-agent.yml - 56-line streamlined workflow with dual auth
  • .github/scripts/codebase_agent/ - Modular Python package (4 files)

Modified Files:

  • docs/patterns/codebase-agent.md - Updated with authentication options guide

Removed Complexity:

  • ✅ No GCP authentication by default (optional for Vertex AI)
  • ✅ No bash parsing duplication
  • ✅ No file I/O for context loading
  • ✅ No reaction steps or unused features
  • ✅ No documentation-code drift
  • ✅ No "Powered by" messaging

Authentication Options

Option 1: Anthropic API (Default - Recommended)

Setup:

  1. Get API key from https://console.anthropic.com
  2. Add ANTHROPIC_API_KEY secret
  3. Done!

Best for: Quick setup, any cloud, pay-as-you-go

Option 2: Vertex AI (Advanced)

Setup:

  1. Set up GCP Workload Identity (see docs)
  2. Uncomment GCP auth steps in workflow
  3. Add GitHub secrets/variables
  4. Done!

Best for: GCP users, no API keys, enterprise deployments

Automatic Fallback: Workflow tries Vertex AI first, falls back to Anthropic API if unavailable.

Code Quality Improvements

Refactoring Highlights:

  • 71% code reduction while improving maintainability
  • Modular architecture - testable, IDE-friendly components
  • Flexible authentication - Choose your provider
  • Error handling - Proper exceptions for API failures, timeouts
  • Simplicity - Removed over-engineering, trusted AI safety

Agent Context (Hardcoded):

  • Operating principles (safety first, high signal/low noise)
  • Code review focus (bugs, security, performance, style, testing)
  • Communication style (direct, technical, actionable)
  • Anti-patterns (no AI slop, no filler content)

Test Plan

  • Create feature branch
  • Extract Python to modular package
  • Add Vertex AI support with fallback
  • Add comprehensive error handling
  • Remove unused code and complexity
  • Update documentation with dual auth options
  • Verify module imports
  • Validate workflow YAML
  • Commit and push
  • Merge to main
  • Add ANTHROPIC_API_KEY secret (or configure Vertex AI)
  • Test with @cba mention in issue/PR

Setup (After Merge)

Quick Start (Anthropic API):

  1. Go to Settings → Secrets → Actions
  2. Add ANTHROPIC_API_KEY from https://console.anthropic.com
  3. Done!

Advanced (Vertex AI):

  1. Follow GCP Workload Identity setup
  2. Uncomment GCP auth steps in workflow
  3. Add GCP secrets and variables
  4. Done!

Usage:

# In any issue or PR comment:
@cba please review this for security issues
@cba help me understand this error

# Or add labels:
cba-review  → Automatic code review
cba-help    → Automatic analysis

Files Modified

Modified:
  .github/workflows/codebase-agent.yml  (207 → 56 lines, -73%)
  docs/patterns/codebase-agent.md       (enhanced with auth options)

Created:
  .github/scripts/codebase_agent/__init__.py
  .github/scripts/codebase_agent/main.py
  .github/scripts/codebase_agent/github_parser.py
  .github/scripts/codebase_agent/ai_client.py (Vertex AI + fallback logic)

🤖 Generated with Claude Code

@jeremyeder
Copy link
Collaborator Author

e792750#diff-9cd72ff775ffa406e961bc36383131d421b160a149ce6d3abc6343897f04cc6fR131 this is where it could be customized.

@jeremyeder jeremyeder force-pushed the feature/codebase-agent-workflow branch 3 times, most recently from ecb4f5c to ca71cd2 Compare January 10, 2026 02:35
Extract inline Python to standalone module for testability and
maintainability. Reduce workflow from 207 lines to 43 lines.

Changes:
- Extract Python to .github/scripts/codebase_agent/ module
- Add Vertex AI support with automatic Anthropic API fallback
- Add error handling for API failures and timeouts
- Simplify error handling (trust base exception messages)
- Remove unused GCP Workload Identity setup from workflow
- Update docs with dual authentication options
- Remove "Powered by Vertex AI" messaging
- Add comprehensive GCP Workload Identity setup guide

Authentication:
- Try Vertex AI first (if GCP_PROJECT_ID set)
- Fall back to Anthropic API automatically
- Clear error messages when neither configured

Result: 71% code reduction with flexible authentication

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jeremyeder jeremyeder force-pushed the feature/codebase-agent-workflow branch from ca71cd2 to ac3670f Compare January 10, 2026 03:07
@jeremyeder jeremyeder added the documentation Improvements or additions to documentation label Jan 14, 2026
@jeremyeder
Copy link
Collaborator Author

Documentation Updates Added

Added commit ebf1acf with documentation structure improvements:

Changes:

  • ✅ Moved docs/quickstart.mddocs/README.md for better discoverability
  • ✅ Deleted redundant docs/index.md
  • ✅ Updated CLAUDE.md with complete repository structure
  • ✅ Documented all 5 GitHub Actions workflows (was 2)
  • ✅ Added automation scripts section to CLAUDE.md
  • ✅ Updated all cross-references in README and PRESENTATION files

CLAUDE.md Improvements:

  • Added .github/scripts/codebase_agent/ module documentation
  • Listed all workflows: codebase-agent, docs-validation, ci, deploy-docs, security
  • Updated documentation structure to reflect standalone patterns approach
  • Removed references to deleted files (architecture.md, tutorial.md, api-reference.md)

All markdown linting passes ✓

@jeremyeder jeremyeder force-pushed the feature/codebase-agent-workflow branch from ebf1acf to ac3670f Compare January 15, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants