<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[WTH are Agents ?]]></title><description><![CDATA[WTH are Agents ?]]></description><link>https://wth-are-agents.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 11:42:25 GMT</lastBuildDate><atom:link href="https://wth-are-agents.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[WTH are AI Agents ?]]></title><description><![CDATA[“What if your terminal could think like a developer?” This exciting question sparked the creation of my very own AI-powered coding assistant! Imagine a terminal-based agent that can whip up entire projects, write full-stack code, and smartly respond ...]]></description><link>https://wth-are-agents.hashnode.dev/wth-are-ai-agents</link><guid isPermaLink="true">https://wth-are-agents.hashnode.dev/wth-are-ai-agents</guid><category><![CDATA[AI]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Divyansh sharma]]></dc:creator><pubDate>Sun, 16 Nov 2025 14:24:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1763302987629/2abb37d5-66a4-4465-8f0e-cf6253a58459.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>“What if your terminal could <em>think</em> like a developer?” This exciting question sparked the creation of my very own AI-powered coding assistant! Imagine a terminal-based agent that can whip up entire projects, write full-stack code, and smartly respond to follow-up prompts. It's like having a mini version of <strong>Cursor</strong> right in your command line! In this post, I’m thrilled to guide you through the journey of building this agent, sharing the motivations, technical architecture, learnings, and how you can tailor it to fit your own needs. Let's dive in!</p>
<h2 id="heading-motivation-why-i-built-this"><strong>🚀 Motivation: Why I Built This</strong></h2>
<p>As developers, we spend a lot of time switching between code editors, terminal windows and documentation. I wanted to streamline this to build a CLI tool that feels like pair-programming with an intelligent assistant.</p>
<p>I was deeply inspired by modern dev tools like <strong>Cursor</strong> and by mentors like <strong>Piyush Garg</strong> and <strong>Hitesh Choudhary</strong>, who emphasize building tools, not just learning about them.</p>
<p>So I asked myself:<br /><strong>Can I build an AI agent that builds software — directly from the terminal?</strong></p>
<hr />
<h2 id="heading-what-it-does-key-features">⚙️ What It Does: Key Features</h2>
<ul>
<li><p><strong>🧠 Prompt-Based Interaction</strong><br />  Talk to the agent in natural language:</p>
<blockquote>
<p><code>add a login page with email/password authentication</code><br />It parses the context and updates your project intelligently.</p>
</blockquote>
</li>
<li><p><strong>📁 Auto Project Scaffold</strong><br />  Generates folder and file structure based on your tech stack preferences — React + Express, MERN, NestJS, etc.</p>
</li>
<li><p><strong>📝 Code Writing</strong><br />  It writes real, production-ready code directly into files — frontend UI components, backend routes, database schemas.</p>
</li>
<li><p><strong>⚡ Real-Time Command Execution</strong><br />  Runs <code>npm install</code>, <code>pip install</code>, <code>npx prisma generate</code>, <code>npm run dev</code>, and more — directly from within the agent.</p>
</li>
<li><p><strong>🔁 Iterative Prompts</strong><br />  You can follow up with:</p>
<blockquote>
<p><code>now add Google login</code><br />The agent will find and edit the correct files intelligently.</p>
</blockquote>
</li>
</ul>
<hr />
<h2 id="heading-how-it-works-behind-the-scenes">🧠 How It Works: Behind the Scenes</h2>
<h3 id="heading-1-natural-language-understanding">🧩 1. Natural Language Understanding</h3>
<p>Using the OpenAI API (or LLMs like Mistral, LLaMA via Ollama), the user’s prompt is parsed using structured <strong>system instructions</strong>. Example system prompt:</p>
<p><strong>Copy</strong></p>
<p><strong>Copy</strong></p>
<pre><code class="lang-python">You are a software engineer that builds full-stack apps. Given user instructions, generate project folders, write frontend <span class="hljs-keyword">and</span> backend code, <span class="hljs-keyword">and</span> execute commands when needed.
</code></pre>
<h3 id="heading-2-project-context-parsing">🗂️ 2. Project Context Parsing</h3>
<p>The agent reads the <strong>existing folder structure and file content</strong> to understand the current state. This context is used in every follow-up prompt.</p>
<h3 id="heading-3-file-writing-logic">🧾 3. File Writing Logic</h3>
<p>The agent determines:</p>
<ul>
<li><p>Which files to update</p>
</li>
<li><p>Which lines to modify</p>
</li>
<li><p>Where to insert new code</p>
</li>
</ul>
<p>It uses structured <code>fs</code> operations in Node.js to write code into actual <code>.js</code>, <code>.ts</code>, <code>.jsx</code>, <code>.json</code>, and <code>.env</code> files.</p>
<h3 id="heading-4-command-execution">🧪 4. Command Execution</h3>
<p>A shell wrapper executes commands like:</p>
<p><strong>Copy</strong></p>
<p><strong>Copy</strong></p>
<pre><code class="lang-python">child_process.exec(<span class="hljs-string">'npm install'</span>)
</code></pre>
<p>Outputs are captured and logged to the user like a real CLI experience.</p>
<hr />
<h2 id="heading-sample-interaction">🖼️ Sample Interaction</h2>
<p><strong>Copy</strong></p>
<p><strong>Copy</strong></p>
<pre><code class="lang-python">bashCopyEdit&gt; initialize react + express project
✅ Project scaffold created

&gt; add login page <span class="hljs-keyword">with</span> email/password
🧠 Context parsed
📝 Writing Login.jsx, AuthRoutes.js, updating App.jsx...

&gt; install dependencies
📦 Running: npm install react-router-dom express bcrypt

&gt; now add forgot password flow
🔁 Updating AuthRoutes.js <span class="hljs-keyword">and</span> adding ForgotPassword.jsx
</code></pre>
<hr />
<h2 id="heading-challenges-amp-fixes">⚠️ Challenges &amp; Fixes</h2>
<h3 id="heading-context-management">🔄 Context Management</h3>
<p><strong>Problem</strong>: Model forgets context or overwrites unrelated files.<br /><strong>Fix</strong>: Used a snapshot of <code>file tree + diff</code> and attached recent edits in every prompt.</p>
<h3 id="heading-code-injection-issues">🛠️ Code Injection Issues</h3>
<p><strong>Problem</strong>: LLM inserted duplicate functions or broke existing code.<br /><strong>Fix</strong>: Added helper functions for <strong>safe append/replace</strong>, and file-specific constraints.</p>
<h3 id="heading-performance-bottlenecks">🐢 Performance Bottlenecks</h3>
<p><strong>Problem</strong>: Long command chains slowed the CLI.<br /><strong>Fix</strong>: Debounced command execution and showed stepwise loading.</p>
<hr />
<h2 id="heading-learnings-from-prompt-engineering">📚 Learnings from Prompt Engineering</h2>
<p>I went deep into prompt formats and methods to get consistent results.</p>
<h3 id="heading-system-task-context-prompting">✅ System + Task + Context Prompting</h3>
<p>Combined system message + file tree + task message.</p>
<h3 id="heading-few-shot-prompting">🧠 Few-Shot Prompting</h3>
<p>Gave the model examples like:</p>
<p><strong>Copy</strong></p>
<p><strong>Copy</strong></p>
<pre><code class="lang-python">// Instruction:
Add a new route to /register <span class="hljs-keyword">in</span> Express

// Response:
Create file routes/register.js, write:
router.post(<span class="hljs-string">'/register'</span>, ...)
</code></pre>
<h3 id="heading-chain-of-thought-prompting">🧵 Chain of Thought Prompting</h3>
<p>Got better quality by encouraging the model to “think” step-by-step:</p>
<p><strong>Copy</strong></p>
<p><strong>Copy</strong></p>
<pre><code class="lang-python">First, check <span class="hljs-keyword">if</span> user model exists. Then add the controller. Finally, update routes.
</code></pre>
<hr />
<h2 id="heading-how-others-can-use-or-extend-it">🧩 How Others Can Use or Extend It</h2>
<ul>
<li><p><strong>Plug into any tech stack</strong>: React, Next.js, NestJS, Django — just modify the scaffold templates.</p>
</li>
<li><p><strong>Customize the system prompt</strong>: Tailor it for your team, coding style, or even a language (like Python or Go).</p>
</li>
<li><p><strong>Add voice input or autocomplete</strong>: Turn it into a full dev assistant.</p>
</li>
<li><p><strong>Deploy as a binary CLI</strong>: Package it for others to install via <code>npx</code> or <code>brew</code>.</p>
</li>
</ul>
<hr />
<h2 id="heading-whats-next">📅 What’s Next?</h2>
<ul>
<li><p>Integrating <strong>AI-powered code linting</strong></p>
</li>
<li><p>Adding <strong>file diff previews before writing</strong></p>
</li>
<li><p>Local model fallback via Ollama (for offline use)</p>
</li>
<li><p>Voice-to-code CLI interaction using Whisper</p>
</li>
</ul>
<hr />
<h2 id="heading-final-thoughts">☕ Final Thoughts</h2>
<p>Building this mini Cursor taught me something simple but powerful:</p>
<p><strong><em>💡 Prompting is the new scripting.</em></strong></p>
<p>You don’t need 1,000 lines of shell scripts anymore.</p>
<p>Just an intelligent agent that understands what you want and writes what you mean. It’s not just about automating tasks — it’s about building <strong>with</strong> AI, not just using it.</p>
]]></content:encoded></item></channel></rss>