Testing Guide for Claude Code CLI Automation
This guide provides multiple testing strategies to validate the automation system without merging to trunk.
๐งช Testing Strategiesโ
Strategy 1: Local Testing (Recommended First)โ
-
Set up test environment variables (replace with your actual values):
export JIRA_URL="https://superna.atlassian.net"
export JIRA_EMAIL="your-email@superna.com"
export JIRA_API_TOKEN="your-actual-token"
export BITBUCKET_TOKEN="your-actual-token" -
Run the local test script:
./test-local.sh -
Test individual components:
# Test environment validation
node scripts/validate-environment.js
# Test Claude Code CLI
node scripts/claude-code-executor.js validate
node scripts/claude-code-executor.js test --debug
# Test JIRA integration (replace AI-78 with real issue)
node scripts/jira-integration.js get-issue AI-78
node scripts/jira-integration.js get-requirements AI-78
# Test dry-run automation
node scripts/claude-documentation-automation.js AI-78 --dry-run --debug
Strategy 2: Test Branch Pipeline (Safe - No Trunk Changes)โ
-
Create a test JIRA issue:
- Create issue in your JIRA (e.g., TEST-123)
- Add the
auto-doclabel - Add descriptive content for testing
-
Create test branch locally:
git checkout -b auto-doc/TEST-123
git add .
git commit -m "feat: Add Claude Code CLI automation system"
git push origin auto-doc/TEST-123 -
Monitor the pipeline:
- Go to Bitbucket Pipelines
- Watch the
auto-doc/TEST-123pipeline execution - Review logs in real-time
- Check artifacts for debug information
-
Review results:
- Check if documentation was created in
solutions/folder - Review debug logs in artifacts
- Check JIRA for automation comments
- Check if documentation was created in
Strategy 3: Feature Branch Testingโ
-
Create a feature branch:
git checkout -b feature/test-claude-automation
git add .
git commit -m "feat: Add Claude Code CLI automation system"
git push origin feature/test-claude-automation -
Create PR to trunk (don't merge yet):
- This triggers the regular pipeline
- Tests markdown linting, spell checking
- Validates the build process
- Creates preview deployment
-
Test auto-doc on feature branch:
# From your feature branch
git checkout -b auto-doc/TEST-124
git push origin auto-doc/TEST-124
๐ Debugging Toolsโ
1. Debug Logsโ
The automation creates detailed debug logs saved as artifacts:
tmp/claude_debug_*.log- Contains Claude's analysis and operations
2. Validation Toolsโ
# Check environment setup
node scripts/validate-environment.js --test-connections
# Validate Claude Code CLI
node scripts/claude-code-executor.js validate
# Test JIRA connectivity
node scripts/jira-integration.js validate
3. Dry Run Modeโ
Test without making changes:
node scripts/claude-documentation-automation.js ISSUE-KEY --dry-run --debug
๐จ Common Issues and Solutionsโ
Issue: "Claude Code CLI not found"โ
Solution: Install via npm (requires Node.js 18+):
npm install -g @anthropic-ai/claude-code
claude --version
Issue: "Environment variables missing"โ
Solution:
- For pipeline: Configure Bitbucket Repository Variables
- For local: Export environment variables or use test script
Issue: "JIRA API authentication failed"โ
Solution:
- Verify JIRA_EMAIL and JIRA_API_TOKEN are correct
- Check if API token hasn't expired
- Ensure using correct JIRA_URL
Issue: "Branch doesn't trigger pipeline"โ
Solution:
- Ensure branch name follows
auto-doc/ISSUE-KEYformat - Verify JIRA issue has
auto-doclabel - Check pipeline configuration in bitbucket-pipelines.yml
โ Testing Checklistโ
Pre-Testing Setupโ
- Bitbucket Repository Variables configured
- Test JIRA issue created with
auto-doclabel - Claude Code CLI available (pipeline installs it)
Local Testingโ
- Environment validation passes
- Claude Code CLI responds to test prompts
- JIRA integration retrieves issue details
- Placement logic generates reasonable paths
- Dry-run mode completes without errors
Pipeline Testingโ
- Auto-doc branch triggers pipeline
- Claude Code CLI installs successfully
- Environment validation passes in pipeline
- Documentation gets generated in correct location
- Git commit and PR creation work
- JIRA gets updated with progress
- Debug logs are captured in artifacts
Integration Testingโ
- Generated documentation follows existing patterns
- Sidebar navigation gets updated correctly
- Markdown syntax is valid
- File paths follow naming conventions
- Content quality meets standards
๐ฏ Recommended Testing Flowโ
- Start with Local Testing - Validate core functionality
- Test Individual Components - Ensure each script works
- Create Test Branch - Validate pipeline integration
- Review Generated Content - Check documentation quality
- Test Edge Cases - Different issue types, complex requirements
- Performance Testing - Large documents, multiple files
This approach lets you thoroughly test the system without affecting the main trunk branch.