Context, Not Just Prompts: Making AI Agents Actually Useful

Posted on Jan 16, 2026

You set up your workspace for agents. Now they give you… garbage. Or they hallucinate imports. Or they break tests and can’t fix them. Why?

Most “bad agent output” is a context problem, not a model problem.

Agents don’t “see” your codebase like you do. They see:

  • Your current chat history (~20% of context window)
  • The open file (~10%)
  • A few recent files you mentioned (~30%)
  • Maybe some workspace index
  • Everything else? Gone.

This article shows how to give agents durable context (project rules they always see) and just-in-time context (task-specific files/symbols). Plus workflows for safe multi-file changes that don’t trash your codebase. artezio

What agents actually “see” in your workspace

Cursor indexes your entire workspace and uses up to 200k tokens in normal mode (1M+ in Max mode with Claude). But it prioritizes:

  1. Current chat
  2. Open files
  3. Recently mentioned files
  4. .cursorrules, README.md, ARCHITECTURE.md
  5. Workspace index (files, symbols)

The problem: it doesn’t see everything. You need to tell it what’s relevant.

Durable context: give agents your project’s rules once

Instead of typing “I’m using Next.js with Prisma and TypeScript strict mode” in every prompt, put it in a file Cursor always sees.

.cursorrules in project root

Create .cursorrules:

# Always visible to agents

## Stack
- Next.js 14, TypeScript strict, Prisma ORM
- Tests: Jest + React Testing Library
- Lint: ESLint + Prettier
- Build: `npm run build && npm run typecheck && npm run test`

## Rules
- No `any` types
- Functional components only
- API routes: `app/api/[resource]/route.ts`
- Tests co-located: `Component.test.tsx`

## Commands
- Dev: `npm run dev`
- Typecheck: `npm run typecheck`
- Test: `npm run test`

Cursor reads this automatically on every request. No repetition needed.

Result: Every agent request gets this context automatically.

Just-in-time context: point, don’t paste

Instead of pasting 200 lines of code, point Cursor to it.

Cursor examples

# Instead of pasting the whole auth file:
@auth/jwt.ts Add token refresh logic following existing patterns

# Instead of describing the schema:
@users/schema.ts Update role enum to include 'superadmin'

# Scoped multi-file:
In app/api/users/ rename all 'admin' to 'superadmin' and update tests

Cursor pulls the referenced files into context automatically.

Why this works: References use ~10 tokens vs. 10k for pasting code. Cursor pulls exactly what’s needed.

Safe multi-file editing: the plan → edit → test loop

Agents shine at multi-file changes, but only with a clear process.

Workflow for any multi-file change

  1. Ask for a plan first (no edits yet):

    Cursor: "Plan how to rename admin → superadmin across the codebase"
    
  2. Review the plan and approve specific parts.

  3. Scoped implementation:

    Cursor: "@users/ @auth/ @tests/ apply the approved plan"
    
  4. Review diffs before applying.

  5. Run verification:

    Cursor: "Run npm run typecheck && npm run test. Fix failures."
    
  6. Iterate if needed.

Real example: API pattern migration

Task: Update all app/api/users/[id]/route.ts to use new async/await pattern.

Step 1: Plan

Cursor: "Show me the current pattern in app/api/users/ and plan the async/await migration"

Cursor responds with:

Current pattern (app/api/users/[id]/route.ts):
.then().catch()
Proposed: try/catch with async/await
Files to change: 8 files in app/api/
Tests to update: users.test.ts

Step 2: Scoped execution

"@app/api/users/ @tests/users/ apply the async/await migration"

Cursor shows diffs across 8 files + tests. Review and apply.

Step 3: Verify

"Run npm run typecheck && npm run test. Fix issues."

Cursor runs tools, finds one test failure, proposes fix.

Time: 5 minutes vs. 45 minutes manual.

5 rules for good agent context

Copy these as your checklist:

  1. Write it once: Product vision, architecture, rules → .cursorrules. techpoint
  2. Point, don’t paste: @file, @folder references, not code dumps. skywork
  3. Scope edits: Tell Cursor where to work, not just what. youtube
  4. Let tools speak: Tests/lints/typecheck = Definition of Done, not your opinion. leanware
  5. Many small passes: 3x 100-line edits > 1x 300-line edit. Context stays cleaner.

What you can do right now

  1. Create .cursorrules in your project root
  2. Try a scoped query: Ask Cursor “show me how authentication works” with @auth/
  3. Run the plan → edit → test loop on a small refactor in your codebase
  4. Measure: Time saved vs. manual, and confidence in the output

Agents don’t replace you. They replace the tedious parts. Good context makes them reliable enough to trust with that.


Sources

Cursor Docs: How Cursor Works - https://cursor.com/docs/context/how-cursor-works artezio

Cursor Docs: Models - https://cursor.com/docs/models techcommunity.microsoft

Cursor: .cursorrules Documentation - https://cursor.com/docs/advanced/rules techpoint

Cursor: Codebase Context - https://cursor.com/docs/context/codebase-context skywork

Cursor: Multi-File Editing - https://cursor.com/docs/advanced/multi-file-editing youtube

Anthropic: Effective Context Engineering - https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents leanware