Skip to main content
skill CX Codex

add-audio — Claude Code skill: game music and SFX

This skill adds background music and sound effects to a browser game using the Web Audio API. No audio files, no npm packages — everything is synthesized in the browser.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add PlayableIntelligence/game-creator --skill add-audio -a claude-code
Open on GitHub

What add-audio does

The skill reads the game at the path you give it, checks src/core/EventBus.js and the scene files, then lays out a table of what audio each scene and event needs. After that it creates src/audio/AudioManager.js for AudioContext setup and the master gain node, AudioBridge.js to wire events to audio, music.js with looping BGM patterns, and sfx.js with one-shot effects built from OscillatorNode, GainNode and BiquadFilterNode. Music runs on a Web Audio step sequencer; effects fire once per event.

It also adds AUDIO_INIT, MUSIC_GAMEPLAY, MUSIC_GAMEOVER, MUSIC_STOP and AUDIO_TOGGLE_MUTE to the event bus, calls initAudioBridge() in main.js, and hooks a mute toggle to a UI button and the M key. The last step runs npm run build and lists every file it touched.

Here is the catch: browsers block audio until the user interacts with the page, so AudioContext has to resume on the first click, tap or keypress — otherwise the game stays silent. And never build new nodes inside the update loop. That is what causes frame drops; keep SFX one-shot and let a single looping sequencer handle BGM. The skill handles audio only — gameplay and visuals are out of scope.

What it helps with

  • add background music to each game scene
  • give jump, score and death events their own sounds
  • loop BGM without shipping audio files
  • wire a mute toggle to the M key
  • connect game events to audio through the event bus

Example prompts for the agent

  • /add-audio examples/flappy-bird
  • add music and sound effects to the game in src/game
  • make my game sound good — scene music plus event SFX

How to install add-audio

1Skills CLI (Vercel)

npx skills add PlayableIntelligence/game-creator --skill add-audio -a claude-code

2Manually: put the files in place

~/.claude/skills/add-audio/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/add-audio/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about add-audio

How do I install add-audio in Claude?

Run npx skills add PlayableIntelligence/game-creator --skill add-audio -a claude-code. The skill lands in ~/.claude/skills/add-audio/SKILL.md.

What does add-audio do?

It adds procedural music and sound effects to an existing game through the Web Audio API: looping BGM per scene, one-shot SFX for game events, and a mute toggle.

Why is there no sound after adding audio?

Browsers require a user interaction before playing audio. Click, tap or press a key once so AudioContext resumes, then the music starts.

Source text

SKILL.md · MIT
---
name: add-audio
description: Add music and sound effects to a game using the Web Audio API — background music, gameplay themes, and SFX. Zero dependencies. Use when the user says "add music", "add sound effects", "add audio", "make it sound good", "add BGM", or "add SFX to my game". Do NOT use for gameplay features or visual design.
argument-hint: "[path-to-game]"
license: MIT
metadata:
  author: OpusGameLabs
  version: 1.3.0
  tags: [game, audio, music, sfx, web-audio-api]
---

## Performance Notes

- Take your time to do this thoroughly
- Quality is more important than speed
- Do not skip validation steps

# Add Audio

Add procedural music and sound effects to an existing game. BGM uses a Web Audio API step sequencer for looping patterns. SFX use the Web Audio API directly for true one-shot playback. No audio files or npm packages needed — everything is synthesized in the browser.

## Instructions

Analyze the game at `$ARGUMENTS` (or the current directory if no path given).

First, load the game-audio skill to get the full Web Audio patterns and integration guide.

### Step 1: Audit

- Read `src/core/EventBus.js` to see what game events exist (flap, score, death, etc.)
- Read all scene files to understand the game flow (gameplay, game over)
- Identify what music and SFX would fit the game's genre and mood

### Step 2: Plan

Present a table of planned audio:

| Event / Scene | Audio Type | Style | Description |
|---------------|-----------|-------|-------------|
| GameScene | BGM | Chiptune | Upbeat square wave melody + bass + drums |
| GameOverScene | BGM | Somber | Slow descending melody |
| Player action | SFX | Retro | Quick pitch sweep |
| Score | SFX | Retro | Two-tone ding |
| Death | SFX | Retro | Descending crushed notes |

Explain in plain English: "Background music will automatically loop during each scene. Sound effects will play when you do things like jump, score, or die. The first time you click/tap, the audio system will activate (browsers require a user interaction before playing sound)."

### Step 3: Implement

1. Create `src/audio/AudioManager.js` — AudioContext init, master gain node, BGM sequencer play/stop
2. Create `src/audio/AudioBridge.js` — wires EventBus events to AudioManager for BGM, calls SFX functions directly
3. Create `src/audio/music.js` with BGM patterns for each scene (Web Audio step sequencer — note arrays that loop continuously)
4. Create `src/audio/sfx.js` with SFX for each event (Web Audio API — OscillatorNode + GainNode + BiquadFilterNode for true one-shot playback)
5. Add audio events to `EventBus.js` if not present (`AUDIO_INIT`, `MUSIC_GAMEPLAY`, `MUSIC_GAMEOVER`, `MUSIC_STOP`, `AUDIO_TOGGLE_MUTE`)
6. Wire `initAudioBridge()` in `main.js`
7. Emit `AUDIO_INIT` on first user interaction (game starts immediately, no menu)
8. Emit music events at scene transitions and SFX events at game actions
9. Add mute toggle — `AUDIO_TOGGLE_MUTE` event, UI button, M key shortcut

### Step 4: Verify

- Run `npm run build` to confirm no errors
- List all files created/modified
- Remind the user: "Click/tap once to activate audio, then you'll hear the music"

## Example Usage

### Full audio pass
```
/add-audio examples/flappy-bird
```
Result: Creates `src/audio/AudioManager.js`, `music.js` (gameplay + game-over BGM patterns), `sfx.js` (flap, score, death, button SFX) → wires via AudioBridge → mute toggle on M key. First click activates audio.

## Troubleshooting

### No sound plays
**Cause:** AudioContext not resumed after user interaction (browser autoplay policy).
**Fix:** Ensure AudioContext.resume() is called on first user input (click/tap/keydown). Check for AUDIO_INIT event wiring.

### Audio causes lag spikes
**Cause:** Creating new OscillatorNodes every frame.
**Fix:** SFX should be one-shot (create, connect, start, stop). BGM uses a single looping sequencer. Never create nodes in update().

## Next Step

Tell the user:

> Your game now has music and sound effects! Next, run `/game-creator:qa-game` to add automated tests that verify your game boots correctly, scenes transition properly, scoring works, and visuals haven't broken.
>
> **Pipeline progress:** ~~/viral-game~~ → ~~/design-game~~ → ~~/add-audio~~ → `/qa-game` → `/review-game`
>
> *(This is the `/viral-game` one-shot pipeline — not the `/make-game` multi-session, milestone-driven workflow.)*

© OpusGameLabs · MIT · PlayableIntelligence/game-creator

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set28

game-qa A skill that turns the agent into a QA engineer for browser games: visual regression, gameplay checks, performance and accessibility via Playwright. Useful when writing or debugging game tests. CX Codex +1 1,100installs improve-game Audits your game across thirteen areas, finds weak spots, and implements fixes ranked by player impact. Run it as many times as you need. CX Codex +1 1,100installs game-3d-assets Finds, generates, and integrates GLB/GLTF models into Three.js browser games to replace primitive cubes and spheres. CX Codex +1 1,100installs threejs-game Locks in a project layout and four core modules for building 3D browser games with Three.js. Useful when the agent scaffolds a scene and game loop from scratch. CX Codex +1 1,100installs add-assets Swaps the circles and rectangles in a 2D game for pixel art sprites of characters, enemies and items. Useful once the prototype plays fine but looks like a wireframe. CX Codex +1 997installs add-feature Adds gameplay mechanics to Three.js or Phaser browser games. It helps implement power-ups, combo systems, or double jumps while keeping the core architecture intact. CX Codex +1 977installs review-game Audits an existing game project for architecture, performance, code quality and monetization readiness. Read-only, no edits. CX Codex +1 954installs add-3d-assets Swaps primitives like BoxGeometry for actual GLB models: animated characters, houses, trees, barrels. Useful when your Three.js game still looks like a pile of boxes. CX Codex +1 938installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor