Count Combinations
For probability and counting: permutations, combinations, sample spaces, Monte Carlo simulation, brute-force enumeration, card/dice problems.
Fallback Compatibility
For cross-version support: try/except imports, optional dependencies, graceful degradation across Python versions.
Use Comprehension Chain
For data transformation: list/dict/set comprehensions, chained filtering and mapping, creating lookup structures concisely.
Propagate Then Search
For constraint problems: eliminate impossibilities before guessing, reduce search space through inference, fail fast on contradictions.
Refactor Decompose Function
For long functions: break into smaller pieces, extract helper functions, reduce nesting, improve testability and readability.
Build Priority Queue
For ordered processing: A* search, Dijkstra, event simulation, task scheduling. Efficient min/max extraction with heap-based queue.
Display Grid State
For 2D debugging: visualize grid/board state, show puzzle progress, make algorithm behavior visible.
Match Stable Pairs
For two-sided matching: hospital-resident, stable marriage, college admissions. Gale-Shapley algorithm for stable matching with preferences.
Use Defaultdict Groups
For grouping and auto-initialization: adjacency lists, grouping by key, multi-maps, nested structures without KeyError handling.
Test With Examples
For example-driven development: test cases as specifications, input/output pairs, documentation through examples.
Use Counter Frequency
For counting and frequency: histograms, most common elements, vote tallying, neighbor counting, word frequencies, distribution analysis.
Cascade Type Conversion
For flexible parsing: try multiple type conversions in order, graceful fallback from specific to general types.
Dispatch On Structure
For heterogeneous data: pattern matching on type/structure, interpreter eval loops, handling different expression types.
Compose Small Helpers
For complex behavior: build from tiny functions, chain transformations, make code read like a pipeline of operations.
Benchmark Before Optimize
For performance work: measure before changing, profile to find bottlenecks, compare before and after.
Define Domain Types
For new modules: define type aliases as vocabulary, make code self-documenting, create domain-specific language feel.
Adversarial Patterns
Library of realistic adversarial attack vectors and anti-patterns to avoid. Contains examples of valid attacks and subtle gaming patterns to reject.
Iterate With Itertools
For combinatorial iteration: permutations, combinations, cartesian products, without storing all results in memory.
Handle Edge Cases
For boundary conditions: empty collections, zero values, recursive base cases, null checks, prevent crashes at edges.
Solve Grid Maze
For 2D grid problems: mazes, board games, tile maps, pixel grids, coordinate systems, cellular automata, flood fill. Uses dict-based Grid class pattern.
Generate Tree Structure
For tree/maze generation: spanning trees, random mazes, graph coverage. Uses frontier-based exploration with configurable traversal order.
Show Side By Side
For comparison: display before/after, multiple solutions, diffs side by side for visual comparison.
Find Convex Hull
For computational geometry: convex hull, point enclosure, polygon operations. Uses monotone chain algorithm with stack-based turn detection.
Precompute Relationships
For static relationships: graph structure, grid neighbors, constraint peers. Calculate once at module load, reference throughout program.
Return None For Failure
For graceful failure: return None or False instead of exceptions, let caller decide how to handle failure.
Error Ux
Principles and patterns for writing error messages that help users recover. Use when auditing, writing, or improving error messages in code. Triggers: error messages, user experience, error handling, exception messages, validation errors.
Time And Report
For performance reporting: timing wrappers, throughput calculations, profiling summaries.
Find Shortest Path
For pathfinding and search: shortest path, maze solving, game AI, route planning, graph traversal, BFS/DFS, Dijkstra, A* problems.
Catch Expected Errors
For iteration with errors: catch exceptions during exploration, skip invalid cases, continue to next attempt.
Optimize Local Search
For NP-hard optimization: TSP, scheduling, assignment problems. Uses greedy construction + local improvement (2-opt, hill climbing).
Tokenize Then Parse
For interpreters: separate lexing from parsing, token stream to AST, structured text processing in stages.
Apply Decorator Wrap
For cross-cutting concerns: add behavior without modifying functions, caching, timing, logging, validation wrappers.
Documentation Testing
Provides heuristics for identifying incomplete or broken documentation. Use when validating README setup instructions, testing onboarding flows, or auditing documentation quality. Triggers: docs, readme, onboarding, setup validation, documentation audit.
Test Structural Invariants
For data structure validation: test lengths, relationships, constraints that must hold, verify setup is correct.
Parse Extract Input
For text processing: extract numbers, words, structured data from messy text using regex patterns, parsing utilities.
Intern Symbols Identity
For fast comparison: ensure only one instance of each symbol, use 'is' instead of '==', symbol tables for interpreters.
Adversarial Analysis
Analyze code to identify explicit contracts, implicit usage patterns, and realistic boundary conditions. Contains concrete formulas for calculating input realism limits. Use before generating adversarial tests.
Compile Once Call Many
For hot loop optimization: repeated formula evaluation, regex patterns, expression compilation. Transform string to callable once, call many times.
Format Statistics Table
For result reporting: tabular output, aligned columns, statistics summaries, human-readable reports.
Overload Operators Dsl
For domain-specific languages: operator overloading, make Python look like math/domain notation, expression builders.
Cache Recursive Calls
For dynamic programming: overlapping subproblems, recursive solutions with repeated computations, memoization to avoid redundant work.
Use Class For State
For complex state: encapsulate multiple interacting variables, stateful algorithms, backtracking search state.
Pass Function As Arg
For generic algorithms: strategy pattern, callbacks, configurable behavior. Pass functions as parameters to customize algorithm behavior.
Deep Research
Conducts iterative deep research on any topic using web search, progressive exploration, and structured synthesis. Use when asked for comprehensive research, deep investigation, thorough analysis, or multi-source exploration of any topic. Triggers: research, investigate, deep dive, comprehensive analysis, explore thoroughly, find everything about.
Frontier Based Explore
For graph exploration: frontier collection with configurable pop order, BFS/DFS/random via strategy change.
Stack Based Backtrack
For search with undo: explicit decision stack, backtracking when paths fail, depth-first exploration with state restoration.
Solve Constraint Puzzle
For constraint satisfaction: Sudoku, scheduling, N-queens, logic puzzles, SAT-like problems, assignment problems. Uses propagate-then-search pattern.
Local Llm
Manage local Ollama LLM models for development and testing. Use when: running local models, configuring Ollama, switching between fast/quality models, optimizing VRAM usage, troubleshooting model performance, creating Modelfiles, or integrating local LLMs with applications via OpenAI-compatible API. Triggers: ollama, local model, local LLM, VRAM, GPU memory, model speed, inference, Modelfile, lla…
Build Expression Tree
For symbolic computation: ASTs, mathematical expressions, code that manipulates code structure, expression transformations.
Capture State Closure
For persistent state: closures capture outer variables, alternative to classes for simple state, factory functions that remember context.