|
| 1 | +# Advanced Scanning Patterns |
| 2 | + |
| 3 | +Patterns for background execution and isolated scanning contexts when working with large document libraries. |
| 4 | + |
| 5 | +## Background Scanning |
| 6 | + |
| 7 | +### When to Use Background Scanning |
| 8 | + |
| 9 | +- Document libraries with 50+ files where scanning takes several minutes |
| 10 | +- Scheduled nightly or weekly audit runs |
| 11 | +- CI/CD pipeline integration where scanning runs asynchronously |
| 12 | + |
| 13 | +### Claude Code: Background Task Pattern |
| 14 | + |
| 15 | +Claude Code supports the `Task` tool for spawning parallel sub-agents. For background-style scanning: |
| 16 | + |
| 17 | +``` |
| 18 | +Scan these 4 document types in parallel: |
| 19 | +1. Task 1: Scan all .docx files in /docs/ → return findings summary |
| 20 | +2. Task 2: Scan all .xlsx files in /docs/ → return findings summary |
| 21 | +3. Task 3: Scan all .pptx files in /docs/ → return findings summary |
| 22 | +4. Task 4: Scan all .pdf files in /docs/ → return findings summary |
| 23 | +
|
| 24 | +Wait for all tasks to complete, then merge results. |
| 25 | +``` |
| 26 | + |
| 27 | +Each task runs in its own context window, scanning independently. The orchestrator collects results and merges them. |
| 28 | + |
| 29 | +**Limitations:** |
| 30 | +- Tasks share the same filesystem — no isolation between tasks |
| 31 | +- Each task has its own context window but sees the same working directory |
| 32 | +- Progress reporting happens only when tasks complete |
| 33 | + |
| 34 | +### GitHub Copilot: Sub-Agent Pattern |
| 35 | + |
| 36 | +Copilot agents use the `agents` frontmatter to reference sub-agents: |
| 37 | + |
| 38 | +```yaml |
| 39 | +agents: ['word-accessibility', 'excel-accessibility', 'powerpoint-accessibility', 'pdf-accessibility', 'document-inventory', 'cross-document-analyzer'] |
| 40 | +``` |
| 41 | +
|
| 42 | +The orchestrator (document-accessibility-wizard) delegates to sub-agents sequentially or by type group. True background execution is not yet supported — sub-agents run within the main conversation context. |
| 43 | +
|
| 44 | +**Practical pattern for large scans:** |
| 45 | +1. Use `document-inventory` to build the file list |
| 46 | +2. Group files by type |
| 47 | +3. Process each type group as a batch |
| 48 | +4. Report progress after each group completes |
| 49 | + |
| 50 | +### CI/CD Background Pattern |
| 51 | + |
| 52 | +For true background execution, use CI/CD pipelines: |
| 53 | + |
| 54 | +```yaml |
| 55 | +# GitHub Actions — runs asynchronously on push |
| 56 | +name: Document Accessibility Audit |
| 57 | +on: |
| 58 | + push: |
| 59 | + paths: ['**/*.docx', '**/*.xlsx', '**/*.pptx', '**/*.pdf'] |
| 60 | +jobs: |
| 61 | + audit: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - run: node .github/scripts/office-a11y-scan.mjs |
| 66 | + - run: node .github/scripts/pdf-a11y-scan.mjs |
| 67 | + - uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: audit-report |
| 70 | + path: DOCUMENT-ACCESSIBILITY-AUDIT.md |
| 71 | +``` |
| 72 | + |
| 73 | +This runs the scan in the background. Results are available as build artifacts. |
| 74 | + |
| 75 | +## Worktree Isolation |
| 76 | + |
| 77 | +### When to Use Isolated Scanning |
| 78 | + |
| 79 | +- Scanning documents in a branch without switching your working directory |
| 80 | +- Running audits against a specific git tag or release |
| 81 | +- Comparing documents across branches |
| 82 | + |
| 83 | +### Git Worktree Pattern |
| 84 | + |
| 85 | +Use `git worktree` to create isolated copies for scanning without affecting your main working directory: |
| 86 | + |
| 87 | +```bash |
| 88 | +# Create a worktree for the target branch |
| 89 | +git worktree add ../audit-workspace release/v2.0 |
| 90 | +
|
| 91 | +# Run scan against the worktree |
| 92 | +cd ../audit-workspace |
| 93 | +# (run scanning tools here) |
| 94 | +
|
| 95 | +# Clean up after scanning |
| 96 | +cd .. |
| 97 | +git worktree remove audit-workspace |
| 98 | +``` |
| 99 | + |
| 100 | +### Temp Directory Pattern |
| 101 | + |
| 102 | +For non-git scenarios or when you need a clean scanning environment: |
| 103 | + |
| 104 | +```powershell |
| 105 | +# PowerShell: Copy documents to temp for isolated scanning |
| 106 | +$ScanDir = Join-Path $env:TEMP "a11y-scan-$(Get-Date -Format 'yyyyMMdd-HHmmss')" |
| 107 | +New-Item -ItemType Directory -Path $ScanDir |
| 108 | +Copy-Item -Path "docs\*.docx","docs\*.xlsx","docs\*.pptx","docs\*.pdf" -Destination $ScanDir |
| 109 | +
|
| 110 | +# Run scan in isolated directory |
| 111 | +# (scan commands targeting $ScanDir) |
| 112 | +
|
| 113 | +# Clean up |
| 114 | +Remove-Item -Recurse -Force $ScanDir |
| 115 | +``` |
| 116 | + |
| 117 | +```bash |
| 118 | +# Bash: Copy documents to temp for isolated scanning |
| 119 | +SCAN_DIR=$(mktemp -d) |
| 120 | +cp docs/*.docx docs/*.xlsx docs/*.pptx docs/*.pdf "$SCAN_DIR/" |
| 121 | +
|
| 122 | +# Run scan in isolated directory |
| 123 | +# (scan commands targeting $SCAN_DIR) |
| 124 | +
|
| 125 | +# Clean up |
| 126 | +rm -rf "$SCAN_DIR" |
| 127 | +``` |
| 128 | + |
| 129 | +### Branch Comparison Pattern |
| 130 | + |
| 131 | +Compare document accessibility across branches: |
| 132 | + |
| 133 | +```bash |
| 134 | +# Scan current branch |
| 135 | +node .github/scripts/office-a11y-scan.mjs --output AUDIT-current.md |
| 136 | +
|
| 137 | +# Create worktree for comparison branch |
| 138 | +git worktree add ../compare-branch main |
| 139 | +
|
| 140 | +# Scan comparison branch |
| 141 | +cd ../compare-branch |
| 142 | +node .github/scripts/office-a11y-scan.mjs --output ../AUDIT-main.md |
| 143 | +
|
| 144 | +# Compare results |
| 145 | +cd .. |
| 146 | +# Use compare-audits prompt or diff the reports |
| 147 | +git worktree remove compare-branch |
| 148 | +``` |
| 149 | + |
| 150 | +## Large Library Strategies |
| 151 | + |
| 152 | +### Tiered Scanning |
| 153 | + |
| 154 | +For very large document libraries (500+ documents): |
| 155 | + |
| 156 | +**Tier 1 — Triage (minimal profile):** |
| 157 | +Scan all documents with `errors only` to identify the worst offenders. |
| 158 | + |
| 159 | +**Tier 2 — Priority (moderate profile):** |
| 160 | +Re-scan the worst 20% with errors and warnings. |
| 161 | + |
| 162 | +**Tier 3 — Comprehensive (strict profile):** |
| 163 | +Full scan of high-priority or public-facing documents. |
| 164 | + |
| 165 | +### Incremental Scanning |
| 166 | + |
| 167 | +Rather than scanning the entire library each time: |
| 168 | + |
| 169 | +1. Run a full baseline scan once |
| 170 | +2. On subsequent runs, use delta scanning (changed files only) |
| 171 | +3. Compare each delta scan against the baseline |
| 172 | +4. Run a full re-scan quarterly to catch configuration drift |
| 173 | + |
| 174 | +### Sampling Strategy |
| 175 | + |
| 176 | +For initial assessment of a large library: |
| 177 | + |
| 178 | +1. Select a proportional sample across document types and folders |
| 179 | +2. Scan 10-20 representative files |
| 180 | +3. Extrapolate issue rates to estimate total remediation effort |
| 181 | +4. Use the sample results to prioritize which folders to scan first |
0 commit comments