DevOps Daily Driver: Git, Docker, and CI Snippets in CodeShelf
DevOps engineers and SREs juggle dozens of commands daily—Docker maintenance, Git operations, Kubernetes debugging, CI pipeline fixes, and incident response procedures. Most of these commands are complex, critical, and infrequently used enough to forget the exact syntax.
The typical DevOps workflow involves:
- Googling command syntax under pressure
- Digging through old terminal history
- Copy-pasting from team wikis that may be outdated
- Asking teammates for “that Docker command” again
- Making syntax errors during critical operations
CodeShelf eliminates this friction by putting your essential DevOps commands one click away in the macOS menu bar. Here’s how to build a comprehensive operations toolkit that saves time and reduces errors.
The Cost of Command Hunting in DevOps
Time Lost to Context Switching
Consider a typical incident response:
- Alert fires: Service degraded, CPU spiking
- Context switch #1: Find terminal, ssh to server
- Context switch #2: Google “docker container memory usage command”
- Context switch #3: Switch to wiki to find logging commands
- Context switch #4: Slack teammate for Kubernetes debugging syntax
- Finally: Start actual diagnosis after 3-5 minutes of setup
With CodeShelf, step 2 becomes: “Open menu bar, copy diagnostic commands, paste to terminal.” Total setup time: 15 seconds.
Error Risk in Critical Operations
DevOps commands often have significant consequences:
- Wrong Docker flags can stop production services
- Incorrect Kubernetes selectors can affect the wrong pods
- Git mistakes can lose work or break deployment branches
- Database commands can corrupt data if parameters are wrong
Having the exact, tested commands readily available reduces operational risk.
Essential DevOps Categories in CodeShelf
1. Docker & Container Management
Container Inspection and Debugging
# Show running containers with resource usagedocker stats --no-stream
# Get detailed container infodocker inspect <container_id> | jq '.[]'
# Follow logs for specific containerdocker logs -f --tail=100 <container_name>
# Execute shell in running containerdocker exec -it <container_name> /bin/bashSystem Maintenance and Cleanup
# Clean up unused containers, networks, images, and build cachedocker system prune -a --volumes
# Show disk usage by Dockerdocker system df
# Remove dangling imagesdocker image prune
# Remove stopped containersdocker container pruneProduction Deployment Commands
# Pull latest image and restart servicedocker-compose pull webdocker-compose up -d --no-deps web
# Rolling update with zero downtimedocker service update --image myapp:latest myapp_web
# Scale service replicasdocker service scale myapp_web=52. Git Operations for Infrastructure
Branch Management for Deployments
# Create and switch to hotfix branchgit checkout -b hotfix/critical-fix-$(date +%Y%m%d)
# Safe merge with no fast-forwardgit merge --no-ff feature-branch
# Push new branch with upstream trackinggit push -u origin hotfix/critical-fix-$(date +%Y%m%d)Deployment and Release Tags
# Tag current commit for releasegit tag -a v$(date +%Y.%m.%d) -m "Production release $(date +%Y-%m-%d)"
# Push tags to remotegit push origin --tags
# List recent tagsgit tag -l --sort=-version:refname | head -10Repository Maintenance
# Clean up merged branches (keep main/develop/staging)git branch --merged | grep -v "\\*\\|main\\|master\\|develop\\|staging" | xargs -n 1 git branch -d
# Fetch and prune deleted remote branchesgit fetch --all --prune
# Reset hard to match remote (destructive - use carefully)git reset --hard origin/$(git branch --show-current)3. Kubernetes Operations
Pod and Service Debugging
# Get pod logs with previous container logskubectl logs -f pod-name --previous
# Execute shell in podkubectl exec -it pod-name -- /bin/bash
# Port forward for local debuggingkubectl port-forward pod-name 8080:80
# Get pod details and eventskubectl describe pod pod-nameCluster Resource Monitoring
# Show resource usage across nodeskubectl top nodes
# Show pod resource usage in namespacekubectl top pods -n production --sort-by=cpu
# Get all resources in namespacekubectl get all -n production
# Show cluster events (recent first)kubectl get events --sort-by=.metadata.creationTimestampDeployment Management
# Rolling restart of deploymentkubectl rollout restart deployment/app-name -n production
# Check rollout statuskubectl rollout status deployment/app-name -n production
# Rollback to previous versionkubectl rollout undo deployment/app-name -n production
# Scale deploymentkubectl scale deployment/app-name --replicas=5 -n production4. System Monitoring and Performance
Server Health Checks
# System resource overviewhtop -d 10
# Disk usage by directorydu -sh /* 2>/dev/null | sort -hr | head -20
# Memory usage breakdownfree -h && echo "" && ps aux --sort=-%mem | head -10
# Network connection monitoringnetstat -tuln | grep LISTENLog Analysis Commands
# Follow system logsjournalctl -f -u service-name
# Search logs for error patternsgrep -i "error\\|exception\\|failed" /var/log/app.log | tail -20
# Count log entries by hourawk '{print $4}' /var/log/access.log | cut -d: -f1-2 | uniq -c
# Find large log filesfind /var/log -name "*.log" -type f -exec du -sh {} \\; | sort -hr | head -105. Database Operations
PostgreSQL Maintenance
-- Check database connections and activitySELECT datname, numbackends, xact_commit, xact_rollbackFROM pg_stat_databaseWHERE datname NOT IN ('template0', 'template1', 'postgres');
-- Find slow queriesSELECT query, mean_exec_time, calls, total_exec_timeFROM pg_stat_statementsORDER BY mean_exec_time DESCLIMIT 10;
-- Check table sizesSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as sizeFROM pg_tablesORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESCLIMIT 10;Database Backup and Restore
# Create timestamped backuppg_dump -U postgres -h localhost database_name > backup_$(date +%Y%m%d_%H%M%S).sql
# Restore from backuppsql -U postgres -h localhost -d database_name < backup_file.sql
# Create compressed backuppg_dump -U postgres -h localhost database_name | gzip > backup_$(date +%Y%m%d_%H%M%S).sql.gzMulti-Step Incident Response Procedures
Performance Issue Investigation
Create a multi-step snippet for systematic performance debugging:
Step 1: System Overview
# Check overall system healthtop -bn1 | head -20df -hfree -mStep 2: Application Layer
# Check application containersdocker stats --no-streamkubectl top pods -n production --sort-by=cpuStep 3: Database Performance
-- Check for blocking queriesSELECT blocked_locks.pid AS blocked_pid, blocked_activity.usename AS blocked_user, blocking_locks.pid AS blocking_pid, blocking_activity.usename AS blocking_user, blocked_activity.query AS blocked_statement, blocking_activity.query AS current_statement_in_blocking_processFROM pg_catalog.pg_locks blocked_locksJOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pidJOIN pg_catalog.pg_locks blocking_locks ON blocking_locks.locktype = blocked_locks.locktypeJOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pidWHERE NOT blocked_locks.GRANTED;Step 4: Network and Load Balancer
# Check load balancer healthcurl -I https://api.example.com/health
# Check response timescurl -w "@curl-format.txt" -o /dev/null -s https://api.example.com/healthDeployment Rollback Procedure
Step 1: Identify Current Version
# Get current deployment imagekubectl describe deployment/app-name -n production | grep ImageStep 2: Check Rollback Targets
# List recent deployment revisionskubectl rollout history deployment/app-name -n productionStep 3: Execute Rollback
# Rollback to previous versionkubectl rollout undo deployment/app-name -n productionStep 4: Verify Rollback
# Check rollout statuskubectl rollout status deployment/app-name -n production
# Verify pods are healthykubectl get pods -n production -l app=app-nameStep 5: Test Application
# Run health checkcurl -f https://api.example.com/health || echo "Health check failed"Organizing Your DevOps Snippet Library
Hierarchical Structure
📁 Infrastructure 📁 Docker ⭐ Container Health Check ⭐ System Cleanup 📝 Multi-step: Deploy New Version 📁 Kubernetes ⭐ Pod Debugging Commands ⭐ Resource Monitoring 📝 Multi-step: Rolling Update 📁 Git Operations ⭐ Deployment Branches ⭐ Release Tags 📝 Multi-step: Hotfix Process
📁 Monitoring ⭐ System Health Overview ⭐ Log Analysis 📝 Multi-step: Performance Investigation
📁 Database ⭐ Performance Queries ⭐ Backup Commands 📝 Multi-step: Maintenance Window
📁 Incident Response 📝 Multi-step: Service Degradation 📝 Multi-step: Security Incident 📝 Multi-step: Data RecoveryFavorites Strategy for DevOps
Mark as favorites based on urgency and frequency:
Daily Operations:
- Docker container status
- Kubernetes pod monitoring
- System resource checks
- Log tailing commands
Emergency Procedures:
- Incident response multi-step workflows
- Service restart commands
- Database connection checks
- Load balancer health verification
Environment-Specific Organization
Create separate categories or use environment prefixes:
- Production Commands (marked with ⚠️ for extra caution)
- Staging Operations
- Development Utilities
- Local Testing
Measuring DevOps Productivity Impact
Incident Response Time
- Before CodeShelf: 3-5 minutes finding and verifying commands
- After CodeShelf: 15-30 seconds accessing proven procedures
- Improvement: 80-90% faster time to effective action
Operational Error Rate
- Before: 5-10% error rate on complex operations under pressure
- After: <1% error rate with tested, exact commands
- Improvement: 90% reduction in operational mistakes
Knowledge Transfer
- Before: New team members take weeks to learn all the commands
- After: Comprehensive snippet library provides immediate access to team knowledge
- Improvement: 70% faster onboarding for operations tasks
Team Adoption Best Practices
1. Start with Incident Response
Build multi-step procedures for your most common incidents first. When the next incident occurs and resolution is 5x faster, the team will immediately see the value.
2. Share Critical Commands
Use CodeShelf’s export/import feature (Pro) to share your snippet library with team members. This ensures everyone has access to the same tested, reliable commands.
3. Version Control Your Snippets
Export your snippet library regularly and commit it to a team repository. This creates a backup and allows you to track changes to operational procedures over time.
4. Create Command Documentation
Use the multi-step format to document not just the commands, but also the context and expected output. This helps team members understand when and why to use specific procedures.
Security Considerations
Sensitive Information Handling
- Don’t store passwords in snippets—use environment variables or keychain references
- Use placeholder variables for server names and sensitive parameters
- Mark sensitive snippets with clear warnings about production usage
- Export libraries without sensitive data when sharing with team members
Production Safety
# Use confirmation prompts for destructive operationsecho "About to delete unused Docker containers. Press Enter to continue or Ctrl+C to cancel"readdocker container prune -fConclusion: Operations Excellence Through Organization
DevOps success depends on reliable execution of complex procedures under pressure. CodeShelf transforms scattered command knowledge into an organized, instantly-accessible toolkit that reduces errors and accelerates response times.
The key is building your library incrementally:
- Start with daily commands you find yourself googling repeatedly
- Add multi-step procedures for your most critical operations
- Share with your team to standardize operational practices
- Refine and expand based on operational needs
Ready to eliminate command hunting? Download CodeShelf and build your comprehensive DevOps command library today.
CodeShelf is available for macOS 13 Ventura or later. Team sharing features require the Pro upgrade for export/import functionality.