Agent skill
video-downloader-transcoder
Add, repair, and verify the existing NestJS `VideoDownloaderTranscoderModule` that downloads media with `yt-dlp` via `youtube-dl-exec`, transcodes with `ffmpeg-static`, and maintains `POST /video-downloader-transcoder/transcode` with validated DTOs, quality presets, optional preview embedding, safe subprocess execution, and structured stage logging. Use when users ask to implement/fix video download+transcode APIs, debug yt-dlp/ffmpeg wiring, enforce env-driven limits, or stabilize this synchronous pipeline.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/nestjs-video-downloader-transcoder
SKILL.md
NestJS Video Downloader + Transcoder
Purpose
Use this skill for changes to the existing synchronous download+transcode feature in a NestJS backend. This skill does not design async queue/job systems unless explicitly requested.
Target Surface
Primary implementation paths:
src/libs/video-downloader-transcoder/video-downloader-transcoder.module.tssrc/libs/video-downloader-transcoder/controllers/video-downloader-transcoder.controller.tssrc/libs/video-downloader-transcoder/services/video-downloader-transcoder.service.tssrc/libs/video-downloader-transcoder/dtos/transcode-video.dto.tssrc/libs/video-downloader-transcoder/dtos/transcode-video-response.dto.ts
Hard Constraints
- Require an existing NestJS application. Do not scaffold a new app in this skill.
- Do not rely on global
ffmpeg; useffmpeg-staticpath by default. - Use
youtube-dl-execforyt-dlpexecution; support optional custom binary via env. - Spawn subprocesses with argument arrays; never interpolate untrusted input into shell strings.
- Keep the public API transport and route stable unless the user explicitly asks to change it.
- Keep descriptions/examples generic and avoid site-specific references.
Workflow
Step 1: Preflight checks (required)
Verify these before coding:
package.jsonincludes@nestjs/core.- App bootstrap file exists at
src/main.ts. - A root module exists (
src/app.module.tsor equivalent wired inmain.ts). - Target module path exists or user asked to create it.
If preconditions 1-3 fail, stop and ask for the correct existing NestJS app path.
Step 2: Dependency baseline (required)
Install runtime dependencies:
npm i youtube-dl-exec ffmpeg-static
Dependency roles:
youtube-dl-exec: manages and invokesyt-dlp.ffmpeg-static: provides absoluteffmpegexecutable path.
Step 3: Enforce module wiring and contracts (required)
Primary files to maintain:
src/libs/video-downloader-transcoder/video-downloader-transcoder.module.tssrc/libs/video-downloader-transcoder/controllers/video-downloader-transcoder.controller.tssrc/libs/video-downloader-transcoder/services/video-downloader-transcoder.service.tssrc/libs/video-downloader-transcoder/dtos/transcode-video.dto.tssrc/libs/video-downloader-transcoder/dtos/transcode-video-response.dto.ts
Ensure VideoDownloaderTranscoderModule is imported in src/app.module.ts.
Step 4: Preserve DTO and service contract (required)
VideoDownloaderTranscoderService must expose:
downloadAndTranscode(dto: TranscodeVideoDto): Promise<TranscodeVideoResponseDto>
TranscodeVideoDto must support:
sourceUrl(required)formatenum:mp4 | webm | mp3qualityenum:auto | best | worst | low | medium | highoutputNameoptionaluserAgentoptionalrefereroptionalembedPreviewImageoptional
TranscodeVideoResponseDto returns:
jobIdoutputPathformatqualitydownloadedBytesoutputBytes
Step 5: Preserve runtime behavior (required)
- Resolve workdir from env
VIDEO_TRANSCODER_WORKDIRor defaulttmp/videos. - Download with
yt-dlpusingbestvideo*+bestaudio/best. - Transcode with ffmpeg using mapped quality preset.
- Support optional preview-image embedding when
embedPreviewImage=true. - Log each stage (
accepted,download start/end,ffmpeg start/end,cleanup,error). - Clean temporary files in
finally.
Step 6: Enforce security and abuse controls (required)
- Validate URL and enums through DTO decorators.
- Enforce max download bytes via
VIDEO_TRANSCODER_MAX_DOWNLOAD_BYTES. - Sanitize
outputName. - Never pass raw shell strings to process execution.
- Keep proxy/TLS overrides env-driven:
VIDEO_TRANSCODER_YTDLP_PROXYVIDEO_TRANSCODER_YTDLP_NO_CHECK_CERTSVIDEO_TRANSCODER_YTDLP_FORCE_IPV4
Use request-level optional headers:
userAgentreferer
Step 7: Verification gates (required)
Run these checks after edits:
- Build/typecheck passes for the backend project.
- Route remains
POST /video-downloader-transcoder/transcodeunless explicitly requested otherwise. - DTO validation blocks invalid URL/enum inputs.
- Service still uses argument-array subprocess execution for
yt-dlpandffmpeg. - Temporary artifacts are cleaned on success and error paths.
Local Implementation References
- references/implementation-spec.md
- references/api-and-types.md
- references/ffmpeg-presets.md
- references/security-limits.md
- references/test-plan.md
Official References
- NestJS Controllers: https://docs.nestjs.com/controllers
- NestJS Validation: https://docs.nestjs.com/techniques/validation
- Node.js child_process: https://nodejs.org/api/child_process.html
- ffmpeg-static package: https://www.npmjs.com/package/ffmpeg-static
- youtube-dl-exec package: https://www.npmjs.com/package/youtube-dl-exec
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?