Agent skill
typescript-file-downloader-module
Add, repair, or standardize an in-repo Node.js TypeScript file downloader module (plain TS or NestJS) with required Referer/User-Agent headers, optional cookie normalization, streamed disk writes, deterministic `DownloadResult` states, and non-throwing error mapping. Use when users ask to build/fix downloader services, enforce safe path and protocol controls, or align existing downloader behavior with stable response contracts.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/typescript-file-downloader-module
SKILL.md
TypeScript File Downloader Module
Overview
Implement downloader functionality inside the existing repository structure with a FileDownloadService that exposes download(req): Promise<DownloadResult>.
Return deterministic DownloadResult objects for both success and failure states, including timing, HTTP metadata, file metadata, and normalized error codes.
Preflight
- Detect project style first: plain TypeScript app, NestJS app, or mixed monorepo.
- Reuse existing package manager, scripts, and lint/test tooling already present in the repository.
- Locate existing downloader-related code and integrate there instead of creating parallel abstractions.
- Read and apply these references before implementation:
references/implementation-spec.mdreferences/error-codes.mdreferences/test-plan.md
Required Output
When executing this skill, always deliver:
- In-repo implementation integrated into the existing system (new/updated files in current app structure).
- Reuse existing workspace/package configuration; do not scaffold a new standalone npm package unless explicitly requested.
- Export points and module wiring needed for current architecture (plain TS exports or Nest module/provider wiring).
- A short usage example aligned with the current project style.
- A statement of the selected HTTP client (
undicipreferred) and why. - A sample
DownloadResultJSON for success and failure.
Workflow
- Define or align types first (
DownloadRequest,DownloadResult, progress/event types, options). - Implement input validation and path/protocol safety gates before any network call.
- Implement HTTP download via streaming file writes (never full-memory buffering).
- Map all known failure paths to standardized
error.codevalues and returnstate: "failed"instead of throwing. - Add checksum generation for completed downloads and keep result shape stable across outcomes.
- Add or align module wiring and exports:
- Plain TS: stable exports from existing index/entry files.
- NestJS: provider/module wiring and exports for
FileDownloadService.
- Add or update tests for minimum acceptance behavior from
references/test-plan.md. - Update existing project docs only if required for discoverability in the current repository.
Verification Gates
- Build/typecheck passes with the repository's existing command set.
- New/updated tests for downloader behavior pass (or clearly report blocker and failing case).
- Downloader returns deterministic
DownloadResultobjects for both success and failure. - No path traversal outside allowed root unless explicit override is enabled.
- No
file:or non-HTTP(S) URL acceptance. - No default console logging unless logger/callback is explicitly configured.
Guardrails
- Never throw for expected failure cases. Return
state: "failed"and a structurederror. - Keep response shape stable across all outcomes.
- Stay silent by default (no console logging unless logger or callback is provided).
- Default to safe path behavior: deny traversal outside
process.cwd()unless explicitly allowed by options. - Forbid non-HTTP(S) protocols and reject
file:URLs. - Prefer minimal-change integration into existing folders, naming, and module boundaries.
Reference Files
- Use
references/implementation-spec.mdfor DTO contract, layout, behaviors, and defaults. - Use
references/error-codes.mdfor standardizederror.codemapping. - Use
references/test-plan.mdfor minimum acceptance tests.
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?