Platform Bridge - Legacy Multi-Platform Support¶
Compatibility note: this page documents the legacy platform bridge. New
default-workflowprovider behavior is specified by the provider-neutral workflow API. Recipes should callamplihack workflow ... --format jsonhelpers, not this bridge directly. Azure Repos pull-request publication is manual in the provider-neutral workflow contract.
Legacy automatic platform detection and unified interface fer selected GitHub and Azure DevOps operations.
Quick Start¶
The legacy bridge can detect whether yer repository be hosted on GitHub or Azure DevOps and use matching CLI tools. New workflow code should use the provider-neutral helpers instead.
from claude.tools.platform_bridge import PlatformBridge
# Automatically detects platform from git remote
bridge = PlatformBridge()
# Create an issue/work item
issue = bridge.create_issue(
title="Add authentication",
body="Implement JWT authentication"
)
# Create a draft pull request through the legacy bridge only.
# default-workflow does not automate Azure Repos PR creation.
pr = bridge.create_draft_pr(
title="feat: Add JWT auth",
body="Implementation of authentication system",
source_branch="feat/auth",
target_branch="main"
)
What Problem Does This Solve?¶
Before the platform bridge, the legacy DEFAULT_WORKFLOW.md hardcoded GitHub-specific commands (gh issue create, gh pr create) throughout all 22 steps. This meant:
- Azure DevOps users couldn't use the workflow without manual workarounds
- Every workflow step required platform-specific instructions
- Switching between GitHub and Azure DevOps projects required different workflows
The legacy platform bridge solved this by:
- Automatic Detection: Examines
git remoteURLs to determine platform - Unified Interface: Single API that works fer both GitHub and Azure DevOps
- Zero Configuration: Works without user intervention or config changes
- Graceful Fallback: Clear error messages when CLI tools be missin'
Core Capabilities¶
The platform bridge supports provider operations used by older workflow tooling.
Provider-neutral workflow helpers supersede this direct bridge for
default-workflow.
| Operation | GitHub Command | Azure DevOps Command | Workflow Step |
|---|---|---|---|
| Create Issue | gh issue create |
az boards work-item create |
Step 3 |
| Create Draft PR | gh pr create --draft |
Legacy bridge only; not part of provider-neutral default-workflow |
GitHub adapter only for automated workflow publication; AzDO manual action |
| Mark PR Ready | gh pr ready |
Legacy bridge only | GitHub adapter only for automated workflow paths |
| Add PR Comment | gh pr comment |
Legacy bridge only | GitHub adapter only for automated workflow paths |
| Check CI Status | gh pr checks |
Legacy bridge only | GitHub adapter only for automated workflow paths |
How Platform Detection Works¶
The platform bridge examines yer git remote URLs to determine the platform:
# Detects GitHub
git remote -v
# origin https://github.com/owner/repo.git (fetch)
# → Platform: github
# Detects Azure DevOps
git remote -v
# origin https://dev.azure.com/org/project/_git/repo (fetch)
# → Platform: azdo
Detection Logic:
- Runs
git remote -vto get all remotes - Checks
originremote first (most common) - Falls back to first available remote if
origindoesn't exist - Examines URL patterns:
github.com→ GitHubdev.azure.comorvisualstudio.com→ Azure DevOps- Raises clear error if platform cannot be determined
Prerequisites¶
Ye need the appropriate CLI tools installed fer yer platform:
For GitHub repositories:
For Azure DevOps repositories:
# Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Ubuntu/Debian
# OR
brew install azure-cli # macOS
Ye don't need both CLIs installed - only the one fer yer current repository's platform.
Usage Examples¶
Creating an Issue/Work Item¶
from claude.tools.platform_bridge import PlatformBridge
bridge = PlatformBridge()
# Works on both GitHub and Azure DevOps
issue = bridge.create_issue(
title="Implement feature X",
body="Detailed description here"
)
print(f"Created: {issue['url']}")
# GitHub: https://github.com/owner/repo/issues/42
# Azure DevOps: https://dev.azure.com/org/project/_workitems/edit/42
Creating a Draft Pull Request¶
# Create draft PR (both platforms)
pr = bridge.create_draft_pr(
title="feat: Add new feature",
body="## Summary\n\nImplementation details...",
source_branch="feat/new-feature",
target_branch="main"
)
print(f"Draft PR created: {pr['url']}")
Marking PR Ready for Review¶
# Mark PR as ready (removes draft status)
result = bridge.mark_pr_ready(pr_number=42)
if result['success']:
print("PR is now ready fer review!")
Adding Comments to PR¶
# Add comment to PR
comment = bridge.add_pr_comment(
pr_number=42,
comment="All tests be passin' - ready fer merge!"
)
Checking CI Status¶
# Check CI pipeline status
status = bridge.check_ci_status(pr_number=42)
if status['all_passing']:
print("All checks passed!")
else:
print(f"Failed checks: {status['failed_checks']}")
Error Handling¶
The platform bridge provides clear, actionable error messages:
try:
bridge = PlatformBridge()
except PlatformDetectionError as e:
# Could not determine platform from git remotes
print(f"Platform detection failed: {e}")
try:
issue = bridge.create_issue(title="Test", body="Body")
except CLIToolMissingError as e:
# GitHub CLI or Azure CLI not installed
print(f"Missing tool: {e}")
print(f"Install with: {e.install_command}")
Common Error Scenarios:
- No Git Remote: Repository has no remotes configured
-
Error: "No git remotes found. Add a remote with
git remote add origin <url>" -
Unknown Platform: Remote URL doesn't match GitHub or Azure DevOps patterns
-
Error: "Could not detect platform from remote URL:
" -
Missing CLI Tool: Required CLI not installed
-
Error: "GitHub CLI not found. Install with: brew install gh"
-
Authentication Required: CLI tool not authenticated
- Error: "GitHub CLI not authenticated. Run: gh auth login"
Integration with default-workflow¶
The platform bridge is integrated into the default-workflow skill/recipe at these steps:
Step 3: Create Issue/Work Item
# Platform-agnostic issue creation
bridge = PlatformBridge()
issue = bridge.create_issue(title=title, body=body)
Step 15: Create Draft PR
# Works on both GitHub and Azure DevOps
pr = bridge.create_draft_pr(
title=pr_title,
body=pr_body,
source_branch=current_branch,
target_branch="main"
)
Step 20: Mark PR Ready
Step 21: Check CI Status
# Platform-agnostic CI status check
status = bridge.check_ci_status(pr_number=pr_number)
if not status['all_passing']:
print("CI checks still runnin' or failed")
Architecture¶
The platform bridge follows the Brick Philosophy - a self-contained module with clear public contract:
.claude/tools/platform_bridge/
├── __init__.py # Public API via __all__
├── detector.py # Platform detection logic
├── operations.py # PlatformOperations interface
├── github_bridge.py # GitHub implementation
├── azdo_bridge.py # Azure DevOps implementation
├── exceptions.py # Custom exceptions
├── tests/ # Unit tests
│ ├── test_detector.py
│ ├── test_github.py
│ └── test_azdo.py
└── README.md # This file
Public API (__all__):
PlatformBridge- Main entry pointdetect_platform()- Standalone detection functionPlatformDetectionError- Exception fer detection failuresCLIToolMissingError- Exception fer missing CLI tools
Security Considerations¶
The platform bridge delegates authentication to official CLI tools:
- GitHub: Uses
ghCLI authentication (gh auth login) - Azure DevOps: Uses
azCLI authentication (az login)
Input Validation:
- All subprocess calls use parameterized commands (no shell injection)
- Branch names, titles, and bodies be validated before passin' to CLI
- URL parsing uses standard library
urllib.parse
Subprocess Safety:
- Timeouts on all subprocess calls (default 30 seconds)
- Standard error captured and parsed
- Exit codes checked before processin' output
See Security Documentation fer complete security analysis.
Troubleshooting¶
Platform Detection Fails¶
Problem: PlatformDetectionError: Could not detect platform
Solutions:
- Check git remotes:
git remote -v - Ensure remote URL contains
github.comordev.azure.com - Add remote if missin':
git remote add origin <url>
CLI Tool Not Found¶
Problem: CLIToolMissingError: GitHub CLI not found
Solutions:
- Install the required CLI tool (see Prerequisites)
- Verify installation:
gh --versionoraz --version - Ensure CLI be in yer PATH
Authentication Errors¶
Problem: CLI commands fail with authentication errors
Solutions:
- GitHub: Run
gh auth loginand follow prompts - Azure DevOps: Run
az loginand authenticate - Verify authentication:
gh auth statusoraz account show
Wrong Platform Detected¶
Problem: Bridge detects wrong platform
Solutions:
- Check which remote be detected:
git remote -v - Ensure
originpoints to correct URL - Platform detection prioritizes
originover other remotes
See Also¶
- Platform Bridge API Reference - Complete API documentation
- Contributing to Platform Bridge - Extend with new platforms
default-workflowskill/recipe - Full workflow integration- Security Analysis - Security implementation details