deep-validation
Skill2 starsChanged 8 months agoMITView on GitHub
Twilio development skill: deep-validation
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
- 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
- video-patternsSkill
- videoSkill
- voice-insightsSkill
- voice-referenceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Call could fail to connect
- Distinctive: line 280
USE THESE MCP TOOLS: instead of CLI commands or manual API polling.
≈ “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
name: deep-validation description: Validation patterns beyond HTTP 200. Use when building validation logic, testing Twilio integrations, or understanding status progression, Voice Insights, and debugger alert patterns.
Deep Validation Patterns for Twilio
This skill covers validation patterns that go beyond simple API response checking. Load this skill when testing Twilio integrations or building validation into workflows.
Why Deep Validation Matters
A 200 OK from Twilio API doesn't guarantee success. The operation may be queued but:
- TwiML validation could fail later
- Carrier could reject the message
- Webhook could return errors
- Call could fail to connect
- Voice quality could be degraded
Tests that only check for 200 OK give false confidence.
The Deep Validation Pattern
For each operation type, check multiple signals after API operations:
SMS/MMS Validation
interface MessageValidation {
// Primary: Check message status progression
resourceStatus: {
passed: boolean;
status: 'queued' | 'sending' | 'sent' | 'delivered' | 'undelivered' | 'failed';
};
// Secondary: Check for debugger alerts
debuggerAlerts: {
passed: boolean;
alerts: Alert[]; // Error codes 30003, 30004, etc.
};
// Optional: Check callback data (if callbacks configured)
callbackReceived: {
passed: boolean;
data: object;
};
}Status progression: queued → sending → sent → delivered
Common failure codes:
| Code | Meaning |
| 30003 | Unreachable destination |
| 30004 | Message blocked |
| 30005 | Unknown destination |
| 30006 | Landline or unreachable |
| 30007 | Carrier violation |
Voice Call Validation
interface CallValidation {
// Primary: Check call status
resourceStatus: {
passed: boolean;
status: 'queued' | 'ringing' | 'in-progress' | 'completed' | 'busy' | 'no-answer' | 'failed';
};
// Secondary: Check call events for HTTP errors
callEvents: {
passed: boolean;
events: Event[]; // HTTP requests/responses during call
};
// Secondary: Check debugger for TwiML errors
debuggerAlerts: {
passed: boolean;
alerts: Alert[];
};
// Quality: Voice Insights call summary
voiceInsights: {
passed: boolean;
summary: {
callQuality: string;
disposition: string;
jitter: number;
packetLoss: number;
};
};
}
// The enhanced Voice Insights check now interprets specific quality tags
// (high_jitter, high_packet_loss, silence, etc.), SIP response codes
// (range-based + 20 specific codes), and edge-specific quality metrics
// against thresholds. See [Voice Insights skill](/skills/voice-insights/SKILL.md)
// for full diagnostic workflows.Status progression: queued → ringing → in-progress → completed
Conference Validation
interface ConferenceValidation {
// All call validation checks, plus:
// Conference-specific: Summary metrics
conferenceSummary: {
passed: boolean;
participantCount: number;
duration: number;
aggregateQuality: string;
};
// Per-participant quality
participantSummaries: {
passed: boolean;
participants: ParticipantSummary[];
};
}Verification Validation
interface VerificationValidation {
// Primary: Check verification status
resourceStatus: {
passed: boolean;
status: 'pending' | 'approved' | 'canceled' | 'max_attempts_reached' | 'expired';
};
// Secondary: Debugger alerts
debuggerAlerts: {
passed: boolean;
alerts: Alert[];
};
}Video Room Validation
A 200 OK from Video Room API doesn't guarantee success. Participants may fail to connect, tracks may not publish, or recordings may fail silently.
interface VideoRoomValidation {
// Primary: Room status and type
roomStatus: {
passed: boolean;
status: 'in-progress' | 'completed' | 'failed';
type: string; // Should be 'group' (not legacy peer-to-peer/go)
};
// Participant checks
participants: {
passed: boolean;
count: number;
connected: number;
withTracks: number; // Participants publishing audio/video
};
// Optional: Transcription (Healthcare use case)
transcription?: {
passed: boolean;
status: 'started' | 'stopped' | 'failed';
sentenceCount: number;
speakers: string[];
};
// Optional: Recording (Professional/Proctoring use case)
recordings?: {
passed: boolean;
count: number;
byParticipant: Record<string, { audio: number; video: number }>;
allCompleted: boolean;
};
// Optional: Composition (Professional use case)
composition?: {
passed: boolean;
status: 'enqueued' | 'processing' | 'completed' | 'failed';
mediaAccessible: boolean;
};
}Video Validation Checklist:
ALWAYS CHECK (every room):
□ Room Resource - status, type = 'group', duration
□ Participant count - matches expected
□ Published tracks - participants publishing audio/video
□ Subscribed tracks - participants receiving each other
WHEN USING TRANSCRIPTION (add these):
□ Transcription resource exists and status = 'started' or 'stopped'
□ Sentences appearing (query sentences endpoint)
□ Speaker attribution working (ParticipantSid in results)
WHEN USING RECORDING (add these):
□ Recording resources exist for each participant
□ Track recordings for audio + video (+ screen if applicable)
□ After room ends: all recordings status = 'completed'
WHEN USING COMPOSITION (add these):
□ Composition created AFTER room ends (not during)
□ Composition status progresses to 'completed'
□ Media URL accessible (HTTP 200)Common Video Failure Patterns:
| Symptom | Cause | Solution |
| Room status = 'completed', duration = 0 | Empty room timeout | Set longer emptyRoomTimeout |
| Participant connected but no tracks | SDK didn't publish | Check client-side publishTrack() |
| Transcription exists but no sentences | Speech not detected | Check audio track is publishing |
| Composition status = 'failed' | Room still in-progress | Wait for room to complete first |
| Media URL returns 404 | External storage misconfigured | Check S3 credentials and bucket |
| Room type is 'peer-to-peer' or 'go' | Legacy room created | Always use type = 'group' |
Timing Considerations
Voice/Conference Insights Timing
Summaries are NOT immediately available after call/conference ends:
| State | When Available | Use |
| Partial | ~2 minutes after end (no SLA) | Quick validation |
| Complete | 30 minutes after end (guaranteed) | Final validation |
Check processingState field:
const summary = await client.insights.v1.calls(callSid).summary().fetch();
if (summary.processingState === 'complete') {
// Data is final and immutable
} else if (summary.processingState === 'partial') {
// Data may change, consider polling or waiting
}Video Room Timing
| Resource | When Available |
| Room participants | Immediately |
| Published tracks | After participant publishes |
| Transcription sentences | ~2-5 seconds after speech |
| Recordings | After room ends + processing |
| Composition | After room ends + encoding time |
Composition encoding time depends on duration:
- Short rooms (< 5 min): ~30 seconds
- Medium rooms (5-30 min): 2-5 minutes
- Long rooms (> 30 min): 10+ minutes
CRITICAL: Compositions can only be created AFTER the room ends (status = 'completed').
Debugger Alert Timing
Query debugger for alerts in the timeframe of your operation:
const alerts = await client.monitor.alerts.list({
startDate: operationStartTime,
endDate: new Date(),
logLevel: 'error'
});MCP Validation Tools (Preferred Method)
USE THESE MCP TOOLS instead of CLI commands or manual API polling. They're available via the Twilio MCP server.
Available Tools
| MCP Tool | Purpose |
validate_call | Deep call validation with Voice Insights, events, content quality |
validate_message | Message delivery validation with debugger check |
validate_recording | Recording completion validation |
validate_transcript | Transcript completion + sentence validation |
validate_debugger | Account-wide debugger error check |
validate_voice_ai_flow | Full Voice AI flow (call + recording + transcript + SMS) |
validate_two_way | Two-way conversation validation |
validate_language_operator | Language Operator results validation |
validate_video_room | Video room validation with participants, tracks, transcription, recording, composition |
validate_sync_document | Sync Document data structure validation |
validate_sync_list | Sync List item count and structure validation |
validate_sync_map | Sync Map keys and values validation |
validate_task | TaskRouter task deep validation |
validate_sip | SIP infrastructure validation |
Using MCP Tools (Claude Code)
# Validate a call - checks status, events, Voice Insights
validate_call(callSid: "CA123...", validateContent: true)
# Validate message delivery
validate_message(messageSid: "SM456...")
# Full Voice AI flow validation
validate_voice_ai_flow(
callSid: "CA123...",
forbiddenPatterns: ["application error", "please try again"]
)
# Check debugger for recent errors
validate_debugger(lookbackSeconds: 300, logLevel: "error")
# Basic video room validation
validate_video_room(roomSid: "RM123...")
# Healthcare use case (with transcription)
validate_video_room(
roomSid: "RM123...",
expectedParticipants: 3,
checkTranscription: true
)
# Professional use case (with recording + composition)
validate_video_room(
roomSid: "RM123...",
checkRecording: true,
checkComposition: true,
waitForCompositionComplete: true,
timeout: 300000 # 5 min for composition
)
# Proctoring use case (recording only, no composition)
validate_video_room(
roomSid: "RM123...",
expectedParticipants: 1,
checkPublishedTracks: true, # Verify screen share
checkRecording: true
)Why MCP Tools Over CLI
| CLI Approach | MCP Tool Approach |
| Manual polling with retries | Automatic polling with timeout |
| Parse text output | Structured JSON response |
| Multiple commands needed | Single tool call |
| No content validation | Forbidden pattern detection |
| Manual error correlation | Unified error reporting |
Using the DeepValidator (Programmatic)
For programmatic use in Node.js, the DeepValidator helper is at twilio/src/validation/deep-validator.ts:
import { DeepValidator } from '../validation/deep-validator';
// Validate a message
const result = await DeepValidator.validateMessage(messageSid, {
waitForTerminal: true, // Wait for delivered/failed status
timeout: 30000 // Max wait time
});
if (!result.success) {
console.log('Failures:', result.errors);
}
// Validate a call
const callResult = await DeepValidator.validateCall(callSid, {
waitForComplete: true,
checkVoiceInsights: true
});
// Validate a conference
const confResult = await DeepValidator.validateConference(conferenceSid, {
waitForComplete: true,
checkParticipantQuality: true
});Integration with Tests
Jest Matchers
The test helper provides custom matchers:
import { setupDeepValidation } from '../helpers/deep-validation';
beforeAll(() => {
setupDeepValidation();
});
test('SMS delivers successfully', async () => {
const message = await sendTestSms();
await expect(message.sid).toBeDelivered();
await expect(message.sid).toHaveNoDebuggerAlerts();
});
test('Call completes with good quality', async () => {
const call = await makeTestCall();
await expect(call.sid).toCompleteSuccessfully();
await expect(call.sid).toHaveGoodVoiceQuality();
});Callback Infrastructure
For deep validation of callbacks, the project uses Sync-based callback capture:
├── status-callback.protected.js # Captures message/call status
├── fallback-handler.protected.js # Captures fallback events
└── voice-events.protected.js # Captures voice events
All callbacks write to Sync documents with 24hr TTL for test retrieval.Validation Checklist
For Every Operation
- Check resource status via API
- Query debugger for errors in timeframe
- Verify no unexpected alerts
For Voice Calls
- Check call events for HTTP errors
- Verify Voice Insights summary (after 2+ minutes)
- Check quality metrics if available
For Conferences
- All call validation checks
- Conference summary metrics
- Per-participant quality checks
For SMS/MMS
- Wait for terminal status (delivered/failed)
- Check for carrier rejection codes
- Verify callback data if configured
For Video Rooms
- Verify room type is 'group' (not legacy peer-to-peer/go)
- Check participant count matches expected
- Verify participants are publishing tracks
- If using transcription: check status and sentences
- If using recording: verify recordings exist per participant
- If using composition: wait for room end, then check composition status
- Verify composition media is accessible
Anti-Patterns
Don't Do This
// BAD: Only checking HTTP status
const response = await client.messages.create({ to, from, body });
if (response.sid) {
console.log('Success!'); // False confidence
}Do This Instead (MCP Tool)
# BEST: Use MCP validation tool
validate_message(messageSid: "SM123...", waitForTerminal: true)Do This Instead (Programmatic)
// GOOD: Deep validation in code
const message = await client.messages.create({ to, from, body });
const validation = await DeepValidator.validateMessage(message.sid, {
waitForTerminal: true
});
if (validation.success) {
console.log('Message delivered successfully');
} else {
console.log('Issues found:', validation.errors);
}Related Documentation
- MCP Validation Tools - Tool definitions
- DeepValidator source - Library implementation
- Validation CLAUDE.md - Validation patterns
- Callback functions - Callback infrastructure
- Voice skill - Voice-specific validation
- Video skill - Video-specific validation and use cases
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.

