blog

AI Context Engineering: How to Level Up Prompting, Context, and Output with Modern Tools - Blog - Naufaldi Rafif Satriya

Most developers blame the AI when they get bad answers. The truth? 90% of “dumb” output is your fault—because you haven’t engineered the prompt, context,...

AI Context Engineering: How to Level Up Prompting, Context, and Output with Modern Tools - Blog - Naufaldi Rafif Satriya

Most developers blame the AI when they get bad answers. The truth? 90% of “dumb” output is your fault—because you haven’t engineered the prompt, context, or output.

1\. Prompting Fundamentals: Input → Context → Output

Prompting is not just “asking” AI for help—it’s designing a robust, testable information contract. Every ambiguity in your prompt is a vector for failure, every missing detail a chance for the model to hallucinate or misfire.

🎯 Input — Ruthless Precision is Key

_Strong prompt:_

"In useFetchPerson, fetching /api/person/{id} returns a 404 error. Why? Fix the code in-place (do not create new files) and return a patch diff."

_Bad prompt:_

"I got a bug in @/useFetchPerson, pls fix."

The difference isn’t subtle. Specificity guides model attention, limits hallucination, and defines the rules of engagement. PromptingGuide.ai breaks this down into: Instruction, Input Data, Context, and Output Indicator.

Best practices for input:

  • State the exact task (Instruction)
  • Attach any identifiers, sample data, or error messages (Input Data)
  • Set explicit constraints (no new files, format as diff, etc)

Keep the "context" in your prompt minimal—just enough to orient the model (e.g., file or function name, error message). Don’t overload the prompt itself with full code or logs—leave that to context engineering.

Examples:

  • _Refactor a component:_
  • Weak: “Refactor my React component.”
  • Strong: “Refactor the UserProfile React component for readability and split out useFetchPerson into a separate hook. Output the diff only.”
  • _Unit test generation:_
  • Weak: “Write tests for this code.”
  • Strong: “Generate Jest unit tests for src/utils/calculateInvoice.ts. Cover edge cases, use real data samples, and output in one file.”
  • _Error diagnosis:_
  • Weak: “Why does this not work?”
  • Strong: “When running fetchData() in Node 20, I get ERR_INVALID_ARG_TYPE on line 17. Show a code fix and explain the root cause.”

✅ Output — Specify, Don’t Assume

Never expect the model to “just know” your output format. A great prompt spells out:

  • Output form (patch diff, inline code, test case, etc)
  • Constraints ("do not create new files")
  • (Optional) rationale for the change

_Example output instruction:_

"Show only the patch diff for useFetchPerson, with inline comments explaining the fix."

This clarity accelerates review, reduces back-and-forth, and drives higher-quality results.

Pro move: If the model output is weak, check your input and context. Iterate until you consistently get actionable, review-ready answers.

2\. Context: The Real Bottleneck in AI Coding

You’ve seen how a strong prompt sets the stage—but that’s only half the battle. Here’s where you win or lose: context engineering. This is the heavy lifting that turns a prompt into a production-grade solution.

"Context engineering is the delicate art and science of filling the context window with just the right information for the next step."
— Andrej Karpathy

If you think writing a clever prompt is enough, you’re already falling behind. In production, context is the main lever that separates toy LLM demos from tools that actually work.

“Context is not just the single prompt users send to an LLM. Context is the complete information payload provided to a LLM at inference time, encompassing all structured informational components that the model needs to plausibly accomplish a given task.” —A Systematic Analysis of Over 1400 Research Papers

---

Prompt Engineering   │   Context Engineering
------------------   │   -------------------
"What you say"       │   "Everything else the model sees"
(Single instruction) │   (Examples, memory, retrieval, tools, state, control flow)

Why context matters:

  • LLMs don’t “understand” your problem unless you engineer the _entire information payload_—every relevant code artifact, config, and log.
  • Every LLM and coding tool (Cursor, Trae, Kiro) has a unique context window—usually smaller than you expect. Overflow, and the tool will drop or truncate context, often without warning.
  • IDEs inject system prompts and metadata; what you see in your editor isn’t always what the model actually gets.
  • Long sessions and noisy history dilute critical details. Too much irrelevant chatter and you push out the context you actually need.

Context engineering best practices:

  • Ruthlessly curate only the code, logs, docs, and metadata _directly_ relevant to your current task. Irrelevant info = worse output.
  • Add stack traces, env config, related types or interfaces—but avoid dumping full files unless essential.
  • Chunk or summarize large inputs. Use Markdown/XML tags for clarity if supported (PromptingGuide.ai).
  • For debugging: always specify what code, what error, what environment, what dependencies. Ambiguity here means garbage output.
“MEM1 trains AI agents to keep only what matters—merging memory and reasoning at every step—so they never get overwhelmed, no matter how long the task.”
— MEM1: Singapore-MIT 2025

Concrete Example: If you’re debugging useFetchPerson, don’t just paste the function. Include:

  • Failing API response and error log
  • API_BASE_URL from your .env
  • Related type/interface
  • Recent git diff if the bug appeared after a deploy

Additional Examples:

_Onboarding a new dev:_

Provide LLM with just README.md, .env.example, latest migration, and a single annotated production trace—avoid outdated wiki pages and legacy code history.

_Bug hunting across microservices:_

Context should include: error logs from Service A, OpenAPI spec for Service B, and version info for all dependent services.

_Multi-file refactor:_

Instead of “Refactor all auth code,” attach just the affected files, related types, and a sequence diagram or architecture doc excerpt. Avoid full repo dumps.

---

Advanced context: Cognitive tools and symbolic mechanisms

  • Modular cognitive tools (from IBM, Zurich, etc) show breaking tasks into steps, surfacing symbols, and scoping context for each reasoning layer are the next frontier in LLM performance (IBM Cognitive Tools 2025, ICML Princeton 2025).
  • This is why Markdown, JSON, and structured formats massively improve parsing and reasoning for LLMs.

---

3\. MCP: How Protocolizing Context Unlocks Real AI Acceleration

Most teams never get past “prompt glue” and brittle context hacks. MCP (Model Context Protocol) changes that by making context a first-class, programmable interface—unlocking everything that matters for real-world, reliable AI.

“MCP is to AI what USB-C is to hardware. Standardized, plug-and-play context.”

Why MCP matters for context engineering

  • Solves the “stale context” problem. AI’s biggest bottleneck is outdated or partial context—MCP gives you _live, up-to-date data_ (schemas, docs, code) at inference, not months-old training data.
  • Reduces hallucinations and context drift. Standardized, server-side context means every tool and model sees the _same, fresh source of truth_.
  • Makes context “just work” across the stack. Whether you’re using Claude, GPT-4o, or Gemini, MCP makes your IDE, agents, or scripts plug-and-play with production data—_no more manual updates, fragile RAG, or “paste this code block in the chat.”_
  • Accelerates agentic workflows. LLMs can reason, query, and chain tasks _across multiple sources_—local and remote—without hardcoding every step or leaking data.

How MCP boosts engineering and code velocity

  • Faster onboarding: Every developer/AI agent gets instant access to the _real_ schema, docs, and current code—no more “where’s the updated diagram?”
  • Automated code review and debugging: MCP lets AI instantly pull related files, logs, and metadata for deep, contextual feedback—impossible with static prompts.
  • Seamless workflow integration: Tools like Cursor, Kiro, and IDEs can “subscribe” to MCP context, making features like inline refactor, multi-file search, and dynamic doc lookup _trivial_ to implement.
  • Enables structured, multi-turn reasoning: MCP Sequential Thinking lets AI agents move step-by-step, updating their context after every inference—closing the loop between output and future input.

Concrete MCP use cases:

  • MCP Postgres: AI can safely generate, migrate, and review SQL using _live_ database metadata and sample data—no more broken migrations.
  • MCP Context7: Bridge model knowledge cutoffs by letting AI query your _real_ docs and changelogs during inference, not just hallucinate.
  • MCP Sequential Thinking: Orchestrate complex workflows—code review, multi-stage builds, incident analysis—where each step’s output automatically informs the next context window.

Want to go deeper?

  • Explore ready-to-use MCP servers and real integrations here: awesome-mcp-servers
  • Find plug-and-play connectors for databases, local files, cloud APIs, IDEs, and more. Build, test, and connect your own context sources—no more brittle RAG glue.

Conclusion

Old-school prompt hacking isn’t enough. If you want AI to boost your code, workflow, and team, you need to master all three levers:

  • Ruthless prompting fundamentals (Input → minimal Context → clear Output)
  • Deep, intentional context engineering (not just dumping code—curate, structure, iterate)
  • Protocolized context with MCP—so your stack, docs, and code always stay in sync with the model

The modern AI engineering stack is:

  • Prompts as contracts (not wishful thinking)
  • Context as a managed asset (not an afterthought)
  • Output you can specify and trust
  • MCP (and other protocols) to automate, accelerate, and scale every step

Don’t let your workflow get stuck in 2023. If you want reliable, explainable, and scalable AI in code, ops, or research—level up _all three_ pillars.

Stop blaming the AI. When you upgrade your prompts, engineer your context, and protocolize your workflow—suddenly, the model isn’t the bottleneck. You are.