GitHub - atlasfutures/claude-output-formatter: GitHub Action to format Claude Code Action execution results with enhanced formatting (original) (raw)
A GitHub Action that enhances Claude Code Action execution results with beautiful formatting and rich GitHub integration.
Features
- ๐จ Multiple Output Formats: Markdown, HTML, and JSON
- ๐ Rich Formatting: Token usage, costs, duration, and execution statistics
- ๐ง Tool Analysis: Detailed breakdown of tool usage and results
- ๐ฏ GitHub Integration: Automatic step summary updates and PR/issue comments
- โก Performance Optimized: Handles large conversations efficiently
- ๐๏ธ Configurable: Extensive customization options
- ๐งช Well Tested: Comprehensive test suite with edge cases and performance tests
Quick Start
name: Claude Code Action uses: anthropics/claude-code-action@main id: claude with:
Your Claude configuration
name: Format Output uses: atlasfutures/claude-output-formatter@v1 with: execution_file: ${{ steps.claude.outputs.execution_file }} format_type: markdown update_step_summary: true
Inputs
| Input | Description | Required | Default |
|---|---|---|---|
| execution_file | Path to the Claude execution JSON file | โ | - |
| format_type | Output format (markdown, html, json) | โ | markdown |
| output_file | Custom output file path | โ | Auto-generated |
| update_step_summary | Update GitHub step summary | โ | true |
| create_comment | Create/update PR/issue comment | โ | false |
| comment_tag | Tag to identify comments for updates | โ | claude-output-formatter |
| include_raw_data | Include raw conversation data | โ | false |
| max_content_length | Maximum length for content blocks (0 = unlimited) | โ | 1000 |
| theme | Theme for HTML output (light, dark, auto) | โ | auto |
Outputs
| Output | Description |
|---|---|
| formatted_file | Path to the formatted output file |
| summary_updated | Whether the step summary was updated |
| comment_id | ID of the created/updated comment |
| total_tokens | Total tokens used in the conversation |
| total_cost | Total cost of the conversation |
| execution_status | Overall execution status (success/error) |
Usage Examples
Basic Usage
- name: Format Claude Output uses: atlasfutures/claude-output-formatter@v1 with: execution_file: ${{ steps.claude.outputs.execution_file }}
HTML Output with Custom Theme
- name: Format as HTML uses: atlasfutures/claude-output-formatter@v1 with: execution_file: ${{ steps.claude.outputs.execution_file }} format_type: html theme: dark max_content_length: 2000
JSON Output with Raw Data
- name: Format as JSON uses: atlasfutures/claude-output-formatter@v1 with: execution_file: ${{ steps.claude.outputs.execution_file }} format_type: json include_raw_data: true output_file: ./artifacts/claude-analysis.json
PR Comment Integration
- name: Comment on PR uses: atlasfutures/claude-output-formatter@v1 with: execution_file: ${{ steps.claude.outputs.execution_file }} create_comment: true comment_tag: claude-analysis max_content_length: 1500 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Complete Workflow Example
name: Claude Code Review
on: pull_request: types: [opened, synchronize]
jobs: claude-review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Claude Code Analysis
uses: anthropics/claude-code-action@main
id: claude
with:
prompt: "Please review this pull request for potential issues"
- name: Format Results
uses: atlasfutures/claude-output-formatter@v1
with:
execution_file: ${{ steps.claude.outputs.execution_file }}
format_type: markdown
create_comment: true
update_step_summary: true
max_content_length: 2000
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save HTML Report
uses: atlasfutures/claude-output-formatter@v1
with:
execution_file: ${{ steps.claude.outputs.execution_file }}
format_type: html
output_file: ./claude-report.html
theme: auto
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: claude-analysis-report
path: ./claude-report.htmlOutput Formats
Markdown
The markdown format provides:
- Executive summary with session details
- Token usage breakdown
- Conversation flow with tool calls and results
- Syntax-highlighted code blocks
- Collapsible sections for raw data
HTML
The HTML format includes:
- Responsive design with theme support
- Interactive elements and collapsible sections
- Syntax highlighting for code blocks
- Professional styling with proper typography
- Dark/light/auto theme support
JSON
The JSON format offers:
- Structured data for programmatic analysis
- Detailed statistics and metrics
- Tool usage analytics
- Conversation flow mapping
- Raw message data (optional)
GitHub Integration
Step Summary
When update_step_summary is enabled, the action automatically updates the GitHub Actions step summary with the formatted output. For non-markdown formats, it provides a summary of the formatting operation.
PR/Issue Comments
When create_comment is enabled, the action will:
- Look for existing comments with the specified tag
- Update existing comments or create new ones
- Format the content appropriately for the output type
- Include timestamps and formatting metadata
Performance
The action is optimized for performance:
- Efficient processing of large conversations
- Content truncation to manage output size
- Streaming processing for memory efficiency
- Caching of repeated operations
Performance benchmarks:
- Small conversations (< 50 messages): < 100ms
- Medium conversations (50-200 messages): < 500ms
- Large conversations (200+ messages): < 2 seconds
Error Handling
The action includes robust error handling:
- Validates all inputs before processing
- Gracefully handles malformed conversation data
- Provides detailed error messages
- Continues processing even with partial failures
Development
Setup
Clone the repository
git clone https://github.com/atlasfutures/claude-output-formatter.git cd claude-output-formatter
Install dependencies
bun install
Run tests
bun test
Build the action
bun run build
Testing
Run all tests
bun test
Run with coverage
bun test --coverage
Run performance tests
bun test tests/performance.test.ts
Watch mode for development
bun test --watch
Formatting and Linting
Format code
bun run format
Check formatting
bun run format:check
Lint code
bun run lint
Fix linting issues
bun run lint:fix
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE for details.
Support
For issues and questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Provide detailed reproduction steps
Changelog
v1.0.0
- Initial release
- Support for markdown, HTML, and JSON formats
- GitHub step summary integration
- PR/issue comment creation
- Comprehensive test suite
- Performance optimizations