Skip to content

Instantly share code, notes, and snippets.

@ljw1004
ljw1004 / learning-hook.py
Created February 12, 2026 00:39
Claude reminder hook, that works within subagents and within agentic loops
#!/usr/bin/env python3
"""
PostToolUse hook: periodic LEARNINGS.md reminder.
On first invocation for an agent/subagent, outputs the full LEARNINGS.md
instructions. Thereafter, outputs a short reminder about every 10 assistant turns.
Does nothing if no LEARNINGS.md exists in the project root.
This works on a per-agent or per-subagent basis. This is tricky because
hooks don't tell us who they fired for. We work around this by looking for
You are COAGENT, an expert at prompt engineering. You will be told a conversation
between a USER who writes prompts, and an ASSISTANT who responds. Your job is
to critique the USER's prompt if necessary.
You will respond in exactly one of two ways (strict format):
1) Line 1 must be exactly: SKIP
- Lines 2+: one short sentence explaining why no advice is needed (≤ 30 words).
2) Line 1 must be exactly: USER
<system-reminder>
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
## Plan File Info:
No plan file exists yet. You should create your plan at /home/ljw/.claude/plans/jaunty-skipping-lighthouse.md using the Write tool.
You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
**Plan File Guidelines:** The plan file should contain only your final recommended approach, not all alternatives considered. Keep it comprehensive yet concise - detailed enough to execute effectively while avoiding unnecessary verbosity.
## Enhanced Planning Workflow
@ljw1004
ljw1004 / you_are_not_right.sh
Last active November 19, 2025 17:05
A UserPromptSubmit hook for Claude Code to stop it saying "You're right"
#!/bin/bash
set -euo pipefail
trap 'echo "at line $LINENO, exit code $? from $BASH_COMMAND" >&2; exit 1' ERR
# This is a Claude Code hook to stop it saying "you are right".
#
# Installation:
# 1. Save this script and chmod +x it to make it executable.
# 2. Within Claude Code, /hooks / UserPromptSubmit > Add a new hook (this file)
#
@ljw1004
ljw1004 / tuple_perf.cs
Created April 20, 2017 15:02
Perf comparison ValueTuple vs Tuple vs KeyValuePair
// TUPLE MICRO-BENCHMARKS, based on https://www.dotnetperls.com/tuple-keyvaluepair
//
// Tuples are generally fastest.
// ValueTuple is fastest in the particular case of GetHashCode.
// KeyValuePair is always worst.
//
//
// RAW RESULTS
// Numbers in milliseconds (lower is better)
//
@ljw1004
ljw1004 / ValueTask_GetNextByteAsync.cs
Created July 21, 2016 17:53
Simple example of async ValueTask
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
class Program
{
static void Main()
{