Auto-Doc Pipeline Configuration
Overview
The auto-doc/* pipeline is designed to automatically generate documentation using Claude Code and deploy preview sites. It includes safeguards to prevent re-generation of content when technical writers make manual edits.
Pipeline Flow
When you push to an auto-doc/* branch, the pipeline executes two steps:
Step 1: Generate Documentation with Claude Code
- Skip Check: Verifies if Claude has already generated documentation for this branch
- Claude Generation: Runs Claude Code to generate documentation from JIRA issue
- Commit: Commits generated documentation with
[skip ci]tag - Artifacts: Captures generated markdown files and debug logs
Step 2: Build Preview and Post Link to PR
- Linting: Runs markdown linting and spell checking
- Build: Builds the Docusaurus site
- Deploy: Deploys to Firebase preview channel (expires in 7 days)
- PR Comment: Posts preview link as a comment on the pull request
One-Time Generation Guarantee
The pipeline ensures Claude generates documentation only once per branch:
How It Works
- First Push: Claude generates documentation and commits with
Co-Authored-By: Claude - Subsequent Pushes: Pipeline detects existing Claude commit and skips generation
- Manual Edits: Tech writers can freely edit generated files without triggering re-generation
Skip Logic
The pipeline checks for Claude commits only in the current branch since it diverged from trunk:
# Get the merge base (where this branch diverged from trunk)
MERGE_BASE=$(git merge-base HEAD origin/trunk)
# Only check commits that are unique to this branch (not in trunk)
CLAUDE_COMMITS=$(git log $MERGE_BASE..HEAD --grep="Co-Authored-By: Claude" --oneline | grep -c "^")
if [ "$CLAUDE_COMMITS" -gt "0" ]; then
echo "🤖 Claude has already generated documentation for this branch"
echo "⏭️ Skipping auto-doc pipeline to prevent re-generation"
exit 0
fi
Why this approach? When JIRA creates a new auto-doc/* branch from trunk, the branch contains all of trunk's history, including previous Claude commits. By using git merge-base, we only check commits that were added after the branch was created, not the entire git history.
When Claude Runs
✅ Will Generate:
- First push to a new
auto-doc/*branch - No existing commits authored by Claude
❌ Will Skip:
- Any push after Claude has generated documentation
- Commits with
[skip ci]in the message - Manual edits by tech writers
- Fixes to linting issues
Preview Deployment
Preview URL Format
https://public-documentation-8353f--docs-preview-{unique-id}.web.app
Preview Features
- Expiry: 7 days (configurable via
--expiresflag) - Channel:
docs-preview(shared across all PRs) - Access: Public URL, no authentication required
Finding Your Preview URL
- Bitbucket Pipeline: Check the "Build Preview and Post Link to PR" step output
- PR Comment: The pipeline automatically posts the preview link as a comment
- Firebase Console: View all preview channels at https://console.firebase.google.com
PR Comment
When the preview is ready, the pipeline posts a comment to the pull request:
## 🤖 Claude Documentation Preview Ready
Your AI-generated documentation is now available for review:
### 📍 Preview Link
[View Documentation Preview](https://public-documentation-8353f--docs-preview-xxx.web.app)
### 📋 Issue Details
- Issue Key: PLAYG-123
- Branch: auto-doc/PLAYG-123
- Pipeline: {pipeline-uuid}
### ⏰ Preview Expiry
This preview will expire in 7 days.
### ✅ Next Steps
1. Review the generated documentation
2. Make any necessary edits
3. Commit your changes (Claude will not re-generate)
4. Merge the PR when ready
Environment Variables Required
For Claude Generation
ANTHROPIC_API_KEY: Claude API keyATLASSIAN_USERNAME: JIRA usernameATLASSIAN_API_TOKEN: JIRA API tokenATLASSIAN_INSTANCE_URL: JIRA instance URL
For Preview Deployment
FIREBASE_SERVICE_ACCOUNT_ENCODED: Base64-encoded Firebase service account JSONBITBUCKET_PR_ID: PR ID (automatically set by Bitbucket)BITBUCKET_REPO_SLUG: Repository slug (automatically set)BITBUCKET_WORKSPACE: Workspace slug (automatically set)
For PR Comments
BITBUCKET_ACCESS_TOKEN: Access token for Bitbucket API (optional)- If not set, preview URL will be logged but not posted to PR
- Add this token to repository variables to enable PR comments
Manual Override
If you need to regenerate documentation (e.g., Claude made an error):
Option 1: Force New Generation
- Delete the branch and create a new
auto-doc/*branch - This resets the Claude commit history check
Option 2: Manual Commit Edit
- Rewrite git history to remove Claude's commit (use with caution)
- Force push to the branch
# Find Claude's commit
git log --grep="Co-Authored-By: Claude"
# Reset to before Claude's commit (replace <commit-hash>)
git reset --hard <commit-hash>
# Force push
git push --force origin auto-doc/PLAYG-XXX
⚠️ Warning: Force pushing can cause issues if others have pulled the branch.
Troubleshooting
Pipeline Skips Generation Unexpectedly
Problem: Pipeline says "Claude has already generated documentation" but you haven't seen any commits.
Possible Causes:
- Trunk was not fetched: Pipeline couldn't find the merge base with trunk
- Branch has Claude commits: There are actual Claude commits on the branch
Solution:
Check if there are Claude commits on your branch (not in trunk):
# Get merge base
MERGE_BASE=$(git merge-base HEAD origin/trunk)
# Check Claude commits since branching
git log $MERGE_BASE..HEAD --grep="Co-Authored-By: Claude" --oneline
If this shows commits, Claude has already run. If empty, the pipeline should have allowed generation.
Preview Link Not Posted to PR
Problem: Preview deploys successfully but no comment appears on PR.
Possible Causes:
BITBUCKET_ACCESS_TOKENnot setBITBUCKET_PR_IDnot available (branch not in a PR)- Insufficient permissions for the access token
Solution:
- Check repository variables for
BITBUCKET_ACCESS_TOKEN - Ensure the branch is in an open pull request
- Verify token has
pullrequest:writepermission
Preview URL Shows 404
Problem: Preview URL is generated but shows "Page Not Found".
Possible Causes:
- Build failed but deployment succeeded
- Page path doesn't match URL structure
- Sidebar configuration missing the page
Solution:
- Check the build logs for errors
- Verify front matter in the markdown file
- Test the build locally:
npm run build && npm run serve
Workflow Example
Typical Auto-Doc Flow
1. Create JIRA issue (PLAYG-123)
└─> Title: "Add 2FA Documentation"
2. Create branch: auto-doc/PLAYG-123
└─> Push to remote
3. Pipeline Step 1: Claude Generation
├─> Claude reads JIRA issue
├─> Claude generates markdown documentation
├─> Claude commits with [skip ci]
└─> Artifacts: solutions/**/*.md
4. Pipeline Step 2: Preview Deployment
├─> Lint markdown files
├─> Build Docusaurus site
├─> Deploy to Firebase preview
├─> Post preview link to PR
└─> Output: https://...--docs-preview-xxx.web.app
5. Tech Writer Review
├─> Review preview site
├─> Make manual edits if needed
├─> Commit changes
└─> Pipeline skips Claude generation (already run)
6. Merge PR
└─> Documentation merged to trunk
Best Practices
For Developers
- Branch Naming: Always use
auto-doc/JIRA-KEYformat - JIRA Issues: Ensure issue has clear description before creating branch
- Review Previews: Check preview site before merging
For Tech Writers
- Edit Freely: Make changes directly to generated markdown
- No Re-generation: Your edits won't be overwritten by Claude
- Commit Often: Regular commits help track changes
For DevOps
- Token Rotation: Rotate
BITBUCKET_ACCESS_TOKENperiodically - Firebase Cleanup: Old preview channels auto-expire after 7 days
- Monitor Logs: Check pipeline logs for generation errors
Related Scripts
scripts/claude-documentation-automation.js: Main Claude automation scriptscripts/post-preview-comment.js: Posts preview link to PRscripts/deploy-preview.js: Sets up preview environmentscripts/fix-markdown-linting.js: Auto-fixes markdown linting issues
See Also
- Local Verification Guide: Guide for running pipeline checks locally
- Repository Overview: See
CLAUDE.mdin the repository root for Claude Code instructions - Pipeline Configuration: See
bitbucket-pipelines.ymlin the repository root