X402 Advanced Workflows

By X402 Team | Last Updated: February 2026

Direct Answer

Advanced X402 workflows include multi-repository coordination for large-scale documentation, monorepo strategies for unified content management, automated cross-referencing between batches, content reuse through includes and templates, multilingual documentation workflows, and integration with static site generators for advanced publishing capabilities.

Detailed Explanation

Multi-Repository Strategies

Repository-Per-Product

Structure:

org/product-a-docs
org/product-b-docs
org/product-c-docs
org/shared-docs

When to use:

  • Independent product teams
  • Different release cycles
  • Separate access controls
  • Large organizations

Coordination approach:

# Shared templates repository
git submodule add https://github.com/org/shared-docs templates

Update templates across all repos

for repo in product--docs; do cd "$repo" git submodule update --remote templates git commit -m "Update shared templates" git push done

Cross-repo linking:

# In product-a-docs
See also: Product B Integration

Or use relative linking if deploying to unified site

See also: Product B Integration

Monorepo Approach

Structure:

org/documentation
├── products/
│   ├── product-a/
│   │   └── batch-001/
│   ├── product-b/
│   │   └── batch-001/
│   └── product-c/
│       └── batch-001/
├── shared/
│   ├── templates/
│   └── common/
└── INDEX.md

When to use:

  • Tightly coupled products
  • Shared documentation team
  • Consistent tooling and standards
  • Atomic cross-product changes

Advantages:

  • Single source of truth
  • Atomic commits across products
  • Simplified dependency management
  • Unified search

Challenges:

  • Large repository size
  • Slower Git operations
  • Complex access control
  • Merge conflicts

Advanced Git Techniques

Git Subtree for Reusable Content

Add shared content:

# Add shared content as subtree
git subtree add --prefix shared/common \
  https://github.com/org/common-docs.git main --squash

Pull updates

git subtree pull --prefix shared/common \ https://github.com/org/common-docs.git main --squash

Push changes back to source

git subtree push --prefix shared/common \ https://github.com/org/common-docs.git main

Use case:

# In product docs, include shared content
{{< include "shared/common/installation-prerequisites.md" >}}

Shared content updated centrally

All products benefit from improvements

Git Worktrees for Parallel Batches

Work on multiple batches simultaneously:

# Create worktree for each batch
git worktree add ../batch-005-worktree batch-005
git worktree add ../batch-006-worktree batch-006

Work in separate directories

cd ../batch-005-worktree

... edit batch-005 content ...

git commit -m "Progress on batch-005"

cd ../batch-006-worktree

... edit batch-006 content ...

git commit -m "Progress on batch-006"

Both worktrees share the same repository

Changes visible across worktrees after commit

Benefits:

  • No branch switching overhead
  • IDE per batch
  • Parallel development
  • Shared Git history

Sparse Checkout for Large Repos

Checkout only needed batches:

# Enable sparse checkout
git sparse-checkout init --cone

Specify directories to checkout

git sparse-checkout set batch-005 batch-006 templates

Now only specified paths are checked out

Faster operations on large repos

Content Reuse Patterns

Include Files

Markdown includes (with static site generator):

# In batch-005/api-overview.md
{{< include "../shared/api-authentication.md" >}}

shared/api-authentication.md is reused across multiple docs

Template variables:

# Define variables

product_name: "Acme Product" version: "2.5"

Use in content

Install {{product_name}} version {{version}}

Content Fragments

Shared snippets:

shared/
├── fragments/
│   ├── installation-prereqs.md
│   ├── api-auth-intro.md
│   ├── troubleshooting-steps.md
│   └── support-contact.md

Reference in content:

# Installation Guide

Prerequisites

{{< fragment "installation-prereqs.md" >}}

Installation Steps

  1. Download package
  2. Run installer
  3. Configure settings

Troubleshooting

{{< fragment "troubleshooting-steps.md" >}}

Support

{{< fragment "support-contact.md" >}}

Benefits:

  • Single source for common content
  • Consistency across documentation
  • Easy updates (change once, apply everywhere)
  • Reduced duplication

Variable Substitution

Template with variables:

# shared/templates/release-notes-template.md

{{PRODUCT_NAME}} {{VERSION}} Release Notes

Released: {{RELEASE_DATE}}

New Features

{{NEW_FEATURES}}

Bug Fixes

{{BUG_FIXES}}

Breaking Changes

{{BREAKING_CHANGES}}

Upgrade Instructions

{{UPGRADE_INSTRUCTIONS}}

Generation script:

#!/bin/bash

generate-release-notes.sh

PRODUCT_NAME="Acme API" VERSION="3.0.0" RELEASE_DATE="2024-12-01"

Read template

template=$(cat shared/templates/release-notes-template.md)

Substitute variables

output=$(echo "$template" | \ sed "s/{{PRODUCT_NAME}}/$PRODUCT_NAME/g" | \ sed "s/{{VERSION}}/$VERSION/g" | \ sed "s/{{RELEASE_DATE}}/$RELEASE_DATE/g")

Add content sections

output=$(echo "$output" | sed "s/{{NEW_FEATURES}}/$(cat release-notes/new-features.md)/") output=$(echo "$output" | sed "s/{{BUG_FIXES}}/$(cat release-notes/bug-fixes.md)/")

Save generated file

echo "$output" > "batch-020/release-notes-3.0.0.md"

Multilingual Documentation

Structure for Multiple Languages

Approach 1: Language-specific batches

batch-001-en/  # English
batch-001-es/  # Spanish
batch-001-fr/  # French
batch-001-de/  # German

Approach 2: Language subdirectories

batch-001/
  en/
    content-1.md
    content-2.md
  es/
    content-1.md
    content-2.md
  fr/
    content-1.md
    content-2.md

Approach 3: Language codes in filenames

batch-001/
  getting-started.en.md
  getting-started.es.md
  getting-started.fr.md

Translation Workflow

Translation tracking:

# batch-001/INDEX.md

Content Items (English - Source)

  • [x] Getting Started
  • [x] API Overview
  • [x] Installation Guide

Translation Status

Spanish (es)

  • [x] Getting Started (translated 2024-11-15)
  • [ ] API Overview (in progress)
  • [ ] Installation Guide (pending)

French (fr)

  • [ ] Getting Started (pending)
  • [ ] API Overview (pending)
  • [ ] Installation Guide (pending)

Translation automation:

#!/bin/bash

track-translations.sh

source_lang="en" target_langs=("es" "fr" "de" "ja")

for batch in batch-/; do # Find source files source_files=$(find "$batch/$source_lang" -name ".md")

for lang in "${target_langs[@]}"; do for source_file in $source_files; do target_file="${source_file/$source_lang/$lang}"

if [ ! -f "$target_file" ]; then echo "Missing translation: $target_file" elif [ "$source_file" -nt "$target_file" ]; then echo "Outdated translation: $target_file" fi done done done

Language Synchronization

Track source changes:

# translations/sync-status.md

Source Changes Since Last Translation

batch-001/en/getting-started.md

  • Last updated: 2024-11-20
  • Spanish translation: 2024-11-15 (OUTDATED)
  • French translation: 2024-11-18 (OUTDATED)
  • German translation: 2024-11-20 (UP TO DATE)

batch-002/en/api-overview.md

  • Last updated: 2024-11-18
  • Spanish translation: 2024-11-19 (UP TO DATE)
  • French translation: Not translated

Static Site Generator Integration

Hugo Integration

Repository structure:

x402-docs/
├── content/
│   ├── batch-001/
│   ├── batch-002/
│   └── _index.md
├── themes/
├── static/
├── config.toml
└── INDEX.md (X402 tracking)

Hugo configuration:

# config.toml
baseURL = "https://docs.example.com/"
languageCode = "en-us"
title = "Product Documentation"

[params] description = "Complete documentation" author = "Documentation Team"

[[menu.main]] name = "Home" url = "/" weight = 1

[[menu.main]] name = "API Reference" url = "/batch-001/" weight = 2

Build and deploy:

# Build static site
hugo --minify

Deploy to GitHub Pages

cd public git init git add . git commit -m "Deploy documentation" git push -f https://github.com/org/org.github.io.git main

MkDocs Integration

Project structure:

x402-docs/
├── docs/
│   ├── batch-001/
│   ├── batch-002/
│   └── index.md
├── mkdocs.yml
└── INDEX.md (X402 tracking)

MkDocs configuration:

# mkdocs.yml
site_name: Product Documentation
theme:
  name: material
  features:
  • navigation.tabs
  • search.suggest
  • content.code.annotate

nav:

  • Home: index.md
  • Getting Started:
  • batch-001/installation.md
  • batch-001/configuration.md
  • API Reference:
  • batch-002/authentication.md
  • batch-002/endpoints.md

plugins:

  • search
  • git-revision-date-localized

Build and deploy:

# Build documentation
mkdocs build

Serve locally

mkdocs serve

Deploy to GitHub Pages

mkdocs gh-deploy

Automated Cross-Referencing

Link Validation

Script to find all internal links:

#!/bin/bash

validate-cross-references.sh

echo "Validating internal links..."

broken_links=0

for file in batch-/.md; do # Extract markdown links links=$(grep -oP '\[.?\]\(\K[^)]+' "$file")

for link in $links; do # Skip external links [[ "$link" =~ ^http ]] && continue

# Resolve relative path dir=$(dirname "$file") target="$dir/$link"

# Check if target exists if [ ! -f "$target" ]; then echo "Broken link in $file: $link" broken_links=$((broken_links + 1)) fi done done

if [ $broken_links -eq 0 ]; then echo "✓ All internal links valid" exit 0 else echo "✗ Found $broken_links broken links" exit 1 fi

Automatic Link Generation

Generate index of all content:

#!/bin/bash

generate-content-index.sh

cat > CONTENT-INDEX.md <<EOF

Content Index

Generated: $(date)

All Documentation

EOF

for batch in batch-/; do batch_name=$(basename "$batch") echo "### $batch_name" >> CONTENT-INDEX.md

for file in "$batch"/.md; do [ "$file" = "$batch/INDEX.md" ] && continue

title=$(head -n 1 "$file" | sed 's/# //') relative_path="${file#./}"

echo "- $title" >> CONTENT-INDEX.md done

echo >> CONTENT-INDEX.md done

Advanced Automation

Batch Dependency Management

Define dependencies between batches:

# batch-dependencies.yml
dependencies:
  batch-005:
    requires:
  • batch-001 # Must be complete
  • batch-003 # Must be complete
blocks:
  • batch-008 # Prevents batch-008 from starting

batch-006: requires:

  • batch-002
blocks:
  • batch-009

Validation script:

#!/bin/bash

check-dependencies.sh

Read dependencies from YAML

Check that required batches are complete

Warn if starting blocked batch

batch=$1

required=$(yq ".dependencies.$batch.requires[]" batch-dependencies.yml 2>/dev/null)

for req_batch in $required; do status=$(grep "$req_batch" INDEX.md | grep -q "\[x\]" && echo "complete" || echo "incomplete")

if [ "$status" = "incomplete" ]; then echo "Warning: $batch requires $req_batch to be complete" exit 1 fi done

echo "✓ All dependencies satisfied for $batch"

Content Templates with Inheritance

Base template:

# templates/base-template.md

{{TITLE}}

Overview

{{OVERVIEW}}

Content

{{CONTENT}}

Quality Standards

  • [ ] All sections complete
  • [ ] No placeholder text
  • [ ] Spell checked
  • [ ] Ready for production

Specialized template (inherits from base):

# templates/api-template.md

{{INHERIT: base-template.md}}

{{OVERRIDE:CONTENT}}

Endpoint Details

  • URL: {{URL}}
  • Method: {{METHOD}}
  • Auth: {{AUTH}}

Request

{{REQUEST}}

Response

{{RESPONSE}}

Examples

{{EXAMPLES}} {{END_OVERRIDE}}

Template processor:

#!/bin/bash

process-template.sh

template=$1 output=$2

Process inheritance

Process variables

Generate final content

Performance Optimization

Large Repository Strategies

Shallow clones:

# Clone with limited history
git clone --depth 1 https://github.com/org/docs.git

Fetch only specific branches

git clone --single-branch --branch main https://github.com/org/docs.git

Git LFS for large files:

# Track large files
git lfs track ".png"
git lfs track ".jpg"
git lfs track ".pdf"

Clone with LFS

git lfs clone https://github.com/org/docs.git

Batch archival:

# Move old batches to separate repository
git filter-branch --subdirectory-filter batch-001 -- --all
git remote add archive https://github.com/org/docs-archive.git
git push archive main

Remove from main repository

git rm -r batch-001 git commit -m "Archive batch-001 to separate repository"

Workflow Orchestration

GitHub Actions Workflow

Complete automation:

# .github/workflows/advanced-workflow.yml
name: Advanced Documentation Workflow

on: push: branches: [main] pull_request:

jobs: quality-checks: runs-on: ubuntu-latest steps:

  • uses: actions/checkout@v3
  • name: Validate Links
run: ./scripts/validate-cross-references.sh
  • name: Check Dependencies
run: ./scripts/check-dependencies.sh
  • name: Lint Markdown
run: markdownlint batch-
/*.md

translations: runs-on: ubuntu-latest steps:

  • uses: actions/checkout@v3
  • name: Check Translation Status
run: ./scripts/track-translations.sh
  • name: Generate Translation Report
run: ./scripts/translation-report.sh

build: needs: [quality-checks] runs-on: ubuntu-latest steps:

  • uses: actions/checkout@v3
  • name: Build with Hugo
run: hugo --minify
  • name: Upload Artifacts
uses: actions/upload-artifact@v3 with: name: site path: public/

deploy: needs: [build] if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps:

  • uses: actions/download-artifact@v3
with: name: site
  • name: Deploy to Production
run: ./scripts/deploy.sh

Related Questions

  • What is X402?
  • X402 automation and tooling
  • X402 for enterprise
  • X402 team collaboration

Quality Standards

  • [x] Meets brand voice requirements
  • [x] Follows formatting standards
  • [x] Includes all required elements
  • [x] Ready for production

Start Building with X402

Get our free X402 Implementation Starter Kit with ready-to-use templates, code examples, and best practices.

What is included:

  • Quick-start implementation templates
  • API integration examples
  • Configuration best practices guide

Get the Free Starter Kit