Skip to content

Instantly share code, notes, and snippets.

View tangentlin's full-sized avatar

Tianzhen Lin (Tangent) tangentlin

View GitHub Profile
@tangentlin
tangentlin / llm-behavioral-rule-critical-thinking.md
Created April 30, 2026 19:56
LLM Behavioral Rules (Critical Thinking)

Behavioral Rules

Scrutinize first, build second — Before starting any task, pause and scrutinize the request. Identify ambiguities, unstated assumptions, edge cases, and blindspots. Assume as little as possible.

Ask in batches of 3 — Surface discovered ambiguities as questions in groups of up to 3. For each question, use whatever format fits best — multiple-choice options when the answer space is enumerable, open-ended when it isn't. Keep iterating in rounds of 3 until no ambiguity remains. Use this format:

Before I start, I want to make sure we're aligned:

  1. [Topic] — [Question]
    • A) [option] — [tradeoff]
function validateAndFormatCard(number: string, type: string) {
const cardType = creditCardTypes[type];
if (!cardType) {
throw new Error('Unsupported card type');
}
const isValid = cardType.validate(number);
const formattedNumber = cardType.format(number);
return {
isValid,
formattedNumber,
interface CreditCardType {
name: string;
logoUri: string;
validate: (number: string) => boolean;
format: (number: string) => string;
}
const creditCardTypes: Record<string, CreditCardType> = {
visa: {
name: "Visa",
@tangentlin
tangentlin / credit-card-processing-declarative.ts
Created March 31, 2024 01:24
A contrived declarative approach of declarative programming
interface PaymentMethod {
process(amount: number): void;
}
const paymentMethods: Record<string, PaymentMethod> = {
credit: {
process(amount: number) {
console.log(`Processing $${amount} via Credit Card`);
// Credit card processing logic...
}
@tangentlin
tangentlin / credit-card-processing-imperative.ts
Created March 31, 2024 01:20
Imperative programming example
function processPayment(amount: number, method: string) {
switch (method) {
case 'credit':
// Process credit card payment
break;
case 'paypal':
// Process PayPal payment
break;
case 'bank_transfer':
// Process bank transfer