Claude Code Bitbucket Pipelines Workflow Guide
Bitbucket Pipelines provides a powerful CI/CD solution for teams using Atlassian’s ecosystem. When combined with Claude Code, you can automate code generation, enforce quality standards, and streamline development workflows without manual intervention. This guide walks through practical configurations to integrate Claude Code into your Bitbucket Pipelines setup.
Why Integrate Claude Code with Bitbucket Pipelines
Claude Code brings AI-assisted development directly into your automated workflows. Rather than relying solely on local developer sessions, you can trigger Claude Code commands during pipeline execution to handle repetitive tasks, generate boilerplate, run tests, and perform code reviews automatically.
This integration works particularly well for teams adopting AI-augmented development practices. You can maintain consistency across pull requests, ensure code quality checks run on every commit, and reduce the burden on human reviewers.
Setting Up Claude Code in Your Pipeline
The first step involves configuring your Bitbucket repository to use Claude Code. Create a bitbucket-pipelines.yml file in your repository root with the following configuration:
image: node:20
pipelines:
default:
- step:
name: Install Claude Code
script:
- npm install -g @anthropic-ai/claude-code
- claude --version
caches:
- npm
- step:
name: Run Claude Code Analysis
script:
- claude --print "Analyze all files in src/ for code quality issues and output a JSON report to analysis-results.json"
artifacts:
- analysis-results.json
This basic setup installs Claude Code as a global npm package and runs an analysis on your source files. The analysis results are saved as artifacts for later review.
Automating Code Generation Tasks
One of the most valuable use cases involves using Claude Code to generate code automatically during pipeline execution. For instance, you can create a pipeline step that generates component files based on specifications.
Consider a frontend project using React. You might want Claude Code to generate new components from a specification file. Configure a pipeline step:
- step:
name: Generate Component Files
script:
- claude --print "Generate a React TypeScript component named $COMPONENT_NAME following the frontend-design skill patterns"
- git add components/$COMPONENT_NAME/
- git commit -m "Generate $COMPONENT_NAME component"
variables:
COMPONENT_NAME: "UserCard"
The frontend-design skill enhances this workflow by providing specialized templates for common UI patterns. Skills are Markdown files placed in your .claude/skills/ directory — commit a frontend-design.md skill file to your repository so it is available in the pipeline.
This skill understands modern design systems and can generate components that follow established patterns.
Running Automated Tests with Claude Code
Testing represents another area where Claude Code adds significant value. The tdd skill provides test-driven development workflows that integrate smoothly with Bitbucket Pipelines. Add a tdd.md skill file to your .claude/skills/ directory and commit it to your repository.
Configure a pipeline step to generate and run tests:
- step:
name: Generate and Run Tests
script:
- npm install
- claude --print "Using the tdd skill, generate unit and integration tests with coverage for all files in src/"
- npm test -- --coverage
caches:
- npm
The TDD skill can analyze your source code and generate relevant test cases, including unit tests, integration tests, and edge case coverage. This automated approach ensures your codebase maintains adequate test coverage without manual test writing effort.
Document Generation Pipeline
Documentation often falls behind code changes in fast-moving projects. Integrate the pdf skill to automatically generate documentation during your pipeline:
- step:
name: Generate API Documentation
script:
- claude --print "Using the pdf skill, generate API documentation from code comments and output to docs/api.pdf"
artifacts:
- docs/api.pdf
This step runs after your build completes, generating a PDF documentation file from your code comments and API specifications. The PDF skill supports various output formats and can be customized to match your team’s documentation standards.
Memory and Context Management
For teams working across multiple repositories or long-lived projects, maintaining context becomes challenging. The supermemory skill addresses this by enabling persistent memory across Claude Code sessions. Place a supermemory.md skill file in your .claude/skills/ directory and commit it to your repository.
Configure your pipeline to load project context before running tasks:
- step:
name: Load Project Context
script:
- claude --print "Using the supermemory skill, load context for my-app and analyze the codebase with full project awareness"
This ensures Claude Code understands your project’s history, coding conventions, and architectural decisions when generating or reviewing code.
Complete Example Workflow
A comprehensive pipeline combining these elements might look like:
image: node:20
pipelines:
pull-requests:
- step:
name: Install Dependencies
script:
- npm install
caches:
- npm
- step:
name: Generate Tests
script:
- claude --print "Using the tdd skill, generate tests with coverage for all source files"
- npm test
- step:
name: Code Quality Check
script:
- claude --print "Analyze all files in src/ for code quality issues and save a report to quality-report.json"
- step:
name: Build and Lint
script:
- npm run build
- npm run lint
- step:
name: Generate Documentation
script:
- claude --print "Using the pdf skill, generate API documentation in PDF format"
branches:
main:
- step:
name: Deploy to Staging
script:
- npm run build
- npm run deploy:staging
This configuration runs comprehensive checks on pull requests, including test generation, quality analysis, and documentation creation. The main branch triggers deployment to your staging environment.
Advanced Pipeline Patterns
Intelligent Code Review with PR Context
Use Claude Code to analyze code changes in the context of pull requests, identifying issues that static analyzers miss:
- step:
name: AI-Powered Code Review
script:
- |
claude --print "Review all changed files in ./src in the context of PR $BITBUCKET_PR_ID. Flag issues at medium severity or above and output findings to review-results.json"
artifacts:
- review-results.json
Smart Deployment with Health Checks
Implement intelligent deployments that evaluate health metrics and make rollback decisions:
- step:
name: Deploy with AI Health Evaluation
deployment: production
script:
- |
./deploy.sh production
sleep 30
claude --print "Evaluate deployment health for production using metrics from $METRICS_URL. Output a JSON decision to deployment-decision.json with fields: action (deploy|rollback) and reason."
DECISION=$(cat deployment-decision.json | jq -r '.action')
if [ "$DECISION" == "rollback" ]; then
echo "Claude recommended rollback: $(cat deployment-decision.json | jq -r '.reason')"
./rollback.sh production
exit 1
fi
Version Pinning
Ensure reproducible builds by pinning Claude Code versions in your pipeline:
script:
- npm install -g @anthropic-ai/claude-code@1.2.3
Best Practices for Pipeline Integration
When integrating Claude Code into Bitbucket Pipelines, consider these practical recommendations:
First, cache Claude Code installations and skills to reduce pipeline execution time. Use Bitbucket’s caching mechanism for npm packages and any downloaded skills.
Second, use environment variables to control Claude Code behavior across different pipeline stages. This allows you to adjust verbosity, output formats, and behavior without modifying your configuration files.
Third, store Claude Code configuration in a dedicated file such as .claude.yaml in your repository. This file can define default behaviors, skill configurations, and project-specific settings that pipeline steps inherit.
Finally, monitor your pipeline logs to understand how Claude Code interprets your code and generates outputs. This feedback helps you refine prompts and configuration for better results over time.
Conclusion
Integrating Claude Code with Bitbucket Pipelines transforms your CI/CD workflow into an AI-assisted development pipeline. By automating code generation, test creation, quality analysis, and documentation, your team can move faster while maintaining high standards. The combination of Claude Code skills like tdd, frontend-design, pdf, and supermemory provides comprehensive coverage for modern development workflows.
Start with a single pipeline step, measure the results, and gradually expand your automation. The initial investment in configuration pays dividends in developer time saved and consistent code quality across your project.
Related Reading
- Claude Code for Beginners: Complete Getting Started Guide
- Best Claude Skills for Developers in 2026
- Claude Skills Guides Hub
Built by theluckystrike — More at zovo.one