Skip to content

Instantly share code, notes, and snippets.

@samkeen
samkeen / rust-directives.md
Created July 5, 2026 18:54
Simple Rust directives for and agents file

Rust data modeling

  • Ownership forms a tree/DAG, never a cycle. One clear owner per value.
  • For references between values (or any logical cycle): use slotmap keys, or Vec indices only if nothing is ever removed. Do NOT default to Rc<RefCell<T>>; treat Rc / Arc<Mutex<T>> as last resorts after trying ownership + keys.
  • Prefer owned fields over borrowed (&'a T) fields. If a struct sprouts a lifetime parameter, reconsider — it usually wants owned data or a key. Legitimate exception: a short-lived, Copy, read-only view struct passed into one call and never stored (e.g. NoteRow in db.rs) — borrowing there avoids a needless clone; keep it, and say so in the doc-comment.
  • Never silence the borrow checker with a reflexive .clone(). Diagnose ownership first: should this be a key instead of a reference?
  • No self-referential structs in safe Rust; restructure with indices.
  • No .unwrap() / .expect() in production paths; handle via match, if let, or ?. This holds even for an invaria
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>B2 — System Architecture</title>
<style>
:root{
--bg:#0d1117; --panel:#161b22; --panel2:#1c2330; --ink:#e6edf3; --muted:#9aa7b4;
--line:#2a3340; --accent:#58a6ff; --green:#3fb950; --amber:#d29922; --purple:#bc8cff;
@samkeen
samkeen / InstructionsLoaded.hook.json
Created May 3, 2026 22:35
example hook implementation to see when CLAUDE.md files are loaded
{
"hooks": {
"InstructionsLoaded": [
{
"hooks": [
{
"type": "command",
"command": "jq -r '({\"User\":\"👤\",\"Project\":\"📁\",\"Local\":\"📍\",\"Plugin\":\"🔌\"}[.memory_type] // \"📄\") as $e | \"\\($e) \\(.memory_type) \\(.file_path) \\(.load_reason)\"' >> instructions-loaded.log"
}
]
@samkeen
samkeen / claude-code-rss-reader-one-shot.txt
Created April 10, 2026 17:54
The session output of Claude Code (Opus 4.6) one shot'ing a Tauri 2 RSS feed reader
╭─── Claude Code v2.1.100 ─────────────────────────────────────────────────────╮
│ │ Tips for getting │
│ Welcome back Sam! │ started │
│ │ Run /init to create a … │
│ ▐▛███▜▌ │ ─────────────────────── │
│ ▝▜█████▛▘ │ Recent activity │
│ ▘▘ ▝▝ │ No recent activity │
│ Opus 4.6 (1M context) · Claude Max · │ │
│ ~/Projects/rss-reader/src-tauri │ │
╰──────────────────────────────────────────────────────────────────────────────╯
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Code — /init session #2</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Syne:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Code — /init session</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Syne:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
❯ how does this app work
⏺ Bash(date '+%Y-%m-%d %H:%M:%S %z')
⎿  2026-03-07 19:43:19 -0800
⏺ Based on the CLAUDE.md and project structure, here's how Demo Kit works:
What It Is
A web platform for structured demo nights and project showcases. Think: hackathon demo day as a service.
❯ how does this app work
⏺ Bash(date '+%Y-%m-%d %H:%M:%S %z')
⎿  2026-03-07 19:39:07 -0800
⏺ Searched for 2 patterns, read 5 files (ctrl+o to expand)
⏺ Here's how Demo Kit works:
The Big Picture

PR Decomposition Agent Prompt

Agent Instructions

You are a senior staff engineer acting as a PR decomposition facilitator. You've been given a diff that is far too large to review meaningfully. Your job is to work with the PR creator through a structured interview to:

  1. Understand the core motivation — the single problem that triggered this work
  2. Identify what's essential vs. what got bundled in along the way
  3. Surface opportunities for simplification — places where the same intent could be achieved with less code, less complexity, or a more incremental approach
  4. Make a deliberate decision about every piece of intent — ship it, spec it, track it, simplify it, or drop it
@samkeen
samkeen / claude-ralph-test.txt
Last active January 21, 2026 19:06
Test using the Ralph Claude Code Plugin for a feature request
* ▐▛███▜▌ * Claude Code v2.0.76
* ▝▜█████▛▘ * Opus 4.5 · Claude Max
* ▘▘ ▝▝ * ~/Projects/revenue-experiments/expenses-sbucks
> use your ralph task setup skill to gather requirements for gh issue 4
⎿  ⧉ Selected 1 lines from README.md in Visual Studio Code
⏺ Bash(gh issue view 4)
⎿  title: Add receipt upload UI