Skip to main content

Deep Dive Chapter 19: File Processing Workflows

You have 847 files in your Downloads folder. You need one of them by Friday. Three of them are duplicates eating 4 GB of space. And the file your boss asked about? It's in there somewhere.

You could spend an afternoon sorting manually. Or you could describe the problem in one sentence and let an agent handle it in 30 seconds.

But here's what this chapter is actually about: it's not about files. Files are the training ground. The real skill is learning to direct an AI agent: when to trust it, when to verify, when to demand a preview, and when to just do it yourself. Every pattern you learn here transfers to email management, project organization, data pipelines, and any domain where you work with General Agents.

By the end, you'll have a reusable prompt toolkit and (more importantly) the instinct to demand safety, verification, and scripts from every agent interaction. Most people prompt blindly and hope for the best. You're about to learn the systematic approach.

In Chapter 18, you learned the Four-Phase Workflow for Claude Code sessions: Explore → Plan → Implement → Commit. File processing expands this into a seven-step framework: Survey → Backup → Design Rules → Test → Execute → Verify → Document. The extra steps exist because file operations are irreversible: a moved file is moved, a renamed file is renamed. The Four-Phase Workflow assumed version control as your safety net. Here, your files don't have git revert, so backups, testing, and verification become explicit steps instead.

📚 Teaching Aid

What You'll Learn

By the end of this chapter, you'll be able to:

SkillWhat It Looks Like
Direct file surveys"Help me understand what's eating my disk space"
Request safety-first operations"Back up important files before making changes"
Design organization systems"Create categories that make sense for my workflow"
Automate batch operations"Rename these 100 screenshots with a consistent pattern"
Recover from mistakes"Something went wrong: compare against my backup"
Search intelligently"Find that PDF from 2023 about taxes"

This isn't about learning bash. It's about learning to work effectively with General Agents.

Why This Matters

The patterns you learn in this chapter aren't just about files. They're the foundation for building AI Employees that automate these workflows entirely. Learn these patterns now or you'll struggle with automation later.

Every expert who works with General Agents mastered these fundamentals first. File organization is the perfect training ground because the problems are concrete, the feedback is immediate, and the patterns transfer everywhere.

This chapter also introduces the rhythm you will use for every agent workflow in this book: you define the goal and what correct looks like (10%), the agent does the work (80%), you check the result before accepting it (10%). That rhythm is Spec-Driven Development applied to file work: describe the outcome precisely, agent executes, you verify.

How This Chapter Teaches

Every lesson in this chapter follows the PRIMM-AI+ learning cycle: a five-stage structure that builds genuine understanding instead of copy-paste fluency. Here is how each stage applies to file processing:

StageWhat You DoIn File Processing Terms
PredictWrite down what you expect before touching the agentName the commands you think the agent will run, estimate how many files match, note your confidence
RunDirect the agent with a specific promptGive the agent a concrete instruction and watch it execute
InvestigateWrite your own explanation first, then probe deeperExplain in one sentence why the output looks the way it does, then ask the agent about edge cases
ModifyChange one variable, predict the new result, verifySwap the folder, change the file extension, or adjust the date range and confirm the outcome shifts as expected
MakeComplete a similar task independently for a new folderApply the same workflow to a different location without using the lesson's example as a template

Each stage is present in every lesson. The Predict stage is always AI-free: your notes come first, before any agent interaction. The Make stage is always the mastery gate: you pass when you complete the task independently, not when you follow the walkthrough.

Chapter Flow

LessonTimeWhat You'll Do
1. Your First Agent Workflow25 minSurvey your files through conversation
2. The Safety-First Pattern20 minLearn to require backups before changes
3. The Organization Workflow25 minDesign and execute file categorization
4. Batch Operations Workflow30 minTransform repetitive tasks into scripts
5. Error Recovery & Resilience20 minDeliberately break things and recover safely
6. Search & Discovery Workflow25 minFind lost files through description
7. Capstone: Your File Toolkit30 minBuild your personal prompt library

Total time: Approximately 2 hours 50 minutes

Seven Principles Observed

You won't memorize these principles. You'll see them in action:

PrincipleYou'll Observe The Agent...
P1: Bash is the KeyUsing ls, find, grep, mv behind the scenes
P2: Code as InterfaceCreating reusable scripts for repetitive tasks
P3: VerificationChecking results after each operation
P4: DecompositionTesting on one file before batch operations
P5: Persisting StateSaving rules and logs to files
P6: Constraints and SafetyCreating backups before destructive changes
P7: ObservabilityLogging everything and showing progress

Prerequisites

Before starting this chapter:

  • Complete Part 1
  • Have Claude Code installed and working
  • Have a Bash-compatible terminal ready:
    • macOS/Linux: Your built-in Terminal app works out of the box
    • Windows: Install Git Bash for a quick start, or run wsl --install in PowerShell for the full Linux experience via WSL
    • Stuck? Ask your AI agent: "Help me get a bash terminal working on my machine"
  • Have Python installed for running scripts
  • Have a folder with files to organize (Downloads recommended)

What You'll Build

By the end, you'll have:

DeliverablePurpose
Prompt toolkitReusable prompts for common file tasks
Organization rulesDocumented categorization logic
Search patternsTemplates for finding lost files
Automation scriptsAgent-generated code you can reuse

From Manual to Automated

The patterns you learn here become the foundation for AI Employees:

This Chapter (Manual)Automated Workflow
Manual promptingAutomatic file watching
One-time organizationContinuous organization
"Show me the plan"AI decides and acts

You're building the vocabulary and verification instincts you'll need for autonomous agents. In Part 3, you will encode these same file-handling patterns directly into AI Employees that run them autonomously, without a human in the loop for each step.