Agent skill

Socket Event Listener

by r0adkll in r0adkll/Campfire

Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events.

GPL-3.0Auto-check passedMobile

Install Socket Event Listener

skills CLI
$ npx skills add r0adkll/Campfire --skill socket-event-listener -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install r0adkll/Campfire socket-event-listener --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/r0adkll/Campfire.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/socket-event-listener .claude/skills/socket-event-listener && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
socket-event-listener
GitHub stars
140
Token cost
~2.5k tokens
SKILL.md length
858 words
Files
1
Skills in repo
9
Repo updated
First seen
Licence
GPL-3.0

At a glance

Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events.

  • Works in 5 steps: Annotate with… → Inject only domain dependencies (the… → Narrow via when or early-return if !is.… → …
  • Reviewing a class that reacts to socket events
  • SKILL.md covers Rule, Why, Where the listener lives and Implementation rules, plus 5 more sections
  • Calls rg

What it does

Socket Event Listener is an agent skill from r0adkll/Campfire. Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events. Feature impl modules contribute a SocketEventListener via @ContributesIntoSet(UserScope::class, binding = binding<SocketEventListener()) — no Scoped, no CoroutineScopeHolder injection, no flow collection, no edits to :infra:socket:impl. Trigger when authoring or reviewing a class that reacts to socket events, or when asked to "wire X to socket events" / "add a socket listener for Y".

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile. It works with React. The repository describes itself as: A KMP Compose app for Audiobookshelf. The licence is GPL-3.0.

When your agent uses it

  • Reviewing a class that reacts to socket events
  • Asked to wire X to socket events / add a socket listener for Y

Example prompts

  • “wire X to socket events”
  • “add a socket listener for Y”
  • “/socket-event-listener”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Annotate with @ContributesIntoSet(UserScope::class, binding = binding()) and @Inject. Without the annotation Metro won't register the…
  2. Inject only domain dependencies (the repos / stores / sync services you'll write to). Do NOT inject SocketManager, CoroutineScopeHolder…
  3. Narrow via when or early-return if !is. Every listener gets every event — that's intentional. Return Unit for events you don't care about…
  4. Keep handle() fast. It runs sequentially per listener — a 500ms handle delays the next event for that listener. For genuinely slow work…
  5. Don't catch exceptions just to swallow them. The dispatcher already wraps handle() in runCatching and logs failures with the listener…

What it can do on your machine

Read from SKILL.md and the folder at commit 2fde7e5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • rg

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Socket Event Listener loads about 2.5k tokens when it runs. Until then it costs about 128 tokens; SKILL.md has 858 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~128
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from r0adkll/Campfire at commit 2fde7e5, republished under its GPL-3.0 licence (© r0adkll). 858 words, ~2,490 tokens.

Download SKILL.mdSave it as .claude/skills/socket-event-listener/SKILL.md (or your agent's skills folder).
name
socket-event-listener
description
Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events. Feature impl modules contribute a `SocketEventListener` via `@ContributesIntoSet(UserScope::class, binding = binding<SocketEventListener>())` — no `Scoped`, no `CoroutineScopeHolder` injection, no flow collection, no edits to `:infra:socket:impl`. Trigger when authoring or reviewing a class that reacts to socket events, or when asked to "wire X to socket events" / "add a socket listener for Y".

Rule

Feature modules subscribe to socket events by contributing a SocketEventListener from their own impl module. The central dispatcher in :infra:socket:impl owns all collection, lifecycle, and error-handling — listeners are pure business logic.

kotlin
// :features:user:impl/.../MediaProgressSocketListener.kt
@ContributesIntoSet(UserScope::class, binding = binding<SocketEventListener>())
@Inject
class MediaProgressSocketListener(
  private val mediaProgressRepository: MediaProgressRepository,
) : SocketEventListener {
  override suspend fun handle(event: SocketEvent) {
    when (event) {
      is UserItemProgressUpdated -> mediaProgressRepository.upsert(event.payload.data)
      else -> Unit
    }
  }
}

That's the whole shape. No init blocks, no coroutine launching, no socketManager injection.

Why

  • Separation of concerns. Socket transport / reconnect / token-refresh / app-lifecycle plumbing lives in :infra:socket:impl. Feature reactions live with the feature they belong to.
  • Zero boilerplate per listener. Dispatcher injects Set<SocketEventListener> and launches one collector coroutine per listener at UserScope creation. New consumers ship in one file.
  • Error isolation. Dispatcher wraps every handle() in runCatching and logs failures — a single bad event can't permanently kill a listener.
  • Discoverability. All consumers are findable by grepping : SocketEventListener across the repo.

Where the listener lives

In the feature module that owns the domain it's updating. Examples:

Event(s)Owning module
UserItemProgressUpdated, UserSessionClosed:features:user:impl
ItemAdded, ItemUpdated, ItemRemoved, ItemsAdded, ItemsUpdated, LibraryAdded, LibraryUpdated, LibraryRemoved:features:libraries:impl
SeriesAdded/Updated/Removed:features:series:impl
CollectionAdded/Updated/Removed:features:collections:impl
AuthorAdded/Updated/Removed:features:author:impl
PlaylistAdded/Updated/Removed:features:playlists:impl
EpisodeAdded, EpisodeDownload*:features:podcasts:impl
UserUpdated:data:account:impl
NotificationsUpdatedwherever notification settings are managed

A feature that touches multiple event families is fine — one listener class can when-switch over several events. Don't make multiple listener classes just to fragment a when block.

Implementation rules

  1. Annotate with @ContributesIntoSet(UserScope::class, binding = binding<SocketEventListener>()) and @Inject. Without the annotation Metro won't register the binding and the dispatcher silently won't call it.
  2. Inject only domain dependencies (the repos / stores / sync services you'll write to). Do NOT inject SocketManager, CoroutineScopeHolder, or anything socket-related.
  3. Narrow via when or early-return if !is. Every listener gets every event — that's intentional. Return Unit for events you don't care about (or omit the else branch if your when is exhaustive over the events you handle).
  4. Keep handle() fast. It runs sequentially per listener — a 500ms handle delays the next event for that listener. For genuinely slow work, dispatch to a separate component or coroutine (rare in practice; repo upserts are sub-millisecond).
  5. Don't catch exceptions just to swallow them. The dispatcher already wraps handle() in runCatching and logs failures with the listener class name and event. If you have invariants that must hold, throw — you'll see it in logs.

When authoring a new event type (not a listener)

If you're adding a new SocketEvent (not consuming one), one rule travels with it:

If the payload extends app.campfire.network.models.NetworkModel or app.campfire.network.envelopes.Envelope, override applyOrigin(origin: RequestOrigin) and propagate to the payload. The dispatcher calls event.applyOrigin(RequestOrigin.Url(serverUrl)) immediately after decoding so downstream DB inserts (which inspect NetworkModel.origin for cover URLs, signed-stream headers, etc.) see the right server. The default on SocketEvent is a no-op, so forgetting silently loses metadata — DB rows end up with RequestOrigin.None and any code that builds absolute URLs from origin breaks.

kotlin
// ✅ Single object payload
data class LibraryUpdated(val library: Library) : SocketEvent {
  override fun applyOrigin(origin: RequestOrigin) = library.applyOrigin(origin)
  /* ... */
}

// ✅ List payload — fan out
data class ItemsUpdated(val items: List<LibraryItemExpanded>) : SocketEvent {
  override fun applyOrigin(origin: RequestOrigin) = items.forEach { it.applyOrigin(origin) }
  /* ... */
}

// ✅ Envelope wrapping a NetworkModel — reach through
data class UserItemProgressUpdated(val payload: UserItemProgressUpdatedPayload) : SocketEvent {
  override fun applyOrigin(origin: RequestOrigin) = payload.data.applyOrigin(origin)
  /* ... */
}

// ✅ Plain payloads (Series, User, PodcastEpisode, your own *Payload types) — no override needed.
data class SeriesAdded(val series: Series) : SocketEvent { /* ... */ }

Audit rule of thumb: if the payload field's type extends NetworkModel (directly or via Envelope), the event needs an applyOrigin override. Grep:

bash
rg -l ': NetworkModel\(\)|: Envelope\(\)' data/network/api --type kt

…and check that every event whose payload type appears in that list has the override.

Show full SKILL.md (438 more words)Show less

Anti-patterns

  • Adding the listener in :infra:socket:impl. Don't. Socket impl is generic plumbing only; the only listener that lives there is the universal SocketEventLogger.

    kotlin
    // ❌ DON'T: infra/socket/impl/.../MyFeatureListener.kt
  • Implementing Scoped and rolling your own collect. This was the pre-dispatcher pattern. With the dispatcher, it duplicates work and creates a second collector subscribed to the same SharedFlow.

    kotlin
    // ❌ DON'T
    @ContributesIntoSet(UserScope::class, binding = binding<Scoped>())
    class MyFeatureListener(
      private val socketManager: SocketManager,
      @ForScope(UserScope::class) private val scopeHolder: CoroutineScopeHolder,
      private val repo: MyRepo,
    ) : Scoped {
      override suspend fun onCreate() {
        scopeHolder.get().launch {
          socketManager.events.filterIsInstance<MyEvent>().collect { repo.upsert(it) }
        }
      }
    }
  • Injecting SocketManager directly. The point of the dispatcher is that listeners never see the socket — they get events handed to them. Injecting it means you're about to bypass the dispatcher.

  • One listener per event type. Five Removed events from the library family don't need five listener classes. One LibraryCacheInvalidator : SocketEventListener with a when block covering all of them is clearer and bundles related cache invalidation into one place.

    kotlin
    // ✅ Preferred — one listener, multi-event when
    override suspend fun handle(event: SocketEvent) {
      when (event) {
        is ItemAdded, is ItemUpdated, is ItemRemoved,
        is ItemsAdded, is ItemsUpdated -> libraryStore.invalidate()
        is LibraryAdded, is LibraryUpdated, is LibraryRemoved -> libraryListStore.invalidate()
        else -> Unit
      }
    }
  • Throwing as a signal. throw IgnoreEvent() to skip an event is wrong — just return/Unit. Throws go to the dispatcher's error log.

  • Mutating shared state without synchronization. Multiple listeners run in parallel coroutines. If two listeners write to the same in-memory cache, you need a Mutex or atomic primitives. Most repos / Stores already handle this internally — but if you're rolling your own, beware.

Concurrency model (so you don't get surprised)

  • One long-lived coroutine per listener, launched at UserScope creation, cancelled at logout.
  • Each listener has its own socketManager.events.collect. Events flow into all listeners concurrently.
  • Within a listener, handle() calls are sequential — event N must finish before event N+1 starts for that listener.
  • The underlying MutableSharedFlow has extraBufferCapacity = 64. If your listener falls behind by >64 events, tryEmit upstream starts returning false and events get dropped at the source for all listeners. In practice this never happens for socket events, but don't do anything in handle() that takes seconds.

When to apply

  • Authoring a class that reacts to ABS socket events → use this pattern.
  • User asks "wire <feature> to react to <event> updates" → drop a SocketEventListener impl in the feature's impl module.
  • Reviewing a PR that touches :infra:socket:impl to add feature-specific reactions → push back; that work belongs in the feature module.
  • Migrating an existing manual events.filterIsInstance<X>().collect { ... } subscriber (if any exist) → consolidate it into a SocketEventListener.

Auditing the codebase

bash
# Find all socket consumers
rg -l ': SocketEventListener' --type kt -g '!*/build/*'

# Find manual subscribers that should be migrated to the dispatcher
rg 'socketManager\.events' --type kt -g '!*/build/*' -g '!*/infra/socket/*'

The latter should return zero hits outside :infra:socket:impl (the dispatcher itself) and the test module. Any hit elsewhere is a pre-dispatcher subscriber that should be refactored to a SocketEventListener.

© r0adkll, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/socket-event-listener of r0adkll/Campfire.

Open the folder on GitHubat commit 2fde7e5

Compare with similar skills

Socket Event Listener next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Socket Event Listener compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Socket Event Listener this skillr0adkll/Campfire140—~2.5kAutomated safety check: PassGPL-3.0
Add Icon Mappinglobehub/lobe-icons2.6k—~1.5kAutomated safety check: WarnMIT
Add Featureecency/vision-mobile262—~1.9kAutomated safety check: PassMIT
ThemingCode-with-Beto/skills140—~2.5kAutomated safety check: PassNone
React Native Experttech-leads-club/agent-skills7k—~3.2kAutomated safety check: PassCC-BY-4.0
Frontend Optimistic Mutationssickn33/agentic-awesome-skills47k1 repos~3.6kAutomated safety check: PassMIT

Similar skills

  • Add Icon Mapping

    lobehub/lobe-icons

    Add or modify icon keyword mappings for providers, models, or agents in lobe-icons.

    2.6k GitHub stars~1.5k tokensUpdated 2 days ago
    MobileAuto-check: warnings
  • Add Feature

    ecency/vision-mobile

    A skill your agent uses when adding a new screen, route, or user-facing feature to the Ecency mobile React Native app, covering navigator registration, route params, i18n strings and styling.

    262 GitHub stars~1.9k tokensUpdated 4 days ago
    MobileAuto-check passed
  • Theming

    Code-with-Beto/skills

    Scaffold a unified, cross-platform color theme system into an Expo Router app.

    140 GitHub stars~2.5k tokensUpdated 2 mo ago
    MobileAuto-check passed
  • React Native Expert

    tech-leads-club/agent-skills

    Guides React Native and Expo work for cross-platform apps: Expo Router navigation, fast lists, Reanimated animation, platform-specific code and project structure.

    7k GitHub stars~3.2k tokensUpdated yesterday
    MobileAuto-check passed
  • Frontend Optimistic Mutations

    sickn33/agentic-awesome-skills

    A portable, framework-agnostic discipline for the write path of any React or React Native app using a query/cache layer.

    47k GitHub starsUsed in 1 repo~3.6k tokens
    MobileAuto-check passed
  • Frontend Architecture

    sickn33/agentic-awesome-skills

    A portable, framework-agnostic architecture style for any React or React Native frontend.

    47k GitHub starsUsed in 1 repo~5.6k tokens
    MobileAuto-check passed

More from r0adkll/Campfire

All 9 skills in this repo
  • PR Stack

    r0adkll/Campfire

    Open, describe, and maintain pull requests in Campfire, especially stacks of dependent PRs (each branch built on the one before).

    140 GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Compose Modifier

    r0adkll/Campfire

    Enforce the Compose guideline that every @Composable function must declare modifier: Modifier = Modifier as its first optional parameter and apply it to the root layout.

    140 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Fdroid Reproducible Foss

    r0adkll/Campfire

    Rules and reliable local tests for keeping Campfire's foss flavor F-Droid-compatible — a clean source scan (using scandelete, never scanignore) and a byte-for-byte reproducible build.

    140 GitHub stars~2.7k tokensUpdated today
    Auto-check passed
  • I18n Compose

    r0adkll/Campfire

    Extract hardcoded user-facing string literals from a Jetpack Compose / Compose Multiplatform file into the owning module's composeResources/values/<modulestrings.xml, then replace each call site…

    140 GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Iconbutton A11y

    r0adkll/Campfire

    Enforce the Campfire IconButton accessibility convention — every IconButton (and its derivatives) must be wrapped with IconButtonTooltip and given a localized action label.

    140 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Compose UI

    r0adkll/Campfire

    Campfire Compose UI conventions. An agent skill from r0adkll/Campfire.

    140 GitHub stars~886 tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Socket Event Listener

What does Socket Event Listener do?

Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events. Socket Event Listener is an agent skill from r0adkll/Campfire. Enforce the Campfire pattern for feature modules to react to Audiobookshelf socket events.

When should I use Socket Event Listener?

Socket Event Listener fits situations like: reviewing a class that reacts to socket events; asked to wire X to socket events / add a socket listener for Y.

How do I install Socket Event Listener in Claude Code?

Run `npx skills add r0adkll/Campfire --skill socket-event-listener -a claude-code`. Or copy the skill folder (.claude/skills/socket-event-listener in r0adkll/Campfire) into .claude/skills/socket-event-listener in your project. Claude Code loads it when a task matches its description.

How do I install Socket Event Listener in Codex?

Run `npx skills add r0adkll/Campfire --skill socket-event-listener -a codex`. Or copy the skill folder (.claude/skills/socket-event-listener in r0adkll/Campfire) into .agents/skills/socket-event-listener in your project. Codex loads it when a task matches its description.

Can I use Socket Event Listener in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add r0adkll/Campfire --skill socket-event-listener -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/socket-event-listener, .gemini/skills/socket-event-listener, .github/skills/socket-event-listener and .opencode/skills/socket-event-listener in your project.

What does Socket Event Listener need to run?

Going by SKILL.md and its folder, Socket Event Listener needs the command-line tools its instructions call (rg).

Does Socket Event Listener access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Socket Event Listener safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Socket Event Listener use?

Socket Event Listener is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Socket Event Listener use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Socket Event Listener?

Skills that share tags, products or a category with Socket Event Listener: Add Icon Mapping (lobehub/lobe-icons, 2.6k stars), Add Feature (ecency/vision-mobile, 262 stars), Theming (Code-with-Beto/skills, 140 stars) and React Native Expert (tech-leads-club/agent-skills, 7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Socket Event Listener?

r0adkll (a GitHub user) maintains it in r0adkll/Campfire, which has 140 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on October 9, 2026.

Source: r0adkll/Campfire on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.