Skip to main content
Engineering

How Context Engineering Works

Aqsa Inam · March 26, 2026 · 5 min read

Laptop screen displaying colorful code — software engineering

Tenkr responses feel different from a raw AI model — more specific, more project-aware, more opinionated about methodology. That is not a different model. It is the same AI with systematically engineered context surrounding every interaction.

Context engineering has two parts: injection (hooks that shape what the model knows at each moment) and persistence (memory that accumulates across sessions). This article covers both.

The Lifecycle: What Fires at Each Event

Tenkr hooks into the AI model's lifecycle at six points. Each one shapes what the model knows and how it behaves.

Session Start. Before you see the prompt, multiple sub-hooks fire: your extended specification gets loaded, today's session notes are injected so the model knows what happened earlier, and any pending reminders are added. By the time you type your first word, the model already knows your project's architecture, your conventions, and what you worked on this morning.

Prompt Submit. Before the model processes your prompt, methodology skills get appended (brainstorming, validation-first execution, verification-before-completion, systematic debugging) so the model sees them every turn. If you use a structured recall prefix, the model is forced to consider databases, external tools, and existing agents before touching a single file.

Pre-Tool Use. When the model spawns a subagent, the dispatcher intercepts and injects the right primer based on the agent type. Exploration agents get an operational landscape primer. Planning agents get orchestration intelligence. Builder agents get methodology requirements. At most one primer fires per spawn.

Agent Start. A lightweight pointer to project memory gets added. Low potency by design — no loss if ignored, occasional upside when relevant.

Want context engineering working for your team?

Agent Stop. For builders and validators, the first stop attempt gets blocked. The agent must provide verification evidence before it can complete. On the second attempt, the system allows it through.

Session End. A background process converts the transcript, updates persistent memory, writes daily notes, indexes knowledge documents, and stores session metadata. Next session, the start hooks have fresh material to inject.

The Hook Mechanism

Hooks are scripts that the AI runtime calls at lifecycle events. They receive structured input and return structured output to inject context, modify tool inputs, or block actions. Three categories:

Context injectors add information the model would not otherwise have. Your project spec at session start. Methodology reminders on every prompt. Memory pointers for agents.

Primers modify agent prompts before execution. An exploration primer rewrites the agent's prompt to include operational landscape awareness. A methodology primer appends validation and verification requirements. Primers are received as part of the assignment, not supplementary context, so they carry high potency.

Gates block actions until conditions are met. The verification gate blocks builder stop attempts until evidence is provided.

Each lifecycle event has one router that decides which sub-hooks fire. You add new behavior by writing a new sub-hook and registering it in the router.

Memory: What Persists Across Sessions

Context injection only works if there is something worth injecting. Memory is the accumulation system that feeds the hooks.

Daily Notes

At the end of every session, a background agent reads the transcript and writes a structured summary. This happens automatically.

Each entry has three sections: what was worked on, what decisions were made, and what is still unfinished. Bullets are capped at ten words. When your next session starts, a hook injects today's daily notes into context. This is why Tenkr can say “earlier today you were working on the data pipeline” without you telling it.

Persistent Memory

Persistent memory stores things that matter across sessions — not what happened today, but what should always be true. At session end, a memory maintenance agent reconciles the transcript against current memory, asking: what would break a future session without this? What assumption was proven wrong? What pattern applies beyond this session?

Entries are written as instructions, not diary entries. For example, instead of “We learned that the shell escapes exclamation marks inside double quotes,” it stores “Shell-executed SQL: use <> not != — Zsh escapes ! inside double quotes, silently breaking queries.”

When persistent memory grows large, topics get offloaded to subdirectory files with one-line references in the main file.

Knowledge Directory

The knowledge directory is for documents you want Tenkr to search — PDFs, Word docs, images, markdown. Drop a file in, and it gets automatically indexed at the end of your next session. Unlike daily notes and persistent memory (written by Tenkr), the knowledge directory is curated by you.

Codebase Profiles

Generated when you profile an external repository. They capture architecture, tech stack, key patterns, and common operations — stored and automatically indexed for future reference.

How Search Works

All memory layers feed into a single search system. Searching performs a hybrid query combining meaning-based matching with keyword matching. Results come back ranked by relevance with source attribution.

The search covers six source types: daily notes, persistent memory, session transcripts, knowledge documents, codebase profiles, and codebase recipes.

Inspection and Diagnosis

When something feels off — the model forgot your conventions, a builder shipped without verification, an exploration agent did shallow investigation — you can trace what happened by checking which hooks fired and what context was available.

The hooks are the mechanism. The lifecycle events are the timing. Memory is the fuel. Together, they turn the same model into one that knows your project, follows your methodology, and proves its work.

The future is not AI-assisted. It is AI-driven.

Join the waitlist for Tenkr.