nostr-replaceable-event-mutation-overwrite

nostr-replaceable-event-mutation-overwrite is a skill for Claude Code, Codex from divinevideo/divine-mobile. It costs 172 tokens per session (1,829 once invoked), scanned A, original, MPL-2.0.

A guide to safely updating Nostr replaceable events, which store one current version of data such as a profile or follow list. It prevents a new update based on incomplete data from replacing and deleting the existing information.

In plain words
What is it for?
Use it when implementing or debugging Nostr profile, follow-list, or relay-list mutations. It helps ensure updates fetch current state before publishing a replacement event.
Why use it?
It removes silent data loss when an app updates a profile, contact list, or relay list before it has loaded the latest version. This is especially relevant on a fresh browser session or mobile login.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code; installed under .agents/ (shared by several agents).

Good fit Use it when implementing or debugging Nostr profile, follow-list, or relay-list mutations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/divinevideo/divine-mobile/nostr-replaceable-event-mutation-overwrite
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add divinevideo/divine-mobile --skill nostr-replaceable-event-mutation-overwrite
Clone the repo
git clone --depth 1 https://github.com/divinevideo/divine-mobile

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nostr-replaceable-event-mutation-overwrite

README.md
[![agentmods](https://agentmods.dev/badge/skills/divinevideo/divine-mobile/nostr-replaceable-event-mutation-overwrite.svg)](https://agentmods.dev/skills/divinevideo/divine-mobile/nostr-replaceable-event-mutation-overwrite)
Your own site
<a href="https://agentmods.dev/skills/divinevideo/divine-mobile/nostr-replaceable-event-mutation-overwrite"><img src="https://agentmods.dev/badge/skills/divinevideo/divine-mobile/nostr-replaceable-event-mutation-overwrite.svg" alt="Measured on agentmods" height="20"></a>
Per session 172 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,829 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00172 $0.01829
Opus 5 $0.00086 $0.00915
Sonnet 5 $0.00034 $0.00366
Haiku 4.5 $0.00017 $0.00183

Measured yesterday against content hash 3952636a02a8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

nostr-replaceable-event-mutation-overwrite scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/nostr-replaceable-event-mutation-overwrite/SKILL.md · 183 lines

How it starts

The opening of the file, as written. The whole thing — 183 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Nostr Replaceable Event Mutation Overwrite

Problem

Nostr replaceable events (Kind 0, 3, 10002, etc.) use a full-replace model: publishing a new event completely replaces the previous one. If a client publishes a mutation based on stale, incomplete, or null cached state, it silently overwrites the canonical version on relays, causing data loss. The most common case is follow list (Kind 3) wipes when a user follows someone before the client has loaded their existing contact list.

Context / Trigger Conditions

  • User reports "I followed someone and lost all my other follows"
  • Follow/unfollow action on a fresh browser session or mobile login
  • Profile update loses existing metadata fields
  • Relay list update drops existing relays
  • Any mutation on a replaceable event where the UI passes cached state to the mutation function
  • React Query / TanStack Query data is undefined when mutation fires (query still loading)
  • The mutation function accepts the current event as a parameter from the UI layer

Solution

1. Always Fetch Fresh State Inside the Mutation

Never rely solely on the UI's cached/query state. Fetch the latest version of the replaceable event directly from the relay inside the mutation function, before publishing:

// BAD: Relies on UI cache which may be null/stale
mutationFn: async ({ targetPubkey, currentContactList }) => {
  const currentTags = currentContactList?.tags || []; // null -> [] -> data loss!
  // ... publish with only the new follow
}

// GOOD: Fetches fresh from relay before mutating
mutationFn: async ({ targetPubkey, currentContactList }) => {
  let bestContactList = currentContactList;

  try {
    const relayEvents = await nostr.query([
      { kinds: [3], authors: [userPubkey], limit: 1 },
    ], { signal: AbortSignal.timeout(5000) });

    const relayContactList = relayEvents
      .sort((a, b) => b.created_at - a.created_at)[0] || null;

    if (relayContactList) {
      // NIP-01 already fixes which copy of a replaceable event wins:
      // the higher created_at, and on an exact tie the lower event id.
      // Never compare tag counts — a shorter list is what a legitimate
      // unfollow produces.
      const passed = currentContactList;
      const isNewer =
        !passed ||
        relayContactList.created_at > passed.created_at ||
        (relayContactList.created_at === passed.created_at &&
          relayContactList.id < passed.id);
      if (isNewer) {
        bestContactList = relayContactList;
      }
    }
  } catch {
    // The read failed. It cannot be told apart from "the relay holds
    // nothing", so refuse to publish rather than replacing from a guess.
    throw new Error('Could not confirm the current list. Please try again.');
  }

  if (!bestContactList) {
    throw new Error('Could not load existing data. Please try again.');
  }

  // Now mutate bestContactList...
}

Read the full file on GitHub · 183 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +29 lines 3952636a02a8
  2. 3d ago First seen · 154 lines · 172 tokens per session scan A c6c0997b54c2

Subscribe to this mod's changes

nostr-replaceable-event-mutation-overwrite is a skill published in the GitHub repository divinevideo/divine-mobile (265 stars, last pushed today), licensed MPL-2.0. It adds 172 tokens to every session and 1,829 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

code-changes

Orchestration workflow for any task that ends in code changes: issue analysis, pull request review, feature implementation, bug fixes, refactors, or fleshing out an idea. MUST be invoked at the start of such a task, before reading or writing any code. Defines how to analyze first, gate on user approval, plan, pick the…

JanDeDobbeleer/oh-my-posh · 88 tokens

alchemy-cli

Use the Alchemy CLI (@alchemy/cli) for live blockchain data, transaction lookups, NFT/token/portfolio queries, simulation, tracing/debugging, contract reads/writes, wallet-signed sends, swaps and cross-chain bridges, Solana RPC/DAS plus wallet sends, webhook management, and Alchemy app administration. Preferred…

alchemyplatform/skills · 166 tokens

skmtc-debug

Diagnose failures in SKMTC sessions — no output, wrong output, error messages, bundle freshness, parseIssues, "Registered definition mismatch", ref cycles, "Module not found" in generated code, or any other broken behavior. Applies across both CLI usage and generator authoring contexts. Use this skill when the user…

skmtc/skmtc · 213 tokens

finish-it

Scope-cutting and shipping discipline from Derek Yu's 'Finishing a Game' and 'Death Loops', jam culture, and veteran shipping practice — diagnose why a game project stalled, cut to a shippable core, define a binary finish line, ship it. Use when: a game project is stalled or sprawling, 'I keep adding features', 'it's…

kyh/vibedgames · 115 tokens

cross-environment-semantic-drift

L1 trigger - audits L1/L2 boundary bugs, precompile context assumptions, integer width mismatches at environment boundaries, and EVM-on-non-EVM drift.

PlamenTSV/plamen · 43 tokens

genvm-lint

Validate GenLayer intelligent contracts with the GenVM linter.

internet-court/internet-court-skill · 17 tokens