Skip to main content

Cognitive Patterns

Cognitive patterns are the core of mycontext-ai. Each one implements a real cognitive or analytical methodology — not a generic template — grounded in research from cognitive science, decision theory, systems thinking, and organizational behavior.

Every pattern provides:

  • build_context(**inputs) → a fully assembled Context ready to execute
  • execute(provider, **inputs) → build + execute in one call
  • generic_prompt(**inputs) → a zero-cost, pre-authored prompt string (~600–1200 chars)

Why Patterns?

Without patterns, every developer writes ad-hoc prompts from scratch — reinventing the wheel every time. A prompt for root cause analysis has decades of methodology behind it (Five Whys, Ishikawa diagrams, contributing factor analysis). A prompt for scenario planning has its own framework (critical uncertainties, 2×2 matrix, signposts). Writing these correctly from scratch takes hours.

Patterns encode that methodology once. You bring the problem.

from mycontext.templates.free.reasoning import RootCauseAnalyzer

# Five Whys + Ishikawa + contributing factors + prevention — encoded
ctx = RootCauseAnalyzer().build_context(
problem="API response times tripled after last deployment",
depth="comprehensive",
)
result = ctx.execute(provider="openai")

All 87 Patterns at a Glance

Free Patterns (16) — Included in Every Install

PatternCategoryWhat it doesKey inputs
RootCauseAnalyzerReasoningFive Whys + Ishikawa systematic diagnosisproblem, depth
StepByStepReasonerReasoningChain-of-thought with transparent stepsproblem, domain
HypothesisGeneratorReasoningTestable hypotheses with experimental designobservation, domain
DataAnalyzerAnalysisPattern detection + actionable insightsdata_description, goal
QuestionAnalyzerAnalysisDecompose questions before answeringquestion, depth
BrainstormerCreativeDivergent ideation + convergent selectiontopic, goal, constraints
CodeReviewerSpecializedSecurity, performance, maintainability reviewcode, language, focus_areas
RiskAssessorSpecialized5-category risk scoring + mitigationdecision, depth
ScenarioPlannerPlanning4-scenario 2×2 matrix + signpoststopic, timeframe
StakeholderMapperPlanningPower-interest matrix + engagement planproject
AudienceAdapterCommunicationReframe content for a different audiencemessage, current_audience, target_audience
TechnicalTranslatorCommunicationJargon → plain language with translation maptechnical_text, target_audience
SocraticQuestionerSpecialized6-category probing questions on a statementstatement, depth
SynthesisBuilderSpecializedIntegrate multiple sources into one narrativesources, goal
ConflictResolverSpecializedMediate disputes, find win-win resolutionsconflict, parties
IntentRecognizerSpecializedUncover true intent behind a requestinput, depth

Enterprise Patterns (71) — Requires License

Advanced patterns organized by category. Each requires a valid license key. Learn more →

CategoryPatternsHighlights
Specialized Intelligence2RagAnswerer (+15% evidence recall, citations, abstention), MemoryCompressor (2x recall over summarization at scale)
Advanced Analysis4TrendIdentifier, GapAnalyzer, SWOTAnalyzer, AnomalyDetector
Advanced Reasoning2CausalReasoner, AnalogicalReasoner
Advanced Creative4IdeaGenerator, InnovationFramework, DesignThinker, MetaphorGenerator
Advanced Communication5SimplificationEngine, PersuasionFramework, NarrativeBuilder, FeedbackComposer, ClarityOptimizer
Advanced Planning3ResourceAllocator, PrioritySetter, DeadlineManager
Advanced Specialized5ContentOutliner, AmbiguityResolver, RiskMitigator, ImpactAssessor, ConceptExplainer
Decision5DecisionFramework, ComparativeAnalyzer, TradeoffAnalyzer, MultiObjectiveOptimizer, CostBenefitAnalyzer
Problem Solving6ProblemDecomposer, BottleneckIdentifier, ConstraintOptimizer, DependencyMapper, EfficiencyAnalyzer, TradeSpaceExplorer
Temporal Reasoning3TemporalSequenceAnalyzer, FutureScenarioPlanner, HistoricalContextMapper
Diagnostic3DiagnosticRootCauseAnalyzer, DifferentialDiagnoser, SystemHealthAuditor
Synthesis3HolisticIntegrator, PatternRecognitionEngine, CrossDomainSynthesizer
Systems Thinking6FeedbackLoopIdentifier, LeveragePointFinder, EmergenceDetector, SystemArchetypeAnalyzer, CausalLoopDiagrammer, StockFlowAnalyzer
Metacognition5MetacognitiveMonitor, SelfRegulationFramework, CognitiveStrategySelector, LearningFromExperience, ErrorDetectionFramework
Ethical Reasoning5EthicalFrameworkAnalyzer, MoralDilemmaResolver, StakeholderEthicsAssessor, ValueConflictNavigator, ConsequentialistAnalyzer
Learning5ScaffoldingFramework, SpacedRepetitionOptimizer, ZoneOfProximalDevelopment, CognitiveLoadManager, ConceptualChangeAnalyzer
Evaluation5RubricDesigner, FormativeAssessmentFramework, SummativeEvaluator, PeerAssessmentStructure, SelfAssessmentGuide

Two Execution Modes

Every pattern supports two modes. Choose based on your cost/quality needs:

Mode 1: Full Context (Rich, Structured)

Uses the complete directive template — structured sections, numbered steps, output format instructions. Produces the richest, most thorough responses.

from mycontext.templates.free.reasoning import RootCauseAnalyzer

# Build full context
ctx = RootCauseAnalyzer().build_context(
problem="Server crashes during peak hours",
depth="comprehensive",
)
result = ctx.execute(provider="openai")

Mode 2: Generic Prompt (Zero-cost compilation)

Uses the hand-crafted GENERIC_PROMPT (~600–1200 chars). No context assembly, no extra LLM calls — just string substitution and a single execute call. Validated at ~95% of full mode quality.

from mycontext.templates.free.reasoning import RootCauseAnalyzer

rca = RootCauseAnalyzer()

# Zero-cost: just string substitution
prompt = rca.generic_prompt(problem="Server crashes during peak hours")

# Or execute directly in generic mode (1 LLM call total)
result = rca.execute(
provider="openai",
mode="generic",
problem="Server crashes during peak hours",
)

Chaining Patterns

Complex questions often need multiple reasoning steps. Chain patterns so each stage feeds the next:

from mycontext.templates.free.reasoning import RootCauseAnalyzer, HypothesisGenerator
from mycontext.templates.free.planning import ScenarioPlanner

# Stage 1: Root cause analysis
ctx1 = RootCauseAnalyzer().build_context(
problem="Churn increased 40% this quarter",
depth="thorough",
)
rca_result = ctx1.execute(provider="openai")

# Stage 2: Generate hypotheses based on root causes
ctx2 = HypothesisGenerator().build_context(
observation=rca_result.response[:2000],
domain="SaaS customer retention",
)
hyp_result = ctx2.execute(provider="openai")

# Stage 3: Plan scenarios for each hypothesis
ctx3 = ScenarioPlanner().build_context(
topic="Customer retention recovery strategies",
timeframe="6 months",
)
result = ctx3.execute(provider="openai")

Automatic Pattern Selection

Don't know which pattern fits? Let the intelligence layer choose:

from mycontext.intelligence import suggest_patterns, smart_execute

# Get recommendations
result = suggest_patterns(
"Why did our churn spike? What should we do about it?",
mode="hybrid",
llm_provider="openai",
)
print(result.suggested_chain)
# → ['root_cause_analyzer', 'scenario_planner']

# Or just execute — auto-selects and runs
response, meta = smart_execute(
"Why did our churn spike? What should we do about it?",
provider="openai",
)
print(meta["templates_used"])

The Research Foundation

Every pattern is backed by peer-reviewed research. Some examples:

PatternMethodologyResearch basis
RootCauseAnalyzerFive Whys, IshikawaQuality management, systems thinking
StepByStepReasonerChain-of-ThoughtWei et al. (2023), IBM Zurich (2025)
HypothesisGeneratorScientific methodExperimental design research
SocraticQuestionerSocratic methodClassical dialogue methodology
ScenarioPlannerScenario planningShell's scenario methodology, GBN
StakeholderMapperStakeholder theoryFreeman's stakeholder framework

The full citation list (150+ papers) is in the Research Foundations document.


Browse the free patterns: