Build a Camera That Pauses Your TV
Build a local camera monitor that pauses video after two positive checks.
Introduction
30 Second Summary
In October 2026, Jamie Quint used Codex to make an app that paused the TV when his 6-year-old sucked her thumb. His prototype used about 25 labelled photos and checked the camera every 15 seconds.
In this project, you will build watch.py, a local vision loop that checks your chosen habit every 15 seconds. It pauses your own playback target after two positive results before waiting one minute to pause again.
What You'll Build
You'll demonstrate your chosen habit, see two positive checks in the terminal, and watch your own playback target pause while every temporary frame is deleted.
By the end of this project, you'll have:
- A local yes/no check that returns JSON results through Ollama and gemma4:e2b without sending camera frames to a cloud vision API.
- A measured prompt evaluation that compares real scores from 24 consented labelled photos and saves the best-scoring prompt in prompt.txt.
- A recorded live proof showing two positive checks in the terminal before your playback target pauses with no checked frame left behind.
- Secret Mission: An optional challenge to extend your monitoring loop while preserving its privacy safeguards.
Are there any prerequisites?
You need a Claude plan that includes Claude Code on a Mac or Windows computer with at least 8 GB of RAM and about 8 GB of free disk space. Use only your own camera, space, and playback target with consent from everyone who may be filmed.
Before We Start
Camera-based automation needs clear boundaries before any hands-on work begins. This checkpoint defines your chosen habit while confirming consent for your own camera, space, and playback target.
Set Up Claude Code and a Local Vision Model
This step keeps future camera checks on your computer by using Claude Code to set up the local Ollama model.
You will finish with a local model that can inspect one consented photo. The photo remains in its original location throughout the check.
In this step, get ready to:
- Install Claude Code.
- Set up Ollama with gemma4:e2b.
- Verify a local photo description from the habit-camera project.
Install Claude Code and Ollama
You'll run the installers in Terminal on Mac or PowerShell on Windows. Native Claude Code installations update automatically after this setup.
macOS
- Press Cmd+Space to open Spotlight.
- Type Terminal.
- Press Enter to open Terminal.
- Install Claude Code by running this command:
curl -fsSL https://claude.ai/install.sh | bash
What does this command do?
The command downloads the official Claude Code installation script. It passes that script to Bash for installation.
You'll return to your shell prompt after the Claude Code installer completes.
- Install Ollama by running this command:
curl -fsSL https://ollama.com/install.sh | sh
What does this command do?
The command downloads the official Ollama installation script. It passes that script to the shell for local installation.
You'll return to your shell prompt when the Ollama installer completes without an error.
- Verify Claude Code by running this command:
claude --version
What does this command do?
The version check asks the installed Claude Code command to print its version number. A version number proves your shell can find the installation.
That is your first setup win. You'll see a version number from Claude Code.
Windows
- Press the Windows key to open search.
- Type PowerShell.
- Press Enter to open PowerShell.
- Install Claude Code by running this command:
irm https://claude.ai/install.ps1 | iex
What does this command do?
The command retrieves the official Claude Code PowerShell installation script. It passes that script to PowerShell for installation.
You'll return to your PowerShell prompt after the Claude Code installer completes.
- Install Ollama by running this command:
irm https://ollama.com/install.ps1 | iex
What does this command do?
The command retrieves the official Ollama PowerShell installation script. It passes that script to PowerShell for local installation.
You'll return to your PowerShell prompt when the Ollama installer completes without an error.
- Verify Claude Code by running this command:
claude --version
What does this command do?
The version check asks the installed Claude Code command to print its version number. A version number proves PowerShell can find the installation.
That is your first setup win. You'll see a version number from Claude Code.
Installer command did not finish?
- Copy the installation command for your operating system again if the shell reports an unrecognized character or incomplete address.
- Close the terminal after a successful installation if the Claude Code version check cannot find the command. Start a fresh terminal before checking again.
Help me troubleshoot my local Claude Code or Ollama installation.
Start the habit-camera project
The habit-camera folder gives Claude Code one workspace for every file created later. Starting Claude Code from inside that folder keeps the project contained on your Desktop.
macOS
- Create the habit-camera folder on your Desktop by running these commands:
cd ~/Desktop
mkdir habit-camera
ls
What do these commands do?
- The first command moves your terminal to your Desktop.
- The second command creates the habit-camera folder.
- The final command lists the Desktop contents so you can verify the new folder.
You'll see habit-camera in the list of Desktop items.
- Move into the new folder by running this command:
cd habit-camera
What does this command do?
The command changes the terminal's current location to the habit-camera folder.
- Start an interactive Claude Code session by running this command:
claude
What does this command do?
The command starts Claude Code from the folder your terminal currently uses. Future project work stays associated with habit-camera.
You'll see an interactive Claude Code session running from your habit-camera folder.
Windows
- Create the habit-camera folder on your Desktop by running these commands:
Set-Location -Path ~\Desktop
New-Item -Path .\habit-camera -ItemType Directory
Get-ChildItem
What do these commands do?
- The first command moves PowerShell to your Desktop.
- The second command creates the habit-camera folder.
- The final command lists the Desktop contents so you can verify the new folder.
You'll see habit-camera in the list of Desktop items.
- Move into the new folder by running this command:
Set-Location -Path .\habit-camera
What does this command do?
The command changes PowerShell's current location to the habit-camera folder.
- Start an interactive Claude Code session by running this command:
claude
What does this command do?
The command starts Claude Code from the folder PowerShell currently uses. Future project work stays associated with habit-camera.
You'll see an interactive Claude Code session running from your habit-camera folder.
Run a local photo check
This check uses one photo containing only you or someone who agreed to appear in it. The setup prompt keeps the model local without copying the photo into the project.
Before you send the prompt, predict what one-sentence description gemma4:e2b will give for your consented photo.
- Set up the local model by pasting this prompt into Claude Code:
We are building a consent-based habit camera for my own space and my own playback target. Use only local Ollama. Do not use an Ollama cloud model, any cloud vision API, an API key, or any upload. Check that Ollama is installed, then pull and run exactly gemma4:e2b. Ask me for the path to one local photo containing only me or someone who agreed to be in it. Have gemma4:e2b describe that photo in one sentence. Do not copy, move, or retain the photo. Tell me each command before you run it and fix any setup error you encounter.
What does this prompt do?
- The opening guardrail limits the project to your own space.
- The model instruction requires local gemma4:e2b through Ollama.
- The photo instruction prevents copying or retaining the consented image.
- The final instruction lets Claude Code diagnose setup problems as they appear.
You'll see the local model download progress before Claude Code asks for your photo path.
- Enter path to your consented local photo when Claude Code asks for the image location.
- Confirm that the session identifies gemma4:e2b as the model used through local Ollama.
You'll see one sentence that matches the consented photo. The terminal also shows that the model is gemma4:e2b.
That privacy foundation is now in place. Next, you'll capture one temporary frame from your own camera.
Grab a Frame From Your Camera
Claude Code has already used your local vision model to describe a consented photo without sending it to a cloud service. Now the project needs a reliable way to see one current moment from your own space.
The model cannot check your chosen habit until the project can capture one current frame from your own camera.
In this step, get ready to:
- Set up a Python 3.14.10 environment for camera capture.
- Enable camera permission for the terminal app running Claude Code.
- Capture one current frame with OpenCV for Python.
Set up the Python environment
The virtual environment lives inside habit-camera. Keeping the camera package in .venv prevents this project from changing other Python projects on your computer.
- Ask Claude Code to verify Python, create .venv, and install the camera dependency by pasting this prompt:
My chosen habit is: [[CHOSEN_HABIT="your chosen habit in one sentence"]]. Check for Python 3.14.10. If it is missing, stop and direct me to https://www.python.org/downloads/release/python-31410/ for the installer for this operating system. When Python is ready, create a virtual environment named .venv inside habit-camera. Install exactly opencv-python==5.1.0.95 in that environment. Keep every dependency local to this folder. Use the .venv/bin interpreter location on Mac or the .venv\Scripts interpreter location on Windows. Tell me what you verified before continuing.
What does this prompt do?
- The chosen habit gives Claude Code the behavior that later camera checks will look for.
- The Python check keeps the project on version 3.14.10.
- The dependency pin installs exactly opencv-python==5.1.0.95 inside .venv.
Claude Code should report Python 3.14.10 and a .venv environment inside habit-camera. It should also confirm that opencv-python==5.1.0.95 is installed in that environment.
✔️ Python is ready
Your camera foundation is in place. Claude Code has confirmed Python 3.14.10, .venv, and the pinned OpenCV package.
ⓧ I see an older Python version
The project depends on Python 3.14.10. Install that release before Claude Code creates the environment.
- Visit the official Python 3.14.10 release page.
- On macOS, use the macOS installer for macOS 10.15 or later.
- On Windows, use the recommended Windows 64-bit installer.
- Return to the existing Claude Code session.
- Continue the environment setup by pasting this prompt:
Python 3.14.10 is installed. Verify it now, then continue the environment setup from my previous prompt.
What does this prompt do?
Claude Code checks the new Python installation before it resumes the interrupted environment setup.
ⓧ Python is not installed
Claude Code has paused before creating .venv. Install Python 3.14.10 before continuing.
- Visit the official Python 3.14.10 release page.
- On macOS, use the macOS installer for macOS 10.15 or later.
- On Windows, use the recommended Windows 64-bit installer.
- Return to the existing Claude Code session.
- Resume the environment setup by pasting this prompt:
Python 3.14.10 is installed. Verify it now, then continue the environment setup from my previous prompt.
What does this prompt do?
Claude Code verifies the installed version before it creates .venv and installs OpenCV.
Grant camera access
Camera permission menus can be easy to miss. Your operating system must allow the terminal app running Claude Code to use the camera before snap.py can capture a frame.
macOS
- Enable camera access for the terminal app running Claude Code.
- In System Settings, select Privacy & Security.
- Select Camera.
- Turn on camera access for the terminal app running Claude Code.
You should see camera access enabled for the terminal app running Claude Code.
Windows
Use the instructions that match your Windows version.
Windows 11
- Turn on Camera access.
- Select Start.
- Select Settings.
- Select Privacy & security.
- Select Camera.
- Turn on Camera access.
- Turn on Let desktop apps access your camera.
- On the same camera permission page, find Let desktop apps access your camera.
- Turn on Let desktop apps access your camera.
You should see both Windows 11 camera controls turned on.
Windows 10
- Turn on camera access for the device.
- Select Start.
- Select Settings.
- Select Privacy.
- Select Camera.
- Turn on camera access.
- Turn on Allow desktop apps to access your camera.
- On the same camera permission page, find Allow desktop apps to access your camera.
- Turn on Allow desktop apps to access your camera.
You should see Windows 10 camera access enabled for desktop apps.
Create and run snap.py
The next prompt turns your camera access into one temporary image. The same path is overwritten on every run so repeated tests do not create a growing collection of frames.
Before you send this prompt, predict what the saved frame should show if the camera source and permission are correct.
- Ask Claude Code to create and run snap.py by pasting this prompt:
Create snap.py without printing the full script back to me. Use OpenCV from the .venv environment to open only my own camera. Default to camera index 0. If I explicitly provide an RTSP URL for a home camera I own, accept it as the alternative source and never print credentials. Capture exactly one frame, create the frames folder if needed, save the frame as frames/latest.jpg, overwrite that same file on every run, release the camera, and print the saved path. Handle a camera-open or frame-read failure with a clear message. Use the .venv/bin interpreter on Mac or the .venv\Scripts interpreter on Windows. Run the script now and fix errors. Do not upload the frame or call any model in this step.
What does this prompt do?
- Camera index 0 points OpenCV at the computer's default camera.
- An owned RTSP stream remains an optional source when you explicitly provide it.
- The script overwrites frames/latest.jpg so only the latest test frame remains.
- Releasing the camera makes it available to other apps after the capture finishes.
Claude Code should print the saved path frames/latest.jpg. The file now contains one current frame from your own camera.
- Ask Claude Code to display the saved frame in your computer's image viewer by pasting this prompt:
Display frames/latest.jpg in my operating system's default image viewer. Do not copy, upload, move, or modify the image.
What does this prompt do?
Claude Code uses your computer's local image viewer so you can inspect the captured frame without moving or uploading it.
You have a working camera capture now. The image should show the intended couch or desk in your own consented space.
Camera frame missing or incorrect?
- Close any other app currently using the camera before running the capture again.
- Confirm that camera access remains enabled for the terminal app running Claude Code.
- Check that snap.py uses camera index 0 unless you explicitly supplied an owned RTSP stream.
Help me diagnose my local camera capture.
Your project can now capture a current frame from your own camera. Next, you will ask the local model one precise yes-or-no question about that frame.
Ask the Model One Yes/No Question
Your camera capture is working inside the Claude Code workspace. The next question is whether local vision can turn each frame into a consistent decision.
A single promising answer cannot show whether the local question distinguishes the chosen habit from a non-habit frame.
In this step, get ready to:
- Create check.py for local JSON classification.
- Run a real habit spot check.
- Run a real non-habit spot check.
Create the local JSON check
The local Ollama request needs a fixed JSON shape so each frame can be compared the same way. Claude Code will put that contract into check.py and reject a response that breaks it.
- Create and test check.py by sending this prompt to Claude Code in the existing habit-camera session:
Create check.py without printing the full script back to me. Read frames/latest.jpg, encode it for the local Ollama REST API, and call only http://localhost:11434/api/chat with model gemma4:e2b. Use my chosen habit in a precise yes/no prompt. Require a JSON schema in format with exactly these fields: habit_seen as a boolean, confidence as a number, and reason as a short string. Include the same schema in the prompt, set temperature to 0, disable streaming, validate the returned JSON, and print one JSON line. Also measure and print the actual duration of this local check. Never call a cloud endpoint, never upload the image, and do not invent a result if the request fails. Run it and fix errors. On Mac, use the interpreter under .venv/bin. On Windows, use the interpreter under .venv\Scripts.
What does this prompt do?
- The script reads only frames/latest.jpg from your local project.
- The request goes only to http://localhost:11434/api/chat with gemma4:e2b.
- The schema requires habit_seen, confidence, and reason in every valid response.
- The measured duration records how long the local check takes on your computer.
You should see one validated JSON line with habit_seen, confidence, and reason. You should also see the actual measured duration from the local check.
Local check not completing?
- Confirm that Ollama is running locally with gemma4:e2b available.
- Confirm that frames/latest.jpg still exists inside the frames folder.
- Confirm that Claude Code used .venv/bin on Mac or .venv\Scripts on Windows.
Help me diagnose a local check that is failing without uploading the frame.
Run a positive spot check
This run gives the classifier a real frame showing the chosen habit. Keep the returned values exactly as the model reports them.
- Perform your chosen habit in front of the consented camera.
- Capture a current habit frame by sending this prompt to Claude Code:
Run snap.py now using the Python interpreter inside .venv. On Mac, use the interpreter under .venv/bin. On Windows, use the interpreter under .venv\Scripts. Keep frames/latest.jpg local and overwrite the existing file. Tell me when the new frame is saved.
How does this capture stay local?
The prompt reuses your existing snap.py camera source. It replaces the previous frames/latest.jpg on your computer.
You should see frames/latest.jpg reported as saved again. That confirms the previous frame was overwritten with the current habit frame.
Before you run the check, what value do you expect the model to return for habit_seen?
- Classify the current habit frame by sending this prompt to Claude Code:
Run check.py on the current frames/latest.jpg. Print the exact JSON returned by gemma4:e2b and the measured duration. Do not reinterpret or replace the model's values. On Mac, use the interpreter under .venv/bin. On Windows, use the interpreter under .venv\Scripts.
What does this spot check preserve?
Claude Code prints the model's exact structured result. Keeping the original values gives you honest evidence for the later evaluation.
You should see the returned habit_seen, confidence, and reason values with the measured duration. Your first measured local classification is now on screen.
Run a negative spot check
The second frame gives the same question a contrasting case. This comparison shows whether the prompt distinguishes these two real moments.
- Stop doing the chosen habit while remaining in the consented camera view.
- Capture a current non-habit frame by sending this prompt to Claude Code:
Run snap.py again using the Python interpreter inside .venv. On Mac, use the interpreter under .venv/bin. On Windows, use the interpreter under .venv\Scripts. Keep frames/latest.jpg local and overwrite the existing file. Tell me when the new frame is saved.
How is the frame replaced?
The second capture overwrites the habit frame at frames/latest.jpg. The classifier now reads the current non-habit moment from the same path.
You should see frames/latest.jpg reported as saved again. That confirms the non-habit frame replaced the earlier habit frame.
Before you run the second check, what value do you expect the model to return for habit_seen?
- Classify the new non-habit frame by sending this prompt to Claude Code:
Run check.py on the newly overwritten frames/latest.jpg. Print the exact JSON returned by gemma4:e2b and the measured duration. Compare only the two habit_seen values. Explain that the two photos form a spot check. Explain that an accuracy score needs a labelled set. On Mac, use the interpreter under .venv/bin. On Windows, use the interpreter under .venv\Scripts.
What does this comparison keep?
The comparison uses only the two real habit_seen values. A larger labelled set is needed before you can measure the prompt's score.
You should now see two real JSON results with measured durations. Keep either incorrect result as evidence for prompt evaluation.
Your two spot checks now show how the current prompt behaves on contrasting frames. Next, you will measure it against 24 consented labelled photos.
Teach It With Labelled Photos
Your habit frame and non-habit frame produced two real JSON results. Now you can test the same local question across a larger set.
Labelled examples expose recurring false alarms that the two-photo spot check can miss.
In this step, get ready to:
- Capture 24 consented photos across positive examples and negative examples.
- Measure the current prompt against all 24 photos.
- Improve the prompt using only the measured misses.
Capture 24 consented photos
The strongest set includes clear positive examples plus difficult negative near misses. Those near misses expose the boundary your prompt must describe.
- Ask Claude Code to create the labelled folders and guide the local capture flow with this prompt:
Add a labelled-capture mode without printing full scripts. Create labels/yes and labels/no. Guide me to capture exactly 12 photos of me, or another person who explicitly agreed, doing the chosen habit into labels/yes. Then capture exactly 12 photos not doing it into labels/no, including near misses such as a hand near the face if relevant. Number the files clearly, never overwrite an existing labelled photo, show the running count, and stop only when each folder contains 12 images. Keep all processing local. Run the capture flow now.
What does this capture prompt do?
- The capture flow stores 12 positive photos in labels/yes.
- The flow stores 12 negative photos in labels/no.
- Near misses test cases that look similar to the chosen habit.
- Clear numbering preserves every consented example for repeatable evaluation.
The hands-on collection is done. You should see 12 numbered photos in labels/yes plus 12 numbered photos in labels/no.
Camera capture blocked?
Camera permissions can be easy to lose track of after a system change. Use the path for your computer before retrying the capture flow.
- On Mac, select System Settings.
- Select Privacy & Security.
- Select Camera.
- Turn on camera access for the terminal app running Claude Code.
- On Windows, select Settings.
- Select Privacy & security.
- Select Camera.
- Turn on Let desktop apps access your camera.
Help me fix my local labelled capture flow.
Measure the first real score
Your two folders now hold the evidence. Testing every photo with the same local request makes the results comparable.
- Ask Claude Code to create evaluate.py and run the first evaluation with this prompt:
Create evaluate.py without printing the full script. Reuse check.py's exact local Ollama request and current habit prompt. Evaluate every image in labels/yes and labels/no. Compare habit_seen with the folder label, print the actual score as Score: X/24, and list every missed filename with its expected and returned value. Save the exact starting prompt for comparison. Do not display a sample score, target score, or invented accuracy. Run it now and preserve the result.
What does this evaluation prompt do?
- The evaluation reuses check.py's exact local Ollama request.
- Each returned habit_seen value is compared with its folder label.
- The Score: X/24 line reports the measured result from your photos.
- The missed filenames preserve the cases that need clearer prompt wording.
On Mac, Claude Code should run the evaluation with the interpreter under .venv/bin. On Windows, it should use the interpreter under .venv\Scripts.
You should see your actual Score: X/24 plus every missed filename with its expected value and returned value. The displayed score comes from your 24 consented photos.
Improve the prompt from measured misses
The missed filenames show where the current wording breaks down. Each new round must respond to those measured cases while leaving every label unchanged.
Before you send the next prompt, do you expect every rewrite to improve the measured score?
- Ask Claude Code to test up to three evidence-based prompt improvements with this prompt:
Review only the real misses printed by evaluate.py. Rewrite the habit prompt to distinguish those cases more clearly, then rerun all 24 photos. Repeat for at most three improvement rounds. Never change labels to improve the score. Print every actual round score, retain the highest-scoring prompt in prompt.txt, and print the starting score and best score together at the end. If no rewrite improves the score, keep the original prompt and say so.
What does this improvement prompt do?
- Each round rewrites the habit prompt using only the real missed cases.
- Every rewrite is tested against the same 24 labelled photos.
- The labels remain unchanged while the prompt changes.
- The highest-scoring measured version is saved in prompt.txt.
You should see every actual round score followed by the starting score and best score together. If no rewrite improves the result, the original prompt remains the measured winner.
- Confirm the final summary reports the actual starting score.
- Confirm the final summary reports the actual best score.
- Confirm prompt.txt contains the highest-scoring measured prompt.
Your best measured prompt is ready. Next, you'll connect one tested local pause action to your own playback target.
Pause the TV From Code
Your 24-photo evaluation produced a measured prompt for the chosen habit. Now Claude Code can connect that decision to one local pause action for your own playback target.
Classification alone cannot interrupt the chosen habit. This step creates one tested local action that pauses only your own playback target.
In this step, get ready to:
- Select one local pause option for your playback target.
- Satisfy the selected option's permission or local-network requirement.
- Pause your selected playback target once with pause.py.
Pick exactly one pause option
Each option produces the same project artifact: pause.py. The four available methods are Roku External Control Protocol (ECP), pyatv, a manufacturer-documented local method, or pynput.
- Select the single option that matches your playback target.
You should now have one selected local-control option. Leave the other three options unused.
- For a Roku playback target, send this prompt to Claude Code:
Create pause.py for my own Roku without printing the full script. Since Roku OS 14.1, keypress commands require Settings > System > Advanced system settings > Control by mobile apps to be set to Enabled. Ask me to confirm that setting and provide my Roku's local IP address. Send one local HTTP POST to port 8060 using keypress/Play. Do not use a Roku cloud service, a third-party platform, or hard-code any device other than the IP I confirm. Run one pause test and report the HTTP result.
What does this Roku prompt do?
The prompt limits pause.py to the Roku IP address you confirm. It asks Claude Code to report the local HTTP result from one pause test.
Claude Code should leave pause.py configured only for your Roku. Its test reports the local HTTP result.
- For an Apple TV playback target, send this prompt to Claude Code:
Install exactly pyatv==0.18.0 into .venv. Create pause.py for my own Apple TV without printing the full script. Run atvremote wizard so I can choose and pair my Apple TV, then use the saved device setup to issue the pause command. Keep pairing credentials local. Run one pause test and fix any discovery or pairing error without controlling a different device.
What does this Apple TV prompt do?
The prompt installs the pinned package inside .venv. It pairs only your Apple TV before creating the pause action.
Claude Code should leave pyatv==0.18.0 in .venv and configure pause.py for your paired Apple TV.
- For another smart TV, send this prompt after filling in the brand and model field:
My own smart TV brand and model are: [[TV_BRAND_MODEL="your smart TV brand and model"]]. Before creating pause.py, find the manufacturer's current official documentation for local-network control for this exact model. Use a purpose-built local method only. Do not use a cloud API, unofficial remote service, account token, or guessed endpoint. If the manufacturer does not document a local pause command, stop and tell me to use the media-key option instead. If it is documented, create pause.py without printing the full script and test one pause on only this TV.
What does this smart TV prompt do?
The prompt creates pause.py only when the manufacturer documents local control for the exact model. Claude Code stops before guessing when no documented local pause method exists.
Claude Code should either configure pause.py with a documented local method or stop without creating a guessed integration.
- For a video playing on this computer, send this prompt to Claude Code:
Install exactly pynput==1.8.2 into .venv. Create pause.py without printing the full script. Use pynput.keyboard Controller with Key.media_play_pause to send one play/pause media key to the video playing on this computer. Do not send any other key. Run one pause test.
What does this media-key prompt do?
The prompt installs the pinned package inside .venv. It limits pause.py to one media play or pause key.
Claude Code should leave pynput==1.8.2 in .venv and configure pause.py for local video.
Apply the selected option's requirement
A local pause method can still be blocked by a device setting, network boundary, or operating-system permission. Apply only the requirement for the option you selected.
- For Roku, set Control by mobile apps to Enabled.
- Select Settings from your Roku home screen.
- Select System.
- Select Advanced system settings.
- Select Control by mobile apps.
- Select Enabled.
On Roku OS 14.1 or later, the setting should now show Enabled.
- For Roku or Apple TV, confirm the computer and playback target use the same local network.
The computer and selected playback target should show the same local network name.
- For the macOS media-key option, grant Accessibility permission to the terminal app running Claude Code.
- Select System Settings on your Mac.
- Select Privacy & Security.
- Select Accessibility.
- Turn on access for the terminal app running Claude Code.
The terminal app should now be enabled under Accessibility.
- For the Windows media-key option, keep the video app focused during the pause test.
- Return to the video app on your Windows computer.
- Select the video area so the app remains active.
The video app should remain in the foreground before you run pause.py.
Test only your playback target
The final test proves that pause.py reaches the intended target without controlling another device. Keep unrelated windows and personal notifications out of the proof.
- Start one video on your selected playback target.
- Return to the playback target you selected earlier.
- Use its visible playback control to start the video.
Before you send the test prompt, decide which device you expect to pause.
- Run one controlled pause test by sending this prompt to Claude Code:
Start one video on my selected playback target, run pause.py once, and tell me exactly which local action was sent. If it does not pause, diagnose only the selected option. Do not add or test any of the other three options.
What does this test prompt do?
The prompt runs only the selected pause.py implementation. It keeps Claude Code focused on that option if the first attempt fails.
Your selected video should pause once. No other device should change.
That connection is working: pause.py can now pause your own playback target with one local action.
Playback target did not pause?
- Confirm that pause.py contains only the option you selected.
- Recheck the selected option's permission or same-local-network condition.
- For a media-key test, keep the video app active while the script runs.
Get help with the selected option only by using this pause-test troubleshooting prompt.
Your local pause action is ready. Next, you'll connect it to two consecutive positive checks and a one-minute cooldown.
Run the Full Loop
Your tested pause.py action can already stop your selected playback target. You now have every part needed to turn that single action into a complete monitor.
A single positive check can be a false alarm in a local vision loop. This step requires two consecutive positive checks before anything pauses.
In this step, get ready to:
- Build watch.py with Claude Code.
- Record a live proof of the two-check pause rule.
- Choose whether to keep or delete the consented labelled photos.
Build the guarded loop
The loop joins the camera source from snap.py, the best prompt in prompt.txt, the local check in check.py, and the selected action in pause.py.
Its safeguards control when pausing is allowed. Its cleanup removes each temporary frame immediately after classification.
- Use .venv/bin on Mac or .venv\Scripts on Windows for watch.py.
- Send the guarded-loop build request to Claude Code by pasting this prompt:
Create watch.py without printing the full script. Reuse the working camera source from snap.py, the best prompt from prompt.txt, the local gemma4:e2b JSON check from check.py, and only the chosen pause.py option. Every 15 seconds, capture one frame to frames/latest.jpg, check it locally, print one line with the current time, habit_seen, confidence, and measured duration, then delete that frame immediately after its check even if the check fails. Never upload, archive, or keep checked frames. One positive check must never pause anything. Pause only after two consecutive habit_seen true results. After a pause, enforce a 60-second cooldown before another pause can happen. If the measured check duration from Step 3 exceeds 15 seconds, set the interval to the next whole number above that measured duration and print the chosen interval. Stop cleanly with Ctrl+C and release the camera. Run a syntax check and a dry run before the live test.
What does this prompt build?
- The capture stage reuses the camera source that already works in snap.py.
- The local JSON check prints the current time, habit_seen, confidence, and the measured duration.
- The cleanup stage deletes frames/latest.jpg after successful checks and failed checks.
- The pause guard requires two consecutive positive results. A pause starts a 60-second cooldown.
You should see Claude Code report a passing syntax check for watch.py.
The dry run should confirm that local capture, classification, cleanup, and the selected playback control are ready for the live proof.
Dry run not ready?
- Confirm Claude Code is still working inside the existing habit-camera folder.
- Confirm the local Ollama model is available. Keep the existing camera permission enabled.
- Have Claude Code fix the cleanup path if the dry run leaves frames/latest.jpg behind.
Help me diagnose the guarded loop without changing its privacy or pause safeguards.
Record the live proof
The live proof shows the guardrail working against real camera checks. Keep the recording limited to the terminal, your consented camera view, and your own playback target.
- Start a screen recording that shows the Claude Code terminal and your selected playback target.
macOS
- Press Shift-Command-5.
- Select Record Selected Portion.
- Drag the recording boundary around the terminal and playback target.
- Click the button that starts the recording.
Windows
On Windows 11, the built-in Snipping Tool can record a selected area of your screen.
- Press Windows logo key + Shift + R.
- Drag over the area containing the terminal and playback target.
- Click Start.
Before you start the live run, do you expect the first positive result or the second consecutive positive result to pause the playback target?
- Keep the same .venv interpreter selected for the live run.
- Start the live proof through Claude Code by pasting this prompt:
Run watch.py for the live proof. I will record my screen and use only my consented camera view and my own playback target. Keep printing one line per check. Point out the two consecutive true checks, the Paused line, the one-minute cooldown state, and confirmation that frames/latest.jpg was deleted after each check. Stop when I press Ctrl+C.
What does this proof capture?
The terminal output connects each local classification to the pause decision. The first positive result increases the consecutive count without pausing.
The second positive result triggers the tested pause.py action. Frame deletion and the cooldown remain visible in the same proof.
- Perform the chosen habit long enough for watch.py to complete two checks.
You should see two consecutive habit_seen: true lines before Paused. The playback target should stop after the second positive check.
The terminal should show the one-minute cooldown state. It should also confirm that frames/latest.jpg was deleted after each check.
That is the full guardrail working. Only the second consecutive positive pauses your selected playback target.
- Stop watch.py with Ctrl+C after the proof shows the cooldown and frame deletion.
You should see a clean shutdown. The camera is released and frames/latest.jpg does not exist.
- Stop the screen recording after watch.py finishes.
macOS
- Click the stop-recording icon in the menu bar.
- Keep the recording stored only on your computer.
Windows
- Click Stop in the recording overlay.
- Keep the recording stored only on your computer.
Choose what happens to labelled photos
The live proof no longer depends on the labelled evaluation set. Your choice now controls whether those consented photos remain available for future prompt testing.
Deleting the photos is permanent. Keeping them is appropriate only while everyone shown continues to agree.
- Ask Claude Code to offer the local keep-or-delete choice by pasting this prompt:
The live proof is complete. Ask me one clear question: Keep the consented labelled photos for future prompt testing, or delete them now? If I choose delete, remove the entire labels folder and confirm that labels/yes and labels/no no longer exist. If I choose keep, leave them only on this computer and remind me who consented to their use. In both cases, confirm that frames/latest.jpg does not exist.
What does this cleanup prompt do?
Claude Code waits for your decision before changing the labelled photos. The keep path preserves them locally with continuing consent.
The delete path removes the entire labels folder. Both paths verify that the temporary checked frame is gone.
Keep the consented photos
Use this option only while everyone shown continues to agree.
- Send your keep decision to Claude Code by pasting:
Keep the consented labelled photos locally for future prompt testing. Everyone shown still agrees to their use.
What does this choice do?
Claude Code leaves labels/yes and labels/no on this computer. Each folder keeps its 12 consented photos.
Delete the consented photos
Use this option when the photos are no longer needed or consent has changed.
- Send your delete decision to Claude Code by pasting:
Delete the entire labels folder now.
What does this choice do?
Claude Code removes the labels folder. The labels/yes and labels/no paths no longer exist.
If you kept the photos, labels/yes and labels/no each still contain 12 local images with continuing consent. If you deleted them, the labels folder no longer exists.
That closes the privacy loop. Your live monitor leaves no checked frame in frames/latest.jpg.
Secret mission
Add Resume and a Tally
Your camera can pause the video after two positive checks. Extend it with two-negative recovery plus a local hourly pause tally.
Clean Up Your Resources
Clean Up Your Resources
Choose whether to keep the local project available, pause monitoring for later, or delete it completely. This project creates no per-check cloud vision bill.
Cost warning
Running watch.py uses your computer's electricity.
The habit-camera folder and gemma4:e2b use local storage.
Your existing Claude Code access remains tied to your current plan.
Resources you used:
- The local habit-camera folder contains .venv, snap.py, check.py, evaluate.py, pause.py, watch.py, prompt.txt, log.csv, plus any retained photos in labels/yes or labels/no.
- The downloaded local gemma4:e2b model stored by Ollama.
Keep everything running
No cleanup is required. Choose this while you are still testing the local loop with continuing consent.
- Keep the habit-camera folder on this computer.
- Keep gemma4:e2b available in Ollama for future local checks.
- Retain any existing labels/yes photos only while everyone shown continues to agree.
- Retain any existing labels/no photos only while everyone shown continues to agree.
- Run watch.py only while the playback target belongs to you and everyone in the camera view has agreed.
Pause - I'll come back to this later
Stop local monitoring to release the camera while keeping the project ready for another session.
- Press Ctrl+C in the terminal running watch.py.
- Wait for watch.py to print the pause counts grouped by hour.
- Keep the habit-camera folder on this computer.
- Keep gemma4:e2b available in Ollama.
- Retain any existing labelled photos only while everyone shown continues to agree.
You should see a clean shutdown with the per-hour tally. The camera is released and frames/latest.jpg remains absent.
Delete - I don't want to use this again
Remove the downloaded model first. Then remove the entire local project folder.
- Ask Claude Code to remove only the project's local model by pasting this prompt:
Remove only the local Ollama model gemma4:e2b from this computer. First tell me the exact official Ollama command you will run. Then run it and verify that gemma4:e2b is no longer installed. Do not remove any other local model.
What does this prompt do?
Claude Code removes only the downloaded gemma4:e2b model. Your other local Ollama models stay in place.
Claude Code should confirm that gemma4:e2b is no longer installed.
- Press Ctrl+C in its terminal if watch.py is still running.
- Exit the Claude Code session after the model removal is verified.
macOS
Remove the project through Finder so its virtual environment, scripts, logs, prompts, and any retained photos are deleted together.
- Press Cmd+Space to open the macOS search bar.
- Type Finder.
- Press Enter to open Finder.
- Locate the habit-camera folder in the location where you created it.
- Move the habit-camera folder to the Trash.
- Empty the Trash after confirming it contains habit-camera.
You should no longer find habit-camera, .venv, log.csv, or any retained labelled photos on your Mac.
Windows
Remove the project through File Explorer so its virtual environment, scripts, logs, prompts, and any retained photos are deleted together.
- Press the Windows key to open the Windows search bar.
- Type File Explorer.
- Press Enter to open File Explorer.
- Locate the habit-camera folder in the location where you created it.
- Delete the habit-camera folder.
- Empty the Recycle Bin after confirming it contains habit-camera.
You should no longer find habit-camera, .venv, log.csv, or any retained labelled photos on your Windows computer.
Nice Work!
Nice Work!
Your habit camera is complete! It now pauses your own playback target after two positive local checks.
You've learned how to:
- Run a local computer vision check through Ollama with gemma4:e2b. check.py returns validated JSON from a temporary camera frame. watch.py deletes that frame immediately after the check.
- Measure a prompt against 24 consented labelled photos. prompt.txt preserves the highest-scoring measured prompt.
- Control an owned playback target with one tested local method. watch.py pauses only after two positive checks. Its 60-second cooldown blocks immediate repeat pauses.
- Complete the Secret Mission by resuming playback after two negative checks. log.csv records each real pause timestamp for the per-hour tally.
Ready to quiz yourself?