Cursor AI 🤖: Giving AI a Keyboard, a Terminal, and a Brain


🔍 What is Agentic AI?
Agentic AI refers to a class of artificial intelligence that doesn't just respond — it acts. Unlike traditional chatbots, which passively return answers, Agentic AIs plan, decide, and take action using tools provided by the developer. They mimic the way a human agent would think through a task:
“What’s the user asking? What steps should I take? What tools do I need? What did I observe? Now what should I do next?”
This makes Agentic AI the brain behind AI agents like AutoGPT, GPT Engineer, and DevGPT, and now — your very own Cursor-like AI Developer Assistant.
⚙️ Core Components of an Agentic AI (Its Arms & Legs 🦾🧠)
To behave agentically, the AI needs:
A System Prompt (Brain 🧠): This defines how the AI reasons, plans, and uses tools.
Tools (Arms 🤖): Functions that can do real-world things (file creation, API calls, etc.).
Planning + Observation Loop (Legs 🦿): The ability to:
Plan the next step
Call a tool
Observe output
Plan again
Output results
This feedback loop enables autonomy.
🏗️ Tools I Built (The Arms)
Here are the core tools I built for the Agent:
1. create_file(filename, content)
A platform-independent file creation tool that works natively on Windows, Linux, or macOS using Python’s built-in functions (no shell commands). This replaced echo
, touch
, and powershell
.
pythonCopyEditdef create_file(filename: str, content: str):
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, "w", encoding="utf-8") as f:
f.write(content)
return f"✅ File '{filename}' created successfully."
2. make_dir(path)
Creates directories recursively. The agent uses this when starting new projects.
pythonCopyEditdef make_dir(path: str):
os.makedirs(path, exist_ok=True)
return f"✅ Directory '{path}' created."
3. get_weather(city)
Fetches weather data using wttr.in
for demo purposes and showing external API access.
4. run_command(cmd)
Executes terminal commands safely (used rarely, mostly for diagnostics or listing files).
🧠 How the Agent Thinks (Planning System Prompt)
The agent uses a carefully crafted system prompt that instructs it to:
Analyze the user query
Plan a step
Choose the right tool
Perform one action at a time
Observe the result
Continue reasoning
Produce a final answer
🧾 Output Format:
jsonCopyEdit{
"step": "plan" | "action" | "observe" | "output",
"content": "Explanation",
"function": "Tool name (if action)",
"input": "Tool input (string or object)"
}
This gives the agent a structure — like a reasoning chain.
💡 What is Natural Programmatic Language (NPL)?
Natural Programmatic Language (NPL) is how the AI speaks to your system — in structured JSON steps instead of plain text.
It’s halfway between natural language and code
Enables reasoning + execution + safety
Prevents hallucination or accidental file corruption
NPL turns GPT from a text bot ➝ into a developer assistant
💻 How the Agent Generated a TODO App from Scratch
Here’s how the agent built a complete HTML + CSS + JavaScript TODO app:
🧠 Plan: “User wants a TODO app in HTML/JS”
🔨 Create Directory:
make_dir
→todo-app/
🔨 Create index.html with form + list structure
🔨 Create style.css for basic styling
🔨 Create script.js with
addTodo
,removeTodo
,localStorage
logic🔁 Observed each file success
✅ Output: “Your TODO app has been created with index.html, style.css, and script.js”
You didn’t write a line of code — the AI acted autonomously.
🖱️ How I Made It Act Like Cursor AI
Cursor AI is an AI IDE that can:
Write files
Modify code
Think step-by-step
Use tools like
createFile()
orrunTests()
I mimicked that behavior by:
Writing native Python tools for file & directory creation
Using OpenAI's
chat.completions.create()
in a reasoning loopAdding structured observations and state
Giving it memory (
messages[]
) just like how Cursor does
The result?
✅ A fully agentic system that builds code, modifies files, reasons, and waits for results — like a junior dev assistant!
🚀 Final Thoughts & Takeaways
This is more than just automation — this is an AI that thinks, acts, and builds.
🧰 Tech Stack:
Python
OpenAI GPT-4.1 (JSON mode)
Dotenv
Requests
Platform-aware design
Subscribe to my newsletter
Read articles from Vidya Sagar Mehar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
