SESSION: P16g Project Audit & Refactor

Summary

Triggered by discovering audio and bluetooth were never tested on the P16g (deployed Apr 2). Escalated to a full project audit which revealed phases 5-6 marked "Done" but thin, and phases 10-13 as stubs. Claude ran a comprehensive audit agent, produced a 5-batch enhancement plan, then executed with parallel agents.

Results: 6 phases enhanced, 716 → 1,883 lines (+1,167 lines of substance). Build clean.

Audit Plan

Claude’s Audit Plan

Full audit of the P16g deployment project reveals 70% completeness. Phases 0-4, 7, 8, 8b are excellent (90-100%). Phases 5-6 are marked "Done" but thin. Phases 9-13 are incomplete/stubs.

Phase Before After Action

5: First Boot

64 lines, no verification

142 lines, 10 verification checks

Enhance

6: Desktop

161 lines, no audio/BT/GPU

481 lines, full hardware validation

Major enhance

9: Development

118 lines, partial

202 lines, npm/Docker/hooks added

Enhance

10: AI Stack

72 lines, stub

323 lines, full RTX 5090 Ollama deploy

Rewrite

11: Verification

70 lines, empty checklist

352 lines, real commands + expected output

Rewrite

13: Maintenance

231 lines, template

383 lines, systemd timers + rollback

Enhance

Execution: 3 parallel agents per batch. Batches 1+2+3 simultaneous (independent files), then 4+5.

Results

Phase Before After Delta

5: First Boot

64

142

+78

6: Desktop

161

481

+320

9: Development

118

202

+84

10: AI Stack

72

323

+251

11: Verification

70

352

+282

13: Maintenance

231

383

+152

Total

716

1,883

+1,167

Key Additions

  • Phase 6: sof-firmware for onboard Dolby speakers, PipeWire verification, bluetoothctl pairing workflow, NVIDIA nvidia-smi validation, DRM modesetting check, 3.2K OLED scaling config, Hyprland process validation, 17-item checklist

  • Phase 10: Ollama model selection table for RTX 5090 (24GB GDDR7), bind mount to /home for storage, custom modelfiles (domus-chat-v3, quick), systemd service, GPU memory management

  • Phase 11: Real verification commands with expected output for every subsystem — system, security, desktop, dev tools, AI stack, secrets, networking. 22-item summary checklist.

Commands Learned

find → process piping (3 patterns)

Three ways to pass find output to another command:

# Pattern 1: -exec (handles spaces, one file at a time)
find . -type f -name "*.adoc" -exec bat {} \;

# Pattern 2: xargs (batched, faster for many files)
find . -type f -name "*.adoc" | xargs bat

# Pattern 3: command substitution (interactive — opens in editor)
nvim $(find . -type f -name "*.adoc")
Pattern Handles Spaces Multiple Files Interactive

-exec cmd {} \;

Yes

One at a time

No

| xargs cmd

No (use -0 with -print0)

Batched

No

cmd $(find …​)

No

All at once

Yes (nvim)

Space-safe version with xargs:

find . -type f -name "*.adoc" -print0 | xargs -0 bat

find → awk range extraction

Extract specific line ranges from files found by find:

# Basic range
find . -type f -name "*.adoc" -exec awk 'NR>=50,NR<=75' {} \;

# With xargs
find . -type f -name "*.adoc" | xargs awk 'NR>=50,NR<=75'

# With filename header (multiple files)
find . -type f -name "*.adoc" -exec sh -c 'echo "=== $1 ==="; awk "NR>=50,NR<=75" "$1"' _ {} \;

# With line numbers
find . -type f -name "*.adoc" -exec awk 'NR>=50 && NR<=75 {printf "%4d: %s\n", NR, $0}' {} \;

Brace expansion for multi-file operations

# Check line counts across specific phases using brace expansion
wc -l phase-{5,6,9,10,11,13}*.adoc

Workflow Notes

Capture Method

  1. Claude proposed the audit plan in the terminal

  2. Used tmux yank to copy the plan text

  3. Piped to tee to create the session file

  4. Ran git status to verify the file was created

  5. Edited in nvim to add the Appendix with CLI exercises

  6. Renamed file with mv for better context

  7. Committed and pushed

Meta-Learning

Tested the find | xargs | awk commands on this session file itself — practicing the commands while documenting them. Every command in the "Commands Learned" section was executed against this document before being written here.

Error Caught

# WRONG: {} doesn't work with xargs (it's a find -exec thing)
find . -name "*.adoc" | xargs awk 'NR>=160' {} \;
# awk: fatal: cannot open file `{}' for reading

# CORRECT: xargs passes filenames as trailing arguments automatically
find . -name "*.adoc" | xargs awk 'NR>=160'

Improvement: capture-session Shell Function

For faster future captures, add to .zshrc:

# Capture Claude plan to session file with proper AsciiDoc header
capture-session() {
    local slug="${1:-$(date +%Y-%m-%d)}"
    local dir=~/atelier/_bibliotheca/domus-captures/docs/modules/ROOT/pages/sessions
    local file="${dir}/SESSION-${slug}.adoc"
    cat > "${file}" << SESSIONEOF
= SESSION: ${slug}
:description:
:revdate: $(date +%Y-%m-%d)
:icons: font

== Summary

== Plan

.Claude's Plan
$(cat)

== Commands Learned

== Workflow Notes
SESSIONEOF
    echo "Created: ${file}"
}

Usage: tmux-yank | capture-session "p16g-refactor-2026-04-06"