Trees: All a Coding Agent Sees
File trees, JSON, the page DOM, code syntax trees—when AI reads your project, it sees trees. Open a line of code and watch it grow into an AST
THE QUESTION THIS PAGE ANSWERS
ANSWER FIRSTWhat is the key idea behind “Trees: All a Coding Agent Sees”?
File trees, JSON, the page DOM, code syntax trees—when AI reads your project, it sees trees. Open a line of code and watch it grow into an AST
Make the claim earn its place. Use this page as a decision aid, not a definition to memorize. Connect the idea to one real task, one observable result, and one failure that would change your mind.
Write one question you could answer with evidence after trying this idea.
A conclusion that sounds complete but leaves the key assumption untested.
Suppose you ask AI to build a “milk-tea shop mini program.” The three tabs below are the project’s file tree, one order’s JSON, and the order page’s DOM—they look totally different. Click the arrowed nodes to expand and collapse, and watch for one thing: don’t they share the exact same shape? One root, branching down.
Trees’ greatest cameo is in the code itself. The total-price line below is a string of text to you; to a Coding Agent it’s a syntax tree (AST). Hit “Parse” and watch it grow bottom-up—notice how each highlighted snippet maps to a new node on the tree.
* node on the tree, takes its right child, and hits exactly what you named. Then it “prints” the tree back to text without shifting a single space. Rename, extract function, bulk refactor—all surgery on this tree, not lucky text replace.
Agent reads a project = walk the file tree from the root
Hand a project to a Coding Agent and its first move is starting at the root directory, expanding folders layer by layer—same gesture as opening the milk-tea mini program tree above. It reads the tree’s shape for the skeleton, then skims a few key “leaves.”
JSON is the universal tree of the API world
The message list you send to an LLM API, the docs RAG retrieves, the tasks Agents pass around—almost all ship as JSON, because it’s a tree written as text any program can peel layer by layer. Read trees, and you’ve read most of the AI world’s data.
Why “One thing, three views · same project, three trees” depends on the operation
“Suppose you ask AI to build a “milk-tea shop mini program.” The three tabs below are the project’s file tree , one order’s JSON , and the order page’s DOM —they look totally differ…” makes the structure concrete. The useful comparison is not which name sounds more advanced, but how the data is arranged and how far the most common operation has to travel.
Read a structure through access and change
“Trees’ greatest cameo is in the code itself.” exposes a trade-off that is easy to miss: reading by position, looking up by key, adding at either end, inserting in the middle, and traversing relationships do not favor the same organization. A structure that is fast for one operation is not automatically fast for all of them.
- Hierarchy is a tree : nested containment means a tree—file trees, JSON, and the DOM all qualify
- Three terms : top is root, a node with kids is a parent, tips are leaves
- AST is the map for precise AI edits : Agents see the syntax tree, not raw text—so they hit what you name
Count scale and update frequency together
Use “The message list you send to an LLM API, the docs RAG retrieves, the tasks Agents pass around—almost all ship as JSON, because it’s a tree written as text any program can peel laye…” as a boundary check. Write down the data size, the dominant operation, and the latency you can accept before deciding whether an AI-generated structure actually fits.
From “One thing, three views · same project, three trees” to “The main act · one line of code becomes a tree”
“One thing, three views · same project, three trees” grounds the problem in “Suppose you ask AI to build a “milk-tea shop mini program.” The three tabs below are the project’s file tree , one order’s JSON , and the order page’s DOM —they look totally different. Click the arrowed nodes t…”. “The main act · one line of code becomes a tree” then moves it toward “Trees’ greatest cameo is in the code itself. The total-price line below is a string of text to you; to a Coding Agent it’s a syntax tree (AST) . Hit “Parse” and watch it grow bottom-up —notice how each highligh…”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.
Carry the judgment into the next situation
When you meet a new data structure, do not begin by memorizing its definition. Write down the most frequent operation, estimate scale and update behavior, and check whether the structure satisfies all three conditions.
- “One thing, three views · same project, three trees”: Suppose you ask AI to build a “milk-tea shop mini program.” The three tabs below are the project’s file tree , one order’s JSON , and the order page’s DOM —they look totally different. Click the arrowed nodes t…
- “The main act · one line of code becomes a tree”: Trees’ greatest cameo is in the code itself. The total-price line below is a string of text to you; to a Coding Agent it’s a syntax tree (AST) . Hit “Parse” and watch it grow bottom-up —notice how each highligh…
- “The closing point”: JSON is the universal tree of the API world : most AI data exchange rides this “text tree”
The final “The closing point” brings the discussion to “JSON is the universal tree of the API world : most AI data exchange rides this “text tree””. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.
What this lesson wants to share
- Hierarchy is a tree: nested containment means a tree—file trees, JSON, and the DOM all qualify
- Three terms: top is root, a node with kids is a parent, tips are leaves
- AST is the map for precise AI edits: Agents see the syntax tree, not raw text—so they hit what you name
- Reading a project is walking the file tree: start at the root, expand layer by layer, skeleton first then leaves
- JSON is the universal tree of the API world: most AI data exchange rides this “text tree”
I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.
After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.
When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.
No discussion on this article yet.