agentleFS
discord-phpdiscord-php/DiscordPHP/.agents/skills/voice-subsystem-keeper/SKILL.md

voice-subsystem-keeper

Skill1.1k starsChanged 35 days agoMITView on GitHub

Work with DiscordPHP's voice subsystem — voice gateway protocol opcodes, encryption (VoiceGroupCrypto), voice packets, audio streaming, and Discord.php voice integration. Use when touching Voice/*, joinVoiceChannel, or voice encryption/packet logic.

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 4 mentionsSep 2026: 13 mentionsOct 2026: 9 mentionsNov 2026: 1 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the discord-php/DiscordPHP repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about discord-php/DiscordPHP

The biggest 5 of 52 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 52

Talked about on GitHub and Bluesky (52 times).

On GitHub · 50

45 more on GitHub

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 4 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when work touches src/Discord/Voice/*, Discord::joinVoiceChannel(), voice event handlers in Discord.php, or anything …

    line 12
  2. Very specific:

    Rule: do not blur these boundaries.

    line 24
  3. Very specific:

    Do not replicate any of this in src/Discord/Voice/: If you need to add audio capability, contribute to the external package or wrap it.

    line 75
  4. Distinctive:

    When touching voice code, also inspect:

    line 85
  5. Very specific:

    Add the mode constant to SessionDescription.

    line 97
  6. Very specific:

    Update VoiceGroupCryptoInterface if the contract changes.

    line 100
  7. Very specific:

    Verify libsodium function availability — throw LibSodiumNotFoundException if missing.

    line 101
  8. Distinctive:

    Add tests for encrypt/decrypt round-trip.

    line 102
  9. Very specific:

    Create a typed value class under src/Discord/Voice/ mirroring the Discord voice gateway docs.

    line 106
  10. Distinctive:

    Document the opcode sequence in the class docblock.

    line 108
  11. Distinctive:

    Do not put audio I/O logic in the opcode class — keep it as a typed payload.

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: voice-subsystem-keeper

Use this skill when work touches src/Discord/Voice/*, Discord::joinVoiceChannel(), voice event handlers in Discord.php, or anything involving audio encryption and packets.

Architecture overview

Voice support is split across three locations. Understand the boundary before touching any of them:

LocationWhat lives here
src/Discord/Voice/*Internal protocol types: opcodes (Hello, Ready, Speaking), session description, voice packets, encryption classes and traits. These are pure data/crypto — no audio I/O.
src/Discord/Discord.phpRuntime integration: joinVoiceChannel(), voice state update handlers, voice server update handlers. This is where the external voice client is wired to gateway events.
discord-php-helpers/voice (external package)Manager and VoiceClient: actual audio I/O, Opus encoding, UDP transport, stream management. DiscordPHP delegates audio work here.

Rule: do not blur these boundaries. Protocol types belong in Voice/*, audio I/O belongs in the external package, and wiring belongs in Discord.php.

Read in this order

  1. src/Discord/Voice/VoiceGroupCrypto.php — encryption/decryption base class
  2. src/Discord/Voice/VoiceGroupCryptoTrait.php — mixin providing group-based AEAD crypto
  3. src/Discord/Voice/VoiceGroupCryptoInterface.php — contract
  4. src/Discord/Voice/VoicePacket.php — encrypted RTP packet encapsulation
  5. src/Discord/Voice/SessionDescription.php — session key and mode negotiation
  6. src/Discord/Voice/Speaking.php, src/Discord/Voice/Hello.php, src/Discord/Voice/Ready.php, src/Discord/Voice/Resumed.php — voice gateway opcodes
  7. src/Discord/Voice/Platform.php, src/Discord/Voice/Region.php — enum helpers
  8. src/Discord/Discord.php — search for joinVoiceChannel, VOICE_STATE_UPDATE, VOICE_SERVER_UPDATE
  9. src/Discord/Helpers/Buffer.php — writable stream for audio buffering (extends EventEmitter)

Core concepts

Voice gateway protocol

Discord voice uses a separate WebSocket gateway from the main gateway. The handshake sequence is:

  1. Hello — server sends heartbeat interval
  2. Identify — client sends token + session
  3. Ready — server sends UDP endpoint + SSRC
  4. Select Protocol — client sends chosen encryption mode
  5. Session Description — server sends secret key
  6. Speaking — sent before/after transmitting audio

The classes in src/Discord/Voice/ model these protocol steps as typed value objects.

Encryption

VoiceGroupCrypto provides AEAD encryption for RTP packets. It depends on libsodium (ext-sodium). The trait VoiceGroupCryptoTrait provides the implementation; concrete classes select the cipher mode (e.g., aead_xchacha20poly1305_ietf).

  • LibSodiumNotFoundException is thrown at runtime if the extension is absent — do not suppress it
  • Cipher mode is negotiated via SessionDescription

VoicePacket

VoicePacket encapsulates an encrypted RTP packet:

  • SSRC identifies the audio source
  • Sequence number and timestamp are required for RTP ordering
  • The packet is encrypted before transmission using the session secret key

Audio I/O (external package)

discord-php-helpers/voice owns all audio work:

  • Opus codec encoding/decoding
  • UDP socket management
  • OGG/Opus stream handling
  • FFmpeg process integration

Do not replicate any of this in src/Discord/Voice/. If you need to add audio capability, contribute to the external package or wrap it.

Old* files

OldVoiceClient.php, OldBuffer.php, OldOggStream.php, OldOggPage.php, OldOpusHead.php, OldOpusTags.php, OldReceiveStream.php are legacy implementations. They are preserved for compatibility only.

Do not extend, copy patterns from, or add new features to any Old* class. Fix bugs in them only when the fix is isolated and does not require architectural change.

Companion surfaces

When touching voice code, also inspect:

TouchingAlso inspect
VoiceGroupCrypto or crypto modeSessionDescription, VoicePacket, VoiceGroupCryptoInterface, LibSodiumNotFoundException
Speaking or voice gateway opcodeHello, Ready, Resumed, SessionDescription — full handshake chain
Discord.php voice handlersVoice gateway opcodes, Buffer, external voice package Manager
Buffer.phpMultipart.php (similar streaming pattern), external voice package stream classes
Any new voice encryption modeVoiceGroupCryptoInterface, crypto trait, SessionDescription mode list

Playbook: adding a new voice encryption mode

  1. Add the mode constant to SessionDescription.
  2. Implement the mode in a class using VoiceGroupCryptoTrait or extending VoiceGroupCrypto.
  3. Register the mode in the external voice package's cipher negotiation if needed.
  4. Update VoiceGroupCryptoInterface if the contract changes.
  5. Verify libsodium function availability — throw LibSodiumNotFoundException if missing.
  6. Add tests for encrypt/decrypt round-trip.

Playbook: adding a voice gateway opcode

  1. Create a typed value class under src/Discord/Voice/ mirroring the Discord voice gateway docs.
  2. Wire the opcode handler in Discord.php (find the voice WebSocket message handler).
  3. Document the opcode sequence in the class docblock.
  4. Do not put audio I/O logic in the opcode class — keep it as a typed payload.

Design tripwires

  • Adding audio codec, UDP, or FFmpeg logic inside src/Discord/Voice/ — that belongs in the external voice package
  • Extending any Old* class for new features
  • Skipping libsodium availability check before using sodium functions
  • Hard-coding a cipher mode instead of reading it from SessionDescription
  • Blocking I/O inside voice packet or stream handlers — everything must be async/Promise-based
  • Catching LibSodiumNotFoundException silently instead of surfacing it to the caller

Reference files

  • src/Discord/Voice/VoiceGroupCrypto.php — encryption base
  • src/Discord/Voice/VoicePacket.php — RTP packet wrapper
  • src/Discord/Voice/SessionDescription.php — session key/mode
  • src/Discord/Voice/Speaking.php — voice speaking opcode
  • src/Discord/Helpers/Buffer.php — writable stream helper
  • src/Discord/Exceptions/LibSodiumNotFoundException.php — crypto dependency guard
  • src/Discord/Exceptions/OpusNotFoundException.php — codec dependency guard
  • src/Discord/Exceptions/FFmpegNotFoundException.php — audio tool dependency guard

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.