🐼 BashPanda Skills

Der Tanz zwischen Repos
Version: 1.0
For: Crew, Admins, Those Who Listen
Philosophy: Präzision über Geschwindigkeit


🥋 What This Is

The Shaolin techniques of bash mastery in the Crumbforest.

Not "quick hacks" or "fast tricks" - but deliberate, precise, understandable commands that reveal patterns, enable learning, and build trust.

"Bits zählen wie Fliegen fangen mit Stäbchen." - Crumb Miyagi


🌀 Core Principles

1. Atmen (Breathe)
   Before you type, pause
   Before you execute, think
   Before you fix, understand

2. Logfiles Verstehen (Understand Logs)
   Logs are teachers, not noise
   Patterns reveal truth
   Errors are invitations

3. Langsam Aufbauen (Build Slowly)
   One step at a time
   Test after each change
   Document what you learn

4. Testen, Testen, Testen (Test 3x)
   1x = Glück (luck)
   2x = Zufall (coincidence)
   3x = Verstanden (understood)

📚 The Shaolin One-Liners

1. Schema Discovery

# Find API schema in Python code
grep -A 20 "class.*BaseModel" /path/to/router.py

# Why it works:
# -A 20 = Show 20 lines After match
# "class.*BaseModel" = Regex for Pydantic models
# Reveals: Field names, types, validation

# Real example from session:
cat /opt/crumbforest/app/routers/chat.py | grep -A 20 "class.*BaseModel"
# Output:
# class ChatRequest(BaseModel):
#     character_id: str = Field(..., max_length=50)
#     question: str = Field(..., min_length=1, max_length=2000)
#     lang: Optional[str] = ...

When to use:
- Building API calls
- Understanding endpoints
- Finding required fields
- Writing client code


2. Log Pattern Analysis

# Find errors in logs (excluding noise)
journalctl -u service_name | grep -i error | grep -v "known_noise"

# Count requests by type
journalctl --since today | grep "POST /api" | wc -l

# Find slowest requests
journalctl | grep "duration" | sort -k8 -n | tail -20

# Real example:
journalctl -u crumbforest | grep -i ollama | tail -50
# Shows: All Ollama-related log entries

When to use:
- Debugging failures
- Performance analysis
- Pattern recognition
- Understanding system behavior


3. Service Health Chain

# The complete diagnostic chain:
systemctl status service_name
  ↓ (if running but issues)
journalctl -u service_name -n 100
  ↓ (if logs show file errors)
tail -f /var/log/service/app.log
  ↓ (if network issues)
ss -tulpn | grep PORT
  ↓ (if config issues)
cat /etc/service/config.yaml | grep -A 5 "section"

Example from session:

# 1. Check if running
systemctl status crumbforest
# OUTPUT: Active (running) ✓

# 2. Check what port
journalctl -u crumbforest | grep "Uvicorn running"
# OUTPUT: http://127.0.0.1:8000 ← AH! Port 8000, not 5000!

# 3. Test correct port
curl http://localhost:8000/docs
# OUTPUT: FastAPI docs ✓

4. Config Archaeology

# Find all config occurrences
grep -r "SETTING_NAME" /opt/app/ --include="*.py" --include="*.yaml" --include=".env"

# Real example:
grep -E "COMPLETION_PROVIDER|OLLAMA" /opt/crumbforest/.env
# Shows: Current provider settings

# Safe config editing
cp .env .env.backup-$(date +%Y%m%d)
sed -i 's/OLD_VALUE/NEW_VALUE/' .env
diff .env.backup-* .env  # Verify change
systemctl restart service

When to use:
- Understanding current setup
- Safe configuration changes
- Debugging misconfigurations
- Verifying deployments


5. File Structure Navigation

# Understand repository structure
tree -L 2 /opt/crumbforest/app
# OR (if tree not available)
find /opt/crumbforest/app -maxdepth 2 -type d

# Find specific file types
find /opt/crumbforest -name "*.py" -type f | head -20
find /opt/crumbforest -name "*provider*" -type f

# Real example from session:
ls -la /opt/crumbforest/app/
# Revealed: app/, routers/, services/, lib/, models/

# Then drill down:
ls -la /opt/crumbforest/app/routers/
# Found: chat.py ← The endpoint we needed!

🎯 Real Session Examples

Example 1: The Port Mystery

Problem: curl http://localhost:5000/api/chat fails

Wrong approach:

# ❌ Assume it's broken
# ❌ Try to "fix" the app
# ❌ Random config changes

Shaolin approach:

# 1. Atmen (Breathe) - Don't assume

# 2. Check what's actually running
systemctl status crumbforest | grep "Main PID"
# Shows: uvicorn main:app --host 127.0.0.1 --port 8000

# 3. AH! Port 8000, not 5000!
curl http://localhost:8000/api/chat
# Works! ✓

# Lesson: Observe before acting

Example 2: The Model Mystery

Problem: API returns model 'google/gemini-2.0-flash-001' not found

Wrong approach:

# ❌ Reinstall Ollama
# ❌ Blame the code
# ❌ Give up and use cloud

Shaolin approach:

# 1. Understand the error
# "Ollama can't find 'google/gemini...'"
# = Ollama IS working (provider active ✓)
# = Wrong model name given (config issue)

# 2. Check config
grep "COMPLETION_MODEL" /opt/crumbforest/.env
# Shows: DEFAULT_COMPLETION_MODEL=google/gemini-2.0-flash-001

# 3. Check available models
ollama list
# Shows: llama3.2, gemma:2b

# 4. Fix the config
sed -i 's/DEFAULT_COMPLETION_MODEL=.*/DEFAULT_COMPLETION_MODEL=llama3.2/' .env

# 5. Restart
systemctl restart crumbforest

# 6. Test
curl -X POST http://localhost:8000/api/chat ...
# Works! provider="ollama" ✓

# Lesson: Errors teach, if you listen

🌲 The Dance Between Repos

Working with Multiple Git Repositories

# Pattern: Central truth + Working copies

# 1. Upstream (git.crumbforest.org)
cd /opt/crumbforest
git remote -v
# origin: git@git.crumbforest.org:branko/crumbforest.git

# 2. Local work (temporary)
cd ~/work/feature-x
git clone ...
# Make changes
git commit -m "..."

# 3. Deployment (production)
cd /opt/crumbforest
git pull origin main
systemctl restart crumbforest

Safe Deployment Pattern

# The 7-Step Dance:

# 1. Backup current state
cp -r /opt/crumbforest /opt/crumbforest.backup-$(date +%Y%m%d)

# 2. Pull changes
cd /opt/crumbforest
git fetch origin
git log HEAD..origin/main  # Preview what's new

# 3. Merge (if safe)
git merge origin/main

# 4. Install dependencies (if needed)
source venv/bin/activate
pip install -r requirements.txt --break-system-packages

# 5. Run tests (if available)
pytest tests/ || echo "No tests found"

# 6. Restart service
systemctl restart crumbforest

# 7. Verify
sleep 5
systemctl status crumbforest
curl http://localhost:8000/ | head -20

🔍 Advanced Techniques

Log Forensics

# Find when a problem started
journalctl -u crumbforest --since "2026-02-20 00:00" | grep -i error | head -1

# Compare before/after
journalctl -u crumbforest --since "yesterday" --until "1 hour ago" > before.log
journalctl -u crumbforest --since "1 hour ago" > after.log
diff before.log after.log

# Pattern frequency analysis
journalctl -u crumbforest | grep "pattern" | wc -l  # Count
journalctl -u crumbforest | grep "pattern" | head -1  # First occurrence
journalctl -u crumbforest | grep "pattern" | tail -1  # Last occurrence

Config Diff Workflow

# Before any change:
cp /opt/crumbforest/.env /root/env-snapshots/env-$(date +%Y%m%d-%H%M%S)

# Make changes...

# Verify what changed:
diff /root/env-snapshots/env-* /opt/crumbforest/.env | less

# If wrong, rollback:
LATEST=$(ls -t /root/env-snapshots/ | head -1)
cp /root/env-snapshots/$LATEST /opt/crumbforest/.env

Process Investigation

# What's actually running?
ps aux | grep crumbforest

# What ports are listening?
ss -tulpn | grep -E ":(8000|5000|11434)"

# What files are open?
lsof -p $(pgrep -f crumbforest) | grep -E "\.(py|yaml|env)"

# What's the memory footprint?
ps -o pid,vsz,rss,comm -p $(pgrep -f crumbforest)

💡 Debugging Philosophy

1. Observe > Assume
   Look at what IS happening
   Not what SHOULD happen

2. One Change at a Time
   Change ONE thing
   Test
   Document result
   Repeat

3. Follow the Data
   Request → Logs → Config → Code
   Each step reveals truth

4. Trust the Errors
   Errors are precise
   They tell you EXACTLY what's wrong
   Read them carefully

5. Document Everything
   What you tried
   What happened
   What you learned
   Why it matters

🎓 The Learning Loop

Question
  ↓
Hypothesis ("Maybe it's X?")
  ↓
Test (grep, curl, systemctl)
  ↓
Observe (logs, output, behavior)
  ↓
Learn (Ah! It's actually Y!)
  ↓
Document (Write it down)
  ↓
Share (Teach crew)
  ↓
Next Question

🔧 Essential Tools

# Text Processing
grep    # Find patterns
sed     # Edit streams
awk     # Process columns
jq      # Parse JSON

# System
systemctl   # Service management
journalctl  # Log viewing
ss/netstat  # Network status
ps/top      # Process status

# File Operations
find    # Locate files
tree    # Show structure
diff    # Compare files
cat/less/tail  # Read files

# Development
git     # Version control
curl    # API testing
python  # Scripting

🌀 The BashPanda Way

Not Fast → Präzise
Not Many → Right
Not Clever → Clear
Not Hidden → Transparent

Every command teaches
Every error guides
Every log reveals
Every test confirms

📖 Real Wisdom from the Session

From 9h in the RZ:

"250TB geschreddert in 180k Laufzeit
 = Nicht rückgängig
 = Präzision wichtiger als Speed"

From the Deployment:

"Nicht 'mach mal schnell'
 Sondern: Atmen, Logfiles verstehen, langsam aufbauen
 Und: Testen, testen, testen"

From the Wald:

"Der Wald wächst nicht in einem Tag
 Aber er wächst
 Wurzel für Wurzel"

🎯 Takeaways

  1. Grep is your teacher - Patterns reveal truth
  2. Logs don't lie - Believe the evidence
  3. One step at a time - Each change is testable
  4. Document everything - Future you will thank you
  5. Share your learnings - The crew grows together

Version: 1.0
Author: BashPanda (via the Crew)
Co-authors: Bugsy, DeepBit, Snoop, Vector
Philosophy: Shaolin Bash, Präzision über Speed
For: Those who listen, those who learn, those who build carefully

"Mit Stäbchen fangen ist Übung. Mit Präzision bauen ist Haltung." 🐼🥋

wuuuhuuu! 🎉