get-audio-duration — Claude Code rule: what it does, how to install
get-audio-duration — a rule that teaches Claude Code to extract audio file duration in seconds using the Mediabunny library.
no license ★ 849 updated 2026-01-24
.claude/rules/get-audio-duration.mdWhat get-audio-duration does
The rule shows the agent how to retrieve audio duration via Mediabunny, a library that runs in browsers, Node.js, and Bun. Inside: a function with Input and UrlSource for remote files, a FileSource variant for local ones, and a staticFile example for Remotion projects.
The library returns duration as a decimal number in seconds. For local files, you need a File object from an input element or drag-and-drop event.
Useful when the agent needs to know audio length before processing — calculating video timings or validating uploads, for instance.
What it helps with
- get duration of MP3, WAV and other audio formats
- check audio file length before processing
- extract audio metadata in browser or server environments
Example prompts for the agent
- Find the duration of
audio.mp3from thepublicfolder - How long is the audio at the URL in
trackUrl? - Add a function that returns the length of an uploaded WAV file
How to install get-audio-duration
Manually: put the files in place
.claude/rules/get-audio-duration.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/get-audio-duration.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/get-audio-duration.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/get-audio-duration.mdManually: put the files in place
.clinerules/get-audio-duration.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about get-audio-duration
How do I install get-audio-duration in Claude Code?
Place the rule file at .claude/rules/get-audio-duration.md in your project root.
What does the get-audio-duration rule do?
It teaches Claude Code to retrieve audio file duration in seconds using Mediabunny — for remote files by URL, local files via File API, and static files through staticFile in Remotion.
Does the rule require Mediabunny to be installed?
Yes, the rule uses mediabunny — you need to add it to your project with npm install mediabunny or another package manager.