Skip to content

Instantly share code, notes, and snippets.

View pfftdammitchris's full-sized avatar
💭
Dreaming

Christopher Tran pfftdammitchris

💭
Dreaming
View GitHub Profile
@pfftdammitchris
pfftdammitchris / snippet-21.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-21.ts
type Config = {
server: {
host: string
port: number
}
}
const config = {
server: {
host: 'localhost',
@pfftdammitchris
pfftdammitchris / snippet-22.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-22.ts
const config = {
server: {
host: 'localhost',
port: 3000,
},
} as const satisfies Config
config.server.host // Type: 'localhost' (literal preserved!)
@pfftdammitchris
pfftdammitchris / snippet-23.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-23.ts
// Before: Type annotation causes widening
const theme: Record<string, string> = {
primary: '#3b82f6',
secondary: '#10b981',
}
// Later in code, you might see type guards like this
if ('primary' in theme) {
// Unnecessary check
// ...
@pfftdammitchris
pfftdammitchris / snippet-24.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-24.ts
// After: satisfies preserves literal types
const theme = {
primary: '#3b82f6',
secondary: '#10b981',
} satisfies Record<string, string>
// No more unnecessary type guards!
theme.primary // TypeScript knows this exists
@pfftdammitchris
pfftdammitchris / snippet-25.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-25.ts
const theme = {
primary: '#3b82f6',
secondary: '#10b981',
} as const satisfies Record<string, string>
@pfftdammitchris
pfftdammitchris / snippet-26.ts
Created January 16, 2026 04:24
The Power of TypeScript's Satisfies Operator - snippet-26.ts
// Don't do this - unnecessary complexity
const name = 'John' satisfies string
// Just do this
const name: string = 'John'
// Or simply: const name = 'John'
@pfftdammitchris
pfftdammitchris / snippet-1.ts
Created January 15, 2026 16:46
15 Miraculous AI Agent Strategies for Code Generation in 2026 - snippet-1.ts
// eslint.config.js (flat config)
export default [
{
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.property.name="forEach"]',
message: 'Prefer lodash/forEach or for...of for complex iterations',
},
@pfftdammitchris
pfftdammitchris / snippet-2.md
Created January 15, 2026 16:46
15 Miraculous AI Agent Strategies for Code Generation in 2026 - snippet-2.md

CLAUDE.md

When starting any non-trivial task:

  1. State what you understand the task to be
  2. List what context is missing or unclear
  3. Declare assumptions you're making

Example output format: "I understand this as: [summary]. Missing context: [gaps]. Assuming: [assumptions]."

@pfftdammitchris
pfftdammitchris / snippet-3.md
Created January 15, 2026 16:46
15 Miraculous AI Agent Strategies for Code Generation in 2026 - snippet-3.md

CLAUDE.md

Always use context7 when:

  • Starting any coding task involving external libraries
  • Before generating code using library APIs
  • When debugging library-related issues

Workflow:

@pfftdammitchris
pfftdammitchris / snippet-4.md
Created January 15, 2026 16:46
15 Miraculous AI Agent Strategies for Code Generation in 2026 - snippet-4.md

CLAUDE.md - Clarification Protocol

When requirements are ambiguous, ask BEFORE coding:

  • "Add authentication" → OAuth? JWT? Session? Magic link?
  • "Make it performant" → What's baseline? Target latency?
  • "Handle errors" → User-facing? Logging only? Recovery?

Format: Present 2-3 options with trade-offs, let user choose.