hassanzohdy/atom/recipes

Claude Code and agent skill by hassanzohdy/atom

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Idiomatic composition recipes for `@mongez/atom` covering boolean toggles, cart totals, derived watch patterns, SSR hydration, DevTools teardown, and scratch atoms.

Install

npx vskill@latest install hassanzohdy/atom/recipes

SKILL.md

Recipes

Idiomatic compositions across @mongez/atom features.

A boolean toggle with verbs

ts
const sidebar = createAtom({
key: "ui.sidebar",
default: false,
actions: {
open() { this.update(true); },
close() { this.update(false); },
toggle() { this.update(!this.value); },
},
});
sidebar.toggle();

A cart with computed totals

ts
type Item = { id: string; price: number; qty: number };
const cart = atomCollection<Item>({
key: "cart",
actions: {
get total() {
return this.value.reduce((s, i) => s + i.price * i.qty, 0);
},
setQty(this: Atom<Item[]>, id: string, qty: number) {
this.update(this.value.map(i => i.id === id ? { ...i, qty } : i));
},
},
});
cart.push({ id: "a", price: 10, qty: 2 });
cart.push({ id: "b", price: 5, qty: 1 });
cart.total; // 25
cart.setQty("a", 3);
cart.total; // 35

Side effect via onChange

When you need a side effect on every change (writing to another atom, logging, hitting an API) rather than a pure derivation, subscribe via onChange. For pure computed values, prefer derive (see mongez-atom-derived).

ts
const inputAtom = createAtom({ key: "search.input", default: "" });
const querySlugAtom = createAtom({ key: "search.slug", default: "" });
inputAtom.onChange(next => {
querySlugAtom.update(next.toLowerCase().trim().replace(/\s+/g, "-"));
});

SSR snapshot + hydrate

ts
// Server
const store = createAtomStore();
store.use(userAtom).update({ name: "Alice" });
const html = renderToString(<App store={store} />);
const payload = JSON.stringify(store.snapshot());
res.send(/* html with payload embedded as <script> */);
store.destroy();
ts
// Client
const incoming = JSON.parse(document.getElementById("__atoms")!.textContent!);
const store = createAtomStore();
store.hydrate(incoming);
// Mount the React tree with this store via AtomStoreProvider.

Devtools in dev only

ts
let teardownDevtools: (() => void) | undefined;
if (process.env.NODE_ENV !== "production") {
teardownDevtools = enableAtomDevtools({
name: "MyApp",
ignore: [/^mouse\./, /^perf\./],
});
}
// HMR cleanup (Vite / Webpack)
if ((import.meta as any).hot) {
(import.meta as any).hot.dispose(() => teardownDevtools?.());
}

A throwaway scratch atom

If you need state but don't care about the key:

ts
const scratch = createAtom({
key: `scratch.${Math.random()}`,
default: { x: 0, y: 0 },
});
// Clean up before forgetting about it:
scratch.destroy();

For long-lived ad-hoc atoms, give them a deterministic key — the registry is shared per process.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hassanzohdy/atom/recipes/badge)](https://verified-skill.com/skills/hassanzohdy/atom/recipes)

Something wrong with this skill or its page? Tell us.