惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
GbyAI
GbyAI
爱范儿
爱范儿
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
M
MIT News - Artificial intelligence
量子位
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
V
Visual Studio Blog
罗磊的独立博客
F
Fortinet All Blogs
美团技术团队
博客园_首页
博客园 - 【当耐特】
L
LangChain Blog
月光博客
月光博客
腾讯CDC
The Cloudflare Blog
D
Docker
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Structured Context Before AI: The Rule That Made My Legac...
Paulo Eremit · 2026-05-07 · via DEV Community

A lot of AI-assisted coding tools fail for a simple reason:

they ask the model to think before the system has done enough work.

That usually leads to one of two outcomes:

  • vague summaries that sound smart but don’t help much
  • confident mistakes wrapped in beautiful prose

While building my legacy analysis tool, I kept running into the same conclusion:

if you want useful AI output, you need structured context first

That rule changed the whole design of the project.

The temptation

When working with a legacy codebase, it is very tempting to do this:

  • grab a file
  • send it to an LLM
  • ask: "what does this do?"

Sometimes that works.

But legacy systems are rarely understandable from a single file.

A method may look innocent until you discover:

  • it depends on includes
  • it calls another class indirectly
  • it builds SQL dynamically
  • it is triggered by a UI flow you haven't seen yet
  • the real business meaning lives in the database schema, not the method body

If you ask AI too early, it will often fill the gaps with plausible fiction.

That is not intelligence. That is autocomplete wearing a tie.

What I changed

Instead of starting with AI, I designed the workflow to start with extraction.

The tool tries to collect structure before asking for commentary.

Depending on the analysis path, that may include:

  • file path and class/method identity
  • dependency chains
  • include resolution
  • SQL blocks
  • tables touched
  • UI actions and endpoints
  • schema metadata
  • procedure summaries
  • domain map hints

Only after that does AI step in.

So the prompt is no longer:

"please explain this mysterious code"

It becomes closer to:

"here is the method, here are its dependencies, here are the SQL fragments, here are the tables, here is the path it came from, now explain what is actually happening"

That difference is enormous.

Why this works better

Structured context improves AI output in at least four ways.

1. It reduces hallucination pressure

When the model has actual extracted signals, it does not need to invent as much missing context.

That does not eliminate mistakes, but it lowers the odds of polished nonsense.

2. It makes answers more specific

Instead of generic observations like:

  • "this appears to handle business logic"
  • "it may interact with the database"

you start getting analysis grounded in real technical evidence:

  • which tables are involved
  • which dependencies were resolved
  • which flow the UI suggests
  • where the risk points actually are

3. It makes reports reusable

If the context is structured, it can be cached, compared, regenerated, and reused.

That matters a lot in real engineering work, where you often revisit the same area multiple times.

4. It makes AI part of a system, not a gimmick

This is the most important one.

AI becomes one stage in a pipeline.

Not the whole pipeline.

That means the tool still has value even before the model speaks.

And that is a good test of whether your design is serious.

A practical example

Let’s say you are trying to understand a legacy backend action.

A weak workflow is:

  1. open one PHP file
  2. paste it into an LLM
  3. ask for a summary

A stronger workflow is:

  1. identify the real method or action
  2. resolve related includes
  3. extract SQL fragments
  4. detect external class calls
  5. identify likely tables involved
  6. inspect schema when needed
  7. only then generate AI commentary

The first workflow gives you a guess.

The second gives you a technical briefing.

The hidden lesson

This idea goes beyond legacy analysis.

I think it applies to almost every serious AI engineering workflow.

If you want reliable AI assistance, you usually need some combination of:

  • preprocessing
  • structure extraction
  • constrained prompting
  • typed outputs
  • caching
  • human-readable artifacts

In other words:

the quality of the AI output often depends more on the surrounding system than on the model itself.

That is not as flashy as saying "I built an AI tool."

But it is much closer to the truth.

What I believe now

I no longer think the most valuable AI tools are the ones that "do everything."

I think the valuable ones are the ones that:

  • collect the right context
  • shape the right questions
  • constrain the right outputs
  • fit into real workflows engineers already need

Models matter.

But scaffolding matters more than people want to admit.

Final thought

One of the most useful engineering habits I’m developing is this:

never ask AI to infer what your system could have extracted first

That rule made my tool better.

It also made my trust in the output more rational.

And in applied AI, rational trust is worth a lot more than impressive demos.

If you’re building AI-assisted engineering tools, I’d love to know:

how much of your result comes from the model, and how much comes from the structure around it?