Capstone: Cost-Conscious Project
Time: 30-60 minutes | Skills: Cost Tracking, Optimization, Safety, Permissions
The Scenario
You are going to complete a real coding task while actively tracking and optimizing your costs. You have a budget of $0.50 for the entire capstone (if on API billing) or a goal of staying mindful and efficient (if on a Max subscription). Along the way, you will practice every safety habit from this module.
The task: build a small utility project from scratch -- a PowerShell script that organizes files in a folder by extension (for example, moving all .jpg files into a images/ subfolder, all .txt files into a text/ subfolder, etc.).
File organization is practical, involves file operations (which test your safety habits), and is complex enough to require a real conversation with Claude. It is also small enough to complete within a budget.
Prerequisites
- Completed all three lessons in Module 13
- You can run
claudeand check/cost - You have a project folder with Git initialized
Step-by-Step Instructions
Step 1 -- Set Your Budget
Before you start Claude Code, write down your budget. If you are on API billing, your target is $0.50 or less for this entire capstone. If you are on a Max subscription, your target is to use /compact at least twice and keep the conversation as efficient as possible.
Open PowerShell and set up the project:
mkdir $env:USERPROFILE\Documents\claude-tutorials\capstone-13
cd $env:USERPROFILE\Documents\claude-tutorials\capstone-13
git init
Step 2 -- Create a Cost-Conscious CLAUDE.md
Before starting Claude, create a lean CLAUDE.md by hand. Open Notepad:
notepad CLAUDE.md
Write a minimal CLAUDE.md (aim for under 10 lines):
# Project: File Organizer
- PowerShell script that sorts files into subfolders by extension
- Target: Windows beginners
- Use PowerShell syntax, not bash
- Keep explanations simple
Save and close. This keeps your per-message token overhead tiny.
Step 3 -- Start Claude and Check Initial Cost
claude
Immediately check your starting point:
/cost
Note the number (it should be near zero).
Step 4 -- Plan Efficiently (One Prompt)
Instead of going back and forth, write a detailed prompt that covers everything:
Create a PowerShell script called organize-files.ps1 that:
1. Accepts a folder path as a parameter (default: current directory)
2. Scans all files in the folder (not subfolders)
3. Creates subfolders based on file extension (e.g., txt, jpg, pdf)
4. Moves each file into its matching subfolder
5. Skips the script itself (don't move organize-files.ps1)
6. Prints a summary of how many files were moved to each subfolder
7. Has a -WhatIf mode that shows what would happen without actually moving files
Include error handling for empty folders and permission issues.
Notice how specific this prompt is. A vague prompt like "write me a file organizer" would cost more because Claude would ask clarifying questions, and you would go back and forth. One detailed prompt saves money.
Review Claude's proposed script carefully. Check that it:
- Uses PowerShell syntax (not bash)
- Handles the
-WhatIfparameter - Skips the script file itself
- Has error handling
If it looks good, approve the file creation. If something is off, reject and give a targeted correction.
Step 5 -- Check Cost After the First Task
/cost
Write down the amount. This is your "planning + first implementation" cost.
Step 6 -- Create Test Files
Ask Claude to create some test files:
Create 6 test files in this folder: report.txt, photo.jpg, notes.txt, data.csv, image.png, readme.md. Each file can have one line of placeholder text.
Approve the file creation. Check /cost again.
Step 7 -- Compact Before Testing
Before asking Claude to help you test, compact the conversation:
/compact
This removes the detailed implementation discussion from context, saving tokens for the rest of the session. Check /cost to see your running total.
Step 8 -- Test the Script
Ask Claude to test the script:
Run organize-files.ps1 with -WhatIf first, then run it for real. Show me the results.
Review the permission prompts carefully. Claude will want to run PowerShell commands. Make sure you understand each one before approving.
After testing, verify the results:
List all files and folders to show the organized structure
Step 9 -- Commit with Git
Commit all files with the message "Add file organizer script and test files"
Approve the git commands.
Step 10 -- Final Cost Check
/cost
Write down the final number. Did you stay within your $0.50 budget?
Step 11 -- Exit and Reflect
/exit
Cost Tracking Log
Fill in this table as you work through the capstone:
| Checkpoint | Cost So Far | Notes |
|---|---|---|
| After starting Claude | $____ | Starting point |
| After creating the script | $____ | First implementation |
| After creating test files | $____ | Setup |
| After compacting | $____ | Should not increase much |
| After testing | $____ | Commands were run |
| Final total | $____ | Under budget? |
Safety Review
As you complete this capstone, verify that you followed all safety practices:
- Did you read every permission prompt before approving?
- Did you reject any prompts that you did not understand?
- Did you check that Claude was not modifying files outside your project folder?
- Is your API key safely stored as an environment variable (not in any file)?
- Does your project have a
.gitignorethat excludes sensitive files?
Stretch Goals
-
Add a
-Undofeature. Ask Claude to add a parameter that reverses the organization -- moving files back from subfolders into the main folder. Track the additional cost. -
Budget challenge. Try to complete the entire capstone (including stretch goals) for under $0.30. Use
/compactaggressively and be as specific as possible in your prompts. -
Audit your CLAUDE.md. Check whether your CLAUDE.md stayed under 10 lines. If Claude modified it during the session, trim it back.
Self-Assessment
Use this checklist to confirm you covered all the essentials:
- Set a cost budget ($0.50) before starting
- Created a lean CLAUDE.md (under 10 lines)
- Used
/costat least 4 times throughout the session - Used
/compactat least once to reduce context - Wrote specific, detailed prompts to minimize back-and-forth
- Reviewed every permission prompt before approving
- Completed the file organizer script and tested it
- Committed the project with git
- Stayed within (or close to) the stated budget
If you checked all nine boxes and stayed within budget, you have demonstrated cost-conscious, safety-aware usage of Claude Code. These habits will serve you well in every future project -- whether personal or professional. If you went over budget, review your conversation to identify where the most tokens were spent. Could you have been more specific? Should you have compacted earlier? These are the questions that make you better over time.
Congratulations!
You have completed Module 13 and the final capstone of this section. You now understand how costs work, how to optimize them, and how to stay safe while using Claude Code. These are not just "nice to know" topics -- they are essential for anyone using AI tools responsibly.
Here is what you proved you can do:
- Track costs in real time using
/cost - Optimize token usage with
/compact, specific prompts, and lean CLAUDE.md files - Follow safety practices for permissions, API keys, and file reviews
- Complete a real task within a budget constraint
You are now equipped to use Claude Code effectively, efficiently, and safely in any project.
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.