Vibe coding with Claude Code course Β· Module 10: TikTok clone
Your own reviewer subagent: video-reviewer
In this lesson13
Go through the last three captain's reviews in your memory. In the feed you searched for pause, in the recorder for getTracks and clearInterval, in the editor for revokeObjectURL. Every time the same list: does the camera go dark, does the player stop, is the address of the recording released, does a denied access give a message. Such mistakes do not spoil the look, so lint and build do not see them, and Treasure Reels will keep getting new video components. Instead of pasting this list into the conversation every time, you will hire a boatswain who walks the rigging every evening with the same list in hand: your own subagent.
What you will learn
- recognize when your own subagent pays off and when an ordinary request is enough;
- ask Claude Code for the file
.claude/agents/video-reviewer.mdand read its frontmatter and instructions in Cursor; - call the reviewer by name and check every point of its report yourself;
- tell a subagent apart from the skill of lesson 6_1 and from
/code-review.
A subagent in one paragraph
You know the built-in Explore subagent from lesson 5_4. The Claude Code documentation describes every subagent the same way: it works in its own context window, with its own instructions, with chosen tools and with separate permissions. It starts with a clean context, so it does not see your conversation or the files Claude has already read, and only its summary comes back to the main conversation. The documentation advises writing your own subagent when you keep sending the same helper with the same instructions again and again. That is exactly our list from three reviews.
When it pays off
Your own subagent makes sense when three conditions are met at once:
- Repetition. The same check comes back with every change in the video components.
- A narrow scope. Five concrete questions, not "find all the bugs".
- Its own context. The reviewer reads a few long files, and only a short report comes back to the conversation.
A one-off question you ask with an ordinary request. A procedure that you want to run as a command in your conversation, you save as a skill. A subagent is a separate member of the crew with their own cabin and their own list.
Request for Claude Code
You can write the agent file by hand, but it is simpler to order it. In older guides you will see a wizard under the /agents command. According to the documentation, in the current version this command only reminds you to ask Claude for an agent or to edit the files in .claude/agents/, so you ask:
Create the project subagent .claude/agents/video-reviewer.md.
It may only read code: the tools Read, Grep and Glob, model sonnet.
It checks the files with video, audio, getUserMedia, MediaRecorder
and createObjectURL: whether the camera, the recording, the intervals
and the object addresses are released on unmount, whether play() handles
rejection and whether a denied access gives a message. Report in English,
every finding as file:line, what is wrong, what it threatens, how to
check it. Fix nothing, just show me the file.What Claude wrote: the frontmatter
Open .claude/agents/video-reviewer.md in Cursor. At the top stands the frontmatter, the settings between the --- lines, in the same notation as in the skill from lesson 6_1:
---
name: video-reviewer
description: Reviewer of video, camera and sound components in Treasure Reels. Checks that the camera, the player, the recording and the object addresses are released on unmount and that a denied access gives a message. Use after every change in files with video, audio, getUserMedia, MediaRecorder or createObjectURL.
tools: Read, Grep, Glob
model: sonnet
---According to the documentation only two fields are required. name is the name by which you call the agent. description is read by Claude when it decides whom to hand a task, which is why the description says what the agent checks and when to use it. The documentation advises adding a phrase like "use proactively" if you want Claude to reach for the agent on its own.
tools is the pass: the subagent gets only the listed tools. Read reads a file, Grep searches for text in files, Glob searches for files by name. Without the tools field the agent inherits all the tools available to subagents, including file editing and Bash. model is optional: without it the agent works on the same model as the conversation, and sonnet is an alias of the Sonnet model. In our run the record of the run showed two models: the main session on the model from the account settings and the reviewer on Sonnet.
What Claude wrote: the instructions
Below the frontmatter stands the body. The documentation says plainly that this is the subagent's whole system prompt: it gets it together with basic data about the environment, but without the Claude Code system prompt. That is why the list must be concrete:
1. Camera and microphone: every stream from getUserMedia has stop() on every track
(getTracks) in the effect cleanup, when the stream is replaced and on unmount,
also when the component disappears before the user gives consent.
2. Recording: MediaRecorder stopped on unmount only when state is not
"inactive"; every setInterval and setTimeout has clearInterval or clearTimeout.These are two of the five points: the remaining ones ask about play() and pause(), about revokeObjectURL and about the message on NotAllowedError and NotFoundError. Every point is a mistake you found in lessons 9_1 to 9_3, not a platitude like "check the quality". The last paragraph of the instructions sets the format of the report and tells it to end with a sentence about which findings the agent is not sure of.
Calling by name
The documentation gives two ways. You can write an ordinary sentence with the agent's name, or type @ and pick the agent from the suggestions. Claude can also reach for it on its own when the task matches the description. If the .claude/agents/ folder appeared during the session, the documentation says to restart it: /exit, then claude -c.
One limit follows from the pass. A reviewer without Bash will not run git diff or tests, so you point it at the files. This is what our call looked like after adding the "Flip camera" button:
Use the video-reviewer subagent and review @components/VideoRecorder.tsx
after the change from the last commit (the camera switch). When it is
done, copy its report to me, and below it write which points cannot be
confirmed by reading the code alone.On this branch we deliberately removed the effect that turned the camera off, because that is exactly how an agent can lose the cleanup while making another change. Lint and npx tsc --noEmit passed, and the test from lesson 9_2 failed with the name turns the camera off when leaving the page. But the test says only that the camera is still on after leaving.
What the reviewer brought
We ran this request in headless mode, claude -p, which you will meet in location 13. The run took about two and a half minutes, and the record confirmed one call of video-reviewer. The report began like this (shortened):
1. VideoRecorder.tsx:102-110 (`switchCamera`) - the previous stream never
gets `stop()`. `setStream(media)` only swaps the state, so the old camera
and microphone keep running.
2. VideoRecorder.tsx:137-141 (`disableCamera`) - `setStream(null)` does not stop
the tracks, and there is no `getTracks().forEach(stop)` either.
3. VideoRecorder.tsx:88-100 (cleanup on unmount) - the stream from `stream`
is not stopped on unmount.The report had 11 points and ended with the sentence: "I did not run the code or the tests." The reviewer did not bring a verdict, only a list of hypotheses with addresses.
How to read the report
You check every point the same way as the /security-review report in lesson 8_7: you open the file in Cursor, go to the line it points at and look for proof.
- A common cause. In our run points 1, 2 and 3 had one cause: the missing effect that calls
stop()on the tracks at every change of the stream. One fix closes three points. - True, but separate. The point about the missing
try/catchinswitchCamerawas on target: a denial when flipping the camera gave no message. - Remarks, not bugs. The last three points are trifles and descriptions of what works. A long report tires you, so in the next call add "at most 5 findings, only bugs", or fix the instructions in the agent's file.
- Details to check. In its comment the main session wrote "React 18", although the project has React 19. You check the version in
package.json, not in the report.
The fix and the second run
The fix goes in one narrow request, as in lesson 8_7: "In @components/VideoRecorder.tsx restore the effect that stops the tracks when the stream changes, and in switchCamera add try/catch with cameraErrorMessage and a check of mountedRef. Nothing else. Then lint, types and tests." In our run all 32 tests passed. We ran the second pass through claude --agent video-reviewer, which means the whole session as this agent, with the note "at most 5 findings, only bugs". It took 34 seconds, it no longer reported the camera leak, but it gave three new, smaller points, and one it marked itself as uncertain. You judge each of them like the earlier ones: a fix, a TODO note or a rejection with a reason.
Subagent, skill or /code-review
The three tools look alike but do different things:
/code-reviewfrom lesson 2_9 is a general review of bugs in behavior in a fresh subagent. Without--fixit only reports, but it does not get your list of video matters.- A skill from lesson 6_1 is a recipe that Claude loads into your conversation when you type the command or when it fits the task. It works in your conversation and in its context.
video-revieweris a permanent member of the crew: its own context, your narrow list and a pass for reading only.
My advice: start with /code-review. When you paste the same checklist for the third time, save it as a subagent.
A shared file for the crew
The file .claude/agents/video-reviewer.md lies in the project, so it travels in the repository like .claude/settings.json from lesson 8_4. The documentation advises keeping project agents in version control so that the crew can use and improve them. Agents only for yourself you keep in ~/.claude/agents/, and with the same name the project agent wins. Remember also the bill from lesson 5_10: according to the documentation, subagent calls count toward the same limits as the main conversation.
Next step
Ask for a commit, for example "The video-reviewer subagent and a fix of the camera switch". To the mentor you will send a screenshot of the working Treasure Reels, the video-reviewer report and one sentence about what you fixed after the review.
In the editor below waits the reviewer's report on a component with a leak. At every point look into the line it points at, judge it as on target or false, and then switch the component to the version after the fix and check the camera light.
Remember: a boatswain with a good list walks the rigging faster than the whole crew, but it is the captain who checks every rope the boatswain pointed at before ordering it replaced.
Code for this lesson: App.jsx
// The video-reviewer subagent's report in miniature: check every finding in the code.
// The reviewer has only Read, Grep and Glob, so it points at lines but changes nothing.
import { useState } from 'react';
const BUGGY = [
'export function VideoRecorder() {',
' const [stream, setStream] = useState(null);',
' const [facing, setFacing] = useState("user");',
'',
' async function switchCamera() {',
' const next = facing === "user" ? "environment" : "user";',
' const media = await navigator.mediaDevices.getUserMedia({',
' video: { facingMode: next },',
' });',
' setFacing(next);',
' setStream(media);',
' }',
'',
' function disableCamera() {',
' setStream(null);',
' }',
' // ...preview and buttons',
'}',
];
const FIXED = [
'export function VideoRecorder() {',
' const [stream, setStream] = useState(null);',
' const [facing, setFacing] = useState("user");',
'',
' useEffect(() => {',
' if (!stream) return;',
' return () => stream.getTracks().forEach((t) => t.stop());',
' }, [stream]);',
'',
' async function switchCamera() {',
' const next = facing === "user" ? "environment" : "user";',
' try {',
' const media = await navigator.mediaDevices.getUserMedia({',
' video: { facingMode: next },',
' });',
' setFacing(next);',
' setStream(media);',
' } catch (err) {',
' setError(cameraErrorMessage(err));',
' }',
' }',
' // ...preview and buttons',
'}',
];
const FINDINGS = [
{ id: 1, line: 11, text: 'switchCamera swaps the stream without stop() on the old tracks: the old camera keeps running.', real: true,
why: 'On target: line 11 has only setStream(media), and getTracks() appears nowhere.' },
{ id: 2, line: 15, text: 'disableCamera sets null, but the tracks do not get stop(): the light stays on after switching off.', real: true,
why: 'On target: the file has no effect with a cleanup that would stop the tracks.' },
{ id: 3, line: 7, text: 'getUserMedia in switchCamera without try/catch: a denied access gives no message.', real: true,
why: 'On target: the rejected promise ends up in no message.' },
{ id: 4, line: 11, text: 'No URL.revokeObjectURL for the preview address: memory grows with every recording.', real: false,
why: 'False: this file has no createObjectURL, so there is nothing to release. A grep for createObjectURL finds nothing.' },
];
export default function App() {
const [fixed, setFixed] = useState(false);
const [selected, setSelected] = useState(null);
const [verdicts, setVerdicts] = useState({});
const [mounted, setMounted] = useState(true);
const [liveTracks, setLiveTracks] = useState(0);
const [note, setNote] = useState('');
const lines = fixed ? FIXED : BUGGY;
function enable() {
if (!mounted) return;
setLiveTracks((n) => (fixed ? 1 : n + 1));
}
function switchCam() {
if (!mounted || liveTracks === 0) return;
setLiveTracks((n) => (fixed ? 1 : n + 1));
}
function disable() {
if (fixed) setLiveTracks(0);
}
function toggleMounted() {
if (mounted && fixed) setLiveTracks(0);
setMounted((m) => !m);
}
function changeVersion(next) {
setFixed(next);
setLiveTracks(0);
setMounted(true);
setSelected(null);
}
const lamp = liveTracks > 0;
return (
<div className="min-h-screen bg-gray-950 p-4 text-white flex flex-col gap-4 lg:flex-row">
<section className="lg:w-1/2">
<div className="mb-2 flex gap-2 text-sm">
<button type="button" onClick={() => changeVersion(false)} className={!fixed ? 'rounded bg-red-700 px-3 py-1' : 'rounded bg-gray-700 px-3 py-1'}>Version with the agent's bug</button>
<button type="button" onClick={() => changeVersion(true)} className={fixed ? 'rounded bg-green-700 px-3 py-1' : 'rounded bg-gray-700 px-3 py-1'}>After the fix</button>
</div>
<p className="text-xs text-gray-400">components/VideoRecorder.tsx (abridged)</p>
<pre className="overflow-x-auto rounded bg-gray-900 p-2 text-xs">
{lines.map((line, i) => (
<div key={i} className={selected === i + 1 ? 'bg-yellow-700' : ''}>
<span className="inline-block w-6 text-gray-500">{i + 1}</span>{line}
</div>
))}
</pre>
</section>
<section className="flex-1 space-y-3 text-sm">
<div>
<p className="font-semibold">video-reviewer report (tools: Read, Grep, Glob)</p>
{fixed ? (
<p className="rounded bg-gray-800 p-2">Second run: no camera leak reported. Check the light before you believe it.</p>
) : (
<ul className="space-y-2">
{FINDINGS.map((f) => (
<li key={f.id} className="rounded bg-gray-800 p-2">
<p>{f.id}. VideoRecorder.tsx:{f.line} - {f.text}</p>
<div className="mt-1 flex flex-wrap gap-2">
<button type="button" onClick={() => setSelected(f.line)} className="rounded bg-gray-700 px-2 py-1">Show line</button>
<button type="button" onClick={() => setVerdicts((v) => ({ ...v, [f.id]: true }))} className="rounded bg-gray-700 px-2 py-1">On target</button>
<button type="button" onClick={() => setVerdicts((v) => ({ ...v, [f.id]: false }))} className="rounded bg-gray-700 px-2 py-1">False</button>
</div>
{f.id in verdicts && (
<p className={verdicts[f.id] === f.real ? 'mt-1 text-green-400' : 'mt-1 text-red-400'}>
{verdicts[f.id] === f.real ? 'Right. ' : 'Check again. '}{f.why}
</p>
)}
</li>
))}
</ul>
)}
<button
type="button"
onClick={() => setNote('video-reviewer has no Edit or Write tool: it only reads. You order the fix in the main session with one narrow request.')}
className="mt-2 rounded bg-amber-600 px-3 py-1 text-black"
>
Ask the reviewer for a fix
</button>
{note && <p className="mt-1 text-amber-300">{note}</p>}
</div>
<div className="rounded bg-gray-900 p-2">
<p className="font-semibold">Fake camera</p>
<p>
Camera light: <span className={lamp ? 'text-red-500' : 'text-gray-500'}>{lamp ? 'β on' : 'β off'}</span>
{' '}| active streams: {liveTracks} | component: {mounted ? 'on the page' : 'unmounted'}
</p>
<div className="mt-2 flex flex-wrap gap-2">
<button type="button" onClick={enable} className="rounded bg-gray-700 px-2 py-1">Turn camera on</button>
<button type="button" onClick={switchCam} className="rounded bg-gray-700 px-2 py-1">Flip camera</button>
<button type="button" onClick={disable} className="rounded bg-gray-700 px-2 py-1">Turn camera off</button>
<button type="button" onClick={toggleMounted} className="rounded bg-gray-700 px-2 py-1">{mounted ? 'Leave the page' : 'Back to the page'}</button>
</div>
</div>
</section>
</div>
);
}Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What is a subagent in Claude Code?
2. How do you treat the video-reviewer subagent's report?
These are 2 of 6 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Vertical ordering
Put in order the steps of working with your own video-reviewer:
- Horizontal ordering
Put in order the path of the project subagent's file:
- Click in order
Build the line with which the route returns the cover from b64_json (click in order):
- Vertical ordering
Put in order the steps of the POST /api/cover route as in the code:
Tasks after this lesson
- QuestionWhat a subagent is
- Put in orderFrom the agent file to the commit
- QuestionThe reviewer's report is hypotheses
- QuestionReviewer's tools
- Put in orderAgent file in the project
- QuestionKey for the image API
- Click in orderCover as a data: address
- QuestionThe description field
- QuestionWhat the reviewer will not do
- Put in orderSteps of the cover route
- Project to submitSend Treasure Reels to mentor
- VideoModule summary