video-patterns
Skill2 starsChanged 8 months agoMITView on GitHub
Twilio development skill: video-patterns
- Reads credentials
In this repository66 other files it gives its agents.
- adversarial-reviewSkill
- agent-connectSkill
- agent-teams-guideSkill
- agent-testingSkill
- android-sdkSkill
- brainstormSkill
- branded-callingSkill
- callbacksSkill
- compliance-regulatorySkill
- conferenceSkill
- context-engineeringSkill
- context-hubSkill
- conversational-intelligenceSkill
- conversation-relay-referenceSkill
- conversation-relaySkill
- conversationrelaySkill
- conversations-v2Skill
- customer-memorySkill
- deepgramSkill
- deep-validationSkill
- elastic-sip-trunkingSkill
- env-doctorSkill
- event-streamsSkill
- getting-startedSkill
- hooks-referenceSkill
- iamSkill
- ios-sdkSkill
- ivr-crawlerSkill
- ivr-migratorSkill
- lookupSkill
- media-streamsSkill
- memory-systemsSkill
- messaging-services-referenceSkill
- messaging-servicesSkill
- messagingSkill
- multi-agent-patternsSkill
- operational-gotchasSkill
- paymentsSkill
- paySkill
- phone-numbersSkill
- proxySkill
- real-time-transcriptionSkill
- recordingsSkill
- segmentSkill
- sendgrid-emailSkill
- sip-byocSkill
- sipSkill
- sync-referenceSkill
- syncSkill
- taskrouter-referenceSkill
- taskrouterSkill
- tdd-workflowSkill
- tool-boundariesSkill
- twilio-cliSkill
- twilio-invariantsSkill
- verify-referenceSkill
- verifySkill
- videoSkill
- voice-insightsSkill
- voice-referenceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 133
Use MCP tool validate_video_room after room creation to verify:
- Very specific: line 170
Use console.log() for ALL logging, including errors.
- Very specific: line 174
Always use JSON.stringify() for response bodies:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Video Functions Context
This directory contains Twilio Video API functions for video rooms, token generation, and status callbacks.
Functions
| Function | Access | Purpose |
token.js | Public (auth-gated) | Generate Video SDK access tokens |
callbacks/room-status.protected.js | Protected | Room and participant status callbacks |
callbacks/recording-status.protected.js | Protected | Track recording callbacks |
callbacks/composition-status.protected.js | Protected | Composition callbacks |
callbacks/transcription-status.protected.js | Protected | Real-time transcription callbacks |
token.js is public (not .protected) because browser clients cannot generate Twilio request signatures. Auth is enforced via TOKEN_API_KEY — callers must pass a matching apiKey parameter. The endpoint returns 403 if TOKEN_API_KEY is not configured.
Room Types
ALWAYS use group rooms. Other types lack features and HIPAA eligibility.
| Room Type | Recommendation | Why |
group | ✅ ALWAYS | HIPAA-eligible, full features, scalable |
group-small | ❌ AVOID | Legacy alias, use group instead |
peer-to-peer | ❌ NEVER | Not HIPAA-eligible, limited features |
go | ❌ NEVER | Not HIPAA-eligible, legacy WebRTC |
Token Generation
The token.js endpoint generates JWT access tokens for the Video SDK.
Parameters:
identity(optional): Participant identity, defaults tovideo-user-{timestamp}room(optional): Room name to restrict access to specific room
Required environment variables:
TWILIO_ACCOUNT_SIDTWILIO_API_KEYTWILIO_API_SECRET
Example request:
curl "https://your-domain.twil.io/video/token?identity=alice&room=my-room"Example response:
{
"token": "eyJ...",
"identity": "alice",
"room": "my-room"
}Status Callbacks
Room Status Callback
Configure on room creation:
const room = await client.video.v1.rooms.create({
uniqueName: 'my-room',
type: 'group',
statusCallback: 'https://your-domain.twil.io/video/callbacks/room-status',
statusCallbackMethod: 'POST'
});Events received:
room-created- Room was createdroom-ended- Room endedparticipant-connected- Participant joinedparticipant-disconnected- Participant leftrecording-started- Recording beganrecording-completed- Recording finishedtrack-added- Track publishedtrack-removed- Track unpublished
Recording Status Callback
Configure on room creation:
const room = await client.video.v1.rooms.create({
uniqueName: 'my-room',
type: 'group',
recordParticipantsOnConnect: true,
recordingStatusCallback: 'https://your-domain.twil.io/video/callbacks/recording-status',
recordingStatusCallbackMethod: 'POST'
});Composition Status Callback
Configure on composition creation or via hooks:
// Manual composition
const composition = await client.video.v1.compositions.create({
roomSid: 'RM...',
audioSources: ['*'],
videoLayout: { grid: { video_sources: ['*'] } },
statusCallback: 'https://your-domain.twil.io/video/callbacks/composition-status'
});
// Auto-composition via hook
await client.video.v1.compositionHooks.create({
friendlyName: 'auto-compose',
enabled: true,
audioSources: ['*'],
videoLayout: { grid: { video_sources: ['*'] } },
statusCallback: 'https://your-domain.twil.io/video/callbacks/composition-status'
});Events received:
composition-enqueued- Queued for processingcomposition-started- Processing startedcomposition-progress- Progress update (includesPercentageDone)composition-available- Completed successfullycomposition-failed- Failed (includesErrorCode,ErrorMessage)
Deep Validation
Callbacks log to Sync for deep validation:
callbacks-video-room-{RoomSid}- Room/participant eventscallbacks-video-recording-{RecordingSid}- Recording eventscallbacks-video-composition-{CompositionSid}- Composition events
Use MCP tool validate_video_room after room creation to verify:
- Room status and type
- Participant connections
- Published tracks
- Recording/composition status
Gotchas
Composition Timing
CRITICAL: Compositions can only be created AFTER the room ends.
// WRONG - fails if room is in-progress
await client.video.v1.compositions.create({ roomSid: 'RM...' });
// RIGHT - wait for room to end first
const room = await client.video.v1.rooms(roomSid).fetch();
if (room.status === 'completed') {
await client.video.v1.compositions.create({ roomSid });
}Recording vs Composition
| Feature | Track Recordings | Compositions |
| Format | Raw per-track files | Single combined file |
| Timing | Created during room | Created after room ends |
| Use case | ML training, proctoring | Sharing, playback |
Storage Retention
Without external S3 storage, recordings are deleted after 24 hours. Configure S3 in Console → Video → Recording Settings for production.
Logging Rules
Use console.log() for ALL logging, including errors. Never use console.error() or console.warn() - they generate debugger alerts (82005/82004).
Response Bodies
Always use JSON.stringify() for response bodies:
// WRONG - causes Buffer TypeError
response.setBody({ success: true });
// RIGHT
response.appendHeader('Content-Type', 'application/json');
response.setBody(JSON.stringify({ success: true }));E2E Testing
A complete E2E test suite exists at __tests__/e2e/video-sdk/:
# Run video SDK tests
npm run test:video-sdk
# Run with visible browser
npm run test:video-sdk:headedTests verify:
- Token generation and room connection
- Two-party video calls
- Video stream rendering (dimensions > 0)
- Audio stream detection (Web Audio API)
- Room API state (type, participants)
- Disconnect handling
See skills/video/SKILL.md for detailed testing patterns.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

