Skip to content

Instantly share code, notes, and snippets.

@camwest
camwest / first-eval.ts
Last active August 9, 2025 23:26
LLM Evals Are Just Tests - Code Examples
it("detects when themes haven't been added", async () => {
const response = await generateAIResponse(context)
const eval = await evaluatePendingCommandAwareness(response)
expect(eval.score).toBeGreaterThan(0.85)
})
@camwest
camwest / gist3-workspace.ts
Created July 13, 2025 18:21
Deterministic file naming in video-to-transcript
// Deterministic file naming in video-to-transcript
// From: https://github.com/camwest/video-to-transcript/blob/main/src/workspace.ts
/**
* Extract a safe directory name from a YouTube URL or file path
*/
function extractProjectId(input: string): string {
// Try to extract YouTube video ID
const videoIdMatch = input.match(/(?:v=|\/)([\w-]{11})(?:\?|&|$)/);
if (videoIdMatch) {
@camwest
camwest / gist2-speaker.ts
Created July 13, 2025 18:21
Speaker identification in video-to-transcript
// Speaker identification prompt from video-to-transcript
// From: https://github.com/camwest/video-to-transcript/blob/main/src/speaker-identifier.ts#L35-L55
return `You are an expert at identifying speakers in YouTube video content. Extract FIRST NAMES ONLY from video metadata and transcript introductions.
Identify speakers by FIRST NAME ONLY for this YouTube video:
Video Title: "${metadata.title}"
Channel: "${metadata.uploader}"
Description: "${metadata.description.substring(0, 500)}..."
@camwest
camwest / gist1-cache.ts
Created July 13, 2025 18:21
Smart caching in video-to-transcript
// Smart caching in video-to-transcript
// From: https://github.com/camwest/video-to-transcript/blob/main/src/transcriber.ts#L46-L52
const responseFile = audioPath.replace(/\.[^.]+$/, '.deepgram.json');
if (!force && existsSync(responseFile)) {
console.log(`✓ Using existing transcription: ${responseFile}`);
try {
const responseText = readFileSync(responseFile, 'utf8');
const result = JSON.parse(responseText);
@camwest
camwest / settings.json
Created July 1, 2025 14:50
Claude Code Hooks Configuration - PreToolUse and PostToolUse hooks setup
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./scripts/claude-branch-protection.sh"
}
@camwest
camwest / claude-code-quality.sh
Last active July 1, 2025 15:12
Claude Code Hook: Code Quality Check - Runs TypeScript and linting after file edits
#!/bin/bash
# Claude Code Hook: Code Quality Check
# Runs TypeScript check and lint fix after file modifications
echo "🔍 Running code quality checks..."
# Run TypeScript check
echo " → Type checking..."
npx tsc --noEmit
@camwest
camwest / claude-branch-protection.sh
Last active July 1, 2025 15:12
Claude Code Hook: Branch Protection - Prevents direct commits to main branch
#!/bin/bash
# Claude Code Hook: Branch Protection
# Prevents direct commits/pushes to main branch
# Get the git command from Claude tool input
COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.command')
# Check for dangerous git operations on main branch
if echo "$COMMAND" | grep -q -E 'git\s+(commit|push.*\smain|push.*origin\s+main)'; then
@camwest
camwest / claude-branch-protection.sh
Created July 1, 2025 14:49
Claude Code Hook: Branch Protection - Prevents direct commits to main branch
#!/bin/bash
# Claude Code Hook: Branch Protection
# Prevents direct commits/pushes to main branch
# Get the git command from Claude tool input
COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | jq -r '.command')
# Check for dangerous git operations on main branch
if echo "$COMMAND" | grep -q 'git.*commit\|git.*push.*main'; then
@camwest
camwest / machine.js
Created August 26, 2020 20:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@camwest
camwest / machine.js
Created August 21, 2020 14:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)