Recently, I adopted a coding tip from the Anthropic team that has significantly boosted the quality of my AI-generated code. Anthropic runs multiple Claude instances in parallel to dramatically improve code quality compared to single-instance workflows. How it works: (1) One Claude writes the code, the coder - focusing purely on implementation (2) A second Claude reviews it, the reviewer - examining with fresh context, free from implementation bias (3) A third Claude applies fixes, the fixer - integrating feedback without defensiveness This technique works with any AI assistant, not just Claude. Spin each agent up in its own tab—Cursor, Windsurf, or plain CLI. Then, let Git commits serve as the hand-off protocol. This separation mimics human pair programming but supercharges it with AI speed. When a single AI handles everything, blind spots emerge naturally. Multiple instances create a system of checks and balances that catch what monolithic workflows miss. This shows that context separation matters. By giving each AI a distinct role with clean context boundaries, you essentially create specialized AI engineers, each bringing a unique perspective to the problem. This and a dozen more tips for developers building with AI in my latest AI Tidbits post https://lnkd.in/gTydCV9b
How to Use AI Agents to Optimize Code
Explore top LinkedIn content from expert professionals.
Summary
AI agents are intelligent software tools that can analyze, write, review, and refine code by collaborating with human developers or working in multi-agent systems. Using AI agents to improve code means setting up workflows where these agents plan, reflect, and execute tasks—sometimes even breaking projects into smaller parts for specialized attention.
- Define clear roles: Assign specific duties to each AI agent, such as writing, reviewing, or fixing code, so their strengths complement your coding workflow.
- Use structured workflows: Set up step-by-step processes where agents can plan, reflect on their output, and incorporate feedback or tests to ensure better results.
- Maintain project context: Provide agents with organized guides, relevant files, and memory systems so they understand your codebase and track progress across multiple sessions.
-
-
Everyone thinks AI coding agents can replace engineers. This is wrong. Here’s how to actually make them useful: Agents generate code that almost works. Engineers close the loop: prompt → review → edit → test → repeat. The teams that win are the ones who make that loop fast and tight. Most teams are still stuck in “ask once, hope it compiles” habits. But here’s what actually works now: 1. Give agents real context → Keep a project guide (agents[.]md, rules[.]md, etc.) → Define goals, edge cases, and examples → Make it clear what “done” looks like before asking for code 2. Treat agents like junior devs → First: ask them to explain changes → Turn that into a clear checklist → Decide how much autonomy they get each run 3. Stay inside a diff-first loop → Always review diffs before merging → Separate shell commands from prompts → Reference files directly to tighten context 4. Edit small things yourself → Quick copy or logic fixes are faster by hand → Recompile and test right after each accepted diff → Let the agent continue in parallel on the next task 5. Capture what you learn → Document tricky fixes for reuse → Save commands, patterns, and notes → Every iteration gets faster with history 6. Ship with guardrails → Commit and PR from the terminal → Keep human review in the loop → Ship confidently, not blindly Agents don’t replace engineers. They amplify engineers who know how to run a tight feedback loop. Here's the link if you want to start building: https://go.warp.dev/aadit
-
Last week, I described four design patterns for AI agentic workflows that I believe will drive significant progress: Reflection, Tool use, Planning and Multi-agent collaboration. Instead of having an LLM generate its final output directly, an agentic workflow prompts the LLM multiple times, giving it opportunities to build step by step to higher-quality output. Here, I'd like to discuss Reflection. It's relatively quick to implement, and I've seen it lead to surprising performance gains. You may have had the experience of prompting ChatGPT/Claude/Gemini, receiving unsatisfactory output, delivering critical feedback to help the LLM improve its response, and then getting a better response. What if you automate the step of delivering critical feedback, so the model automatically criticizes its own output and improves its response? This is the crux of Reflection. Take the task of asking an LLM to write code. We can prompt it to generate the desired code directly to carry out some task X. Then, we can prompt it to reflect on its own output, perhaps as follows: Here’s code intended for task X: [previously generated code] Check the code carefully for correctness, style, and efficiency, and give constructive criticism for how to improve it. Sometimes this causes the LLM to spot problems and come up with constructive suggestions. Next, we can prompt the LLM with context including (i) the previously generated code and (ii) the constructive feedback, and ask it to use the feedback to rewrite the code. This can lead to a better response. Repeating the criticism/rewrite process might yield further improvements. This self-reflection process allows the LLM to spot gaps and improve its output on a variety of tasks including producing code, writing text, and answering questions. And we can go beyond self-reflection by giving the LLM tools that help evaluate its output; for example, running its code through a few unit tests to check whether it generates correct results on test cases or searching the web to double-check text output. Then it can reflect on any errors it found and come up with ideas for improvement. Further, we can implement Reflection using a multi-agent framework. I've found it convenient to create two agents, one prompted to generate good outputs and the other prompted to give constructive criticism of the first agent's output. The resulting discussion between the two agents leads to improved responses. Reflection is a relatively basic type of agentic workflow, but I've been delighted by how much it improved my applications’ results. If you’re interested in learning more about reflection, I recommend: - Self-Refine: Iterative Refinement with Self-Feedback, by Madaan et al. (2023) - Reflexion: Language Agents with Verbal Reinforcement Learning, by Shinn et al. (2023) - CRITIC: Large Language Models Can Self-Correct with Tool-Interactive Critiquing, by Gou et al. (2024) [Original text: https://lnkd.in/g4bTuWtU ]
-
Anthropic 𝗷𝘂𝘀𝘁 𝗿𝗲𝗹𝗲𝗮𝘀𝗲𝗱 𝗮 𝗱𝗲𝗻𝘀𝗲 𝗮𝗻𝗱 𝗵𝗶𝗴𝗵𝗹𝘆 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹 𝗿𝗲𝗽𝗼𝗿𝘁 𝗼𝗻 𝗵𝗼𝘄 𝘁𝗼 𝗯𝘂𝗶𝗹𝗱 𝗲𝗳𝗳𝗲𝗰𝘁𝗶𝘃𝗲 𝗔𝗜 𝗮𝗴𝗲𝗻𝘁𝘀 — 𝗽𝗮𝗰𝗸𝗲𝗱 𝘄𝗶𝘁𝗵 𝗲𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴 𝗶𝗻𝘀𝗶𝗴𝗵𝘁𝘀 𝗳𝗿𝗼𝗺 𝗿𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝗱𝗲𝗽𝗹𝗼𝘆𝗺𝗲𝗻𝘁𝘀: ⬇️ Not just marketing, BUT a real, practical blueprint for developers and teams building AI agents that actually work. It explains how Claude Code (tool for agentic coding) can function as a software developer: writing, reviewing, testing, and even managing Git workflows autonomously. BUT in my view: The principles and patterns described in this document are not Claude-specific. You can apply them to any coding agent — from OpenAI’s Codex to Goose, Aider, or even tools like Cursor and GitHub Copilot Workspace. 𝗛𝗲𝗿𝗲 𝗮𝗿𝗲 7 𝗸𝗲𝘆 𝗶𝗻𝘀𝗶𝗴𝗵𝘁𝘀 𝗳𝗼𝗿 𝗯𝘂𝗶𝗹𝗱𝗶𝗻𝗴 𝗯𝗲𝘁𝘁𝗲𝗿 𝗔𝗜 𝗮𝗴𝗲𝗻𝘁𝘀 — 𝘁𝗵𝗮𝘁 𝘄𝗼𝗿𝗸 𝗶𝗻 𝘁𝗵𝗲 𝗿𝗲𝗮𝗹 𝘄𝗼𝗿𝗹𝗱: ⬇️ 1. 𝗔𝗴𝗲𝗻𝘁 𝗱𝗲𝘀𝗶𝗴𝗻 ≠ 𝗷𝘂𝘀𝘁 𝗽𝗿𝗼𝗺𝗽𝘁𝗶𝗻𝗴 ➜ It’s not about clever prompts. It’s about building structured workflows — where the agent can reason, act, reflect, retry, and escalate. Think of agents like software components: stateless functions won’t cut it. 2. 𝗠𝗲𝗺𝗼𝗿𝘆 𝗶𝘀 𝗮𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲 ➜ The way you manage and pass context determines how useful your agent becomes. Using summaries, structured files, project overviews, and scoped retrieval beats dumping full files into the prompt window. 3. 𝗣𝗹𝗮𝗻𝗻𝗶𝗻𝗴 𝗶𝘀𝗻’𝘁 𝗼𝗽𝘁𝗶𝗼𝗻𝗮𝗹 ➜ You can’t expect an agent to solve multi-step problems without an explicit process. Patterns like plan > execute > review, tool use when stuck, or structured reflection are necessary. And they apply to all models, not just Claude. 4. 𝗥𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝗮𝗴𝗲𝗻𝘁𝘀 𝗻𝗲𝗲𝗱 𝗿𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝘁𝗼𝗼𝗹𝘀 ➜ Shell access. Git. APIs. Tool plugins. The agents that actually get things done use tools — not just language. Design your agents to execute, not just explain. 5. 𝗥𝗲𝗔𝗰𝘁 𝗮𝗻𝗱 𝗖𝗼𝗧 𝗮𝗿𝗲 𝘀𝘆𝘀𝘁𝗲𝗺 𝗽𝗮𝘁𝘁𝗲𝗿𝗻𝘀, 𝗻𝗼𝘁 𝗺𝗮𝗴𝗶𝗰 𝘁𝗿𝗶𝗰𝗸𝘀 ➜ Don’t just ask the model to “think step by step.” Build systems that enforce that structure: reasoning before action, planning before code, feedback before commits. 6. 𝗗𝗼𝗻’𝘁 𝗰𝗼𝗻𝗳𝘂𝘀𝗲 𝗮𝘂𝘁𝗼𝗻𝗼𝗺𝘆 𝘄𝗶𝘁𝗵 𝗰𝗵𝗮𝗼𝘀 ➜ Autonomous agents can cause damage — fast. Define scopes, boundaries, fallback behaviors. Controlled autonomy > random retries. 7. 𝗧𝗵𝗲 𝗿𝗲𝗮𝗹 𝘃𝗮𝗹𝘂𝗲 𝗶𝘀 𝗶𝗻 𝗼𝗿𝗰𝗵𝗲𝘀𝘁𝗿𝗮𝘁𝗶𝗼𝗻 ➜ A good agent isn’t just a wrapper around an LLM. It’s an orchestrator: of logic, memory, tools, and feedback. And if you’re scaling to multi-agent setups — orchestration is everything. Check the comments for the original material! Enjoy! Save 💾 ➞ React 👍 ➞ Share ♻️ & follow for everything related to AI Agents!
-
AI coding agents feel simple when you use them- but behind the scenes, a lot more is happening than just generating code. They’re not just responding… they’re understanding, planning, executing, and adapting in real time. That’s the shift most people miss. Once you see how they actually work, you stop treating them like tools… and start using them like systems. Here’s what’s really happening inside a coding AI agent 👇 🔹 Live Repo Context The agent reads your entire codebase - files, dependencies, Git state, configs- so it works with real context instead of guessing. 🔹 Prompt Structure & Cache Reuse Separates stable instructions from dynamic inputs, reuses context, and reduces token usage for faster, consistent responses. 🔹 Tool Access & Execution This is where things get powerful- running code, reading files, executing commands, and interacting with real systems. 🔹 Context Optimization Filters out noise by trimming logs, removing duplicates, and prioritizing relevant information. 🔹 Structured Memory System Remembers past steps, tasks, and decisions- enabling long, multi-step workflows without losing context. 🔹 Subagents & Delegation Breaks complex tasks into smaller ones, handled in parallel by specialized agents for speed and scalability. Put all of this together… and you’re not just interacting with a model. You’re working with a system that can: → Understand your codebase → Plan tasks step-by-step → Execute real actions → Remember context across sessions → Solve complex problems efficiently The biggest shift? Moving from “Ask AI a question” to “Collaborate with an AI system.” Because this is where things are heading, AI agents that don’t just assist… They operate inside your workflow like an actual developer.
-
Your AI coding agent is burning tokens on garbage. (and you're paying for every single one) Run a git status. 200 tokens. Run npm install. 3,000 tokens. Read a file you already read two prompts ago. Full price again. Nobody talks about this. Everyone optimizes prompts. Nobody optimizes what the agent actually reads between prompts. Shell output is the silent token sink in agentic loops. A single cargo build dumps thousands of tokens into the context window. Most of it is noise. Progress bars, warnings, paths your agent will never use. lean-ctx fixes this by sitting between your agent and your codebase. It compresses everything before it hits the model. Here's how it works: 1) Shell output compression - 95+ patterns for git, npm, cargo, docker, and more - Strips the noise, keeps the signal - A 3,000 token npm install becomes a handful of useful lines 2) Smart file reads with 10 modes - full, map, signatures, diff, and more - Cached re-reads cost ~13 tokens instead of reading the whole file again - 60-95% token reduction on file reads, up to 99% on cache hits 3) Property graph for file ranking - Builds a multi-edge code graph: imports, calls, exports, type references - Ranks files by actual impact, not just embedding similarity - BM25 + embeddings + graph proximity layered together 4) Session memory - Persists tasks, facts, and decisions across chat sessions - Your agent doesn't start from zero every conversation Works with 27 agents out of the box. Cursor, Claude Code, Copilot, Windsurf, Codex, Gemini, and more. Single Rust binary. One install command. The math is simple. Fewer tokens per loop means more loops before you hit the context ceiling. More loops means harder problems solved without the agent losing its thread. Link in the comments. I'm Shrey Shah & I teach AI assisted coding and agents.
-
Agent-assisted coding transformed my workflow. Most folks aren’t getting the full value from coding agents—mainly because there’s not much knowledge sharing yet. Curious how to unlock more productivity with AI agents? Here’s what’s worked for me. After months of experimenting with coding agents, I’ve noticed that while many people use them, there’s little shared guidance on how to get the most out of them. I’ve picked up a few patterns that consistently boost my productivity and code quality. Iterating 2-3 times on a detailed plan with my AI assistant before writing any code has saved me countless hours of rework. Start with a detailed plan—work with your AI to outline implementation, testing, and documentation before coding. Iterate on this plan until it’s crystal clear. Ask your agent to write docs and tests first. This sets clear requirements and leads to better code. Create an "AGENTS.md" file in your repo. It’s the AI’s university—store all project-specific instructions there for consistent results. Control the agent’s pace. Ask it to walk you through changes step by step, so you’re never overwhelmed by a massive diff. Let agents use CLI tools directly, and encourage them to write temporary scripts to validate their own code. This saves time and reduces context switching. Build your own productivity tools—custom scripts, aliases, and hooks compound efficiency over time. If you’re exploring agent-assisted programming, I’d love to hear your experiences! Check out my full write-up for more actionable tips: https://lnkd.in/eSZStXUe What’s one pattern or tool that’s made your AI-assisted coding more productive? #ai #programming #productivity #softwaredevelopment #automation
-
A lot of people say that AI agents don't work well on large legacy codebases. That's false. Over the last eight months, I've been successfully using AI agents to clean up massive portions of legacy tech debt in a very large Java and Kotlin codebase that's over 10 years old and used by millions of people. It works. You just have to set up the prompt and engineer the context management correctly. The prompts I use have been iterated on for quite a while. I create one, test it out, find some edge cases I missed, undo the changes, and try again. I do this while performing other work, so it's done in parallel. Ultimately, the prompt typically ends up anywhere from around 800 words to over 2,000 words long. It's a basic full-on manual of how to perform some type of tech debt migration. This has been further expanded by other skills that I have developed. The agent will call into them when it needs to perform certain actions or determines that it is not ready to perform a particular operation because of another dependency. So they maintain their own context window. Done correctly and at the right level, you will have presented the agent with a set of instructions that is a full decision matrix. This covers how to successfully dissect, update, and migrate from one technology to another—all with full guardrails, verification, and more. The majority of pull requests I have opened with these agents are nearly impossible to identify as having been written by an agent. They follow proper standards, protocols, and implementation details that our team has dictated. This is enforced through deterministic methods such as linting, testing, verification, and sub-agents that do additional verification before completing. Finally, when the agent is complete and everything is working, I will open the pull request in a draft state and manually review it there. Once I'm happy with it, I'll transition it to a pull request that's ready to be reviewed. Then, additional AI agent reviewers will perform another set of analysis on top of that, along with a human reviewer.
-
𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝘄𝗶𝘁𝗵 𝗔𝗜 𝗖𝗼𝗱𝗶𝗻𝗴 𝗧𝗼𝗱𝗮𝘆: You prompt → AI writes code → You ship → You start from zero. Every. Single. Time. This is why most developers plateau. They treat AI like chat bots. Top performers do something different: 𝗖𝗼𝗺𝗽𝗼𝘂𝗻𝗱 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴. ━━━━━━━━━━━━━━━━━━━━ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? Building AI systems with memory. → Every PR educates the system → Every bug becomes a permanent lesson → Every code review updates agent behavior Regular AI coding makes you productive 𝘁𝗼𝗱𝗮𝘆. Compound Engineering makes you better 𝗲𝘃𝗲𝗿𝘆 𝗱𝗮𝘆 𝗮𝗳𝘁𝗲𝗿. ━━━━━━━━━━━━━━━━━━━━ 𝟰 𝗔𝗰𝘁𝗶𝗼𝗻𝘀 𝘁𝗼 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁: 𝟭. 𝗖𝗼𝗱𝗶𝗳𝘆 𝗬𝗼𝘂𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲 Create AGENTS.md or .cursorrules in your repo. Document patterns, pitfalls, and PR references. This becomes your AI's "onboarding doc." 𝟮. 𝗠𝗮𝗸𝗲 𝗕𝘂𝗴𝘀 𝗣𝗮𝘆 𝗗𝗶𝘃𝗶𝗱𝗲𝗻𝗱𝘀 When fixing bugs, ask: Can a lint rule prevent this? Should AGENTS.md document it? A true fix ensures the agent never repeats it. 𝟯. 𝗘𝘅𝘁𝗿𝗮𝗰𝘁 𝗥𝗲𝘃𝗶𝗲𝘄 𝗣𝗮𝘁𝘁𝗲𝗿𝗻𝘀 Every review comment is a potential system upgrade. Turn feedback into reusable standards the agent auto-applies. 𝟰. 𝗕𝘂𝗶𝗹𝗱 𝗥𝗲𝘂𝘀𝗮𝗯𝗹𝗲 𝗪𝗼𝗿𝗸𝗳𝗹𝗼𝘄𝘀 Document task sequences. Next time: "Follow the add API endpoint workflow." The system already knows what to do. ━━━━━━━━━━━━━━━━━━━━ 𝗧𝗵𝗲 𝗖𝗼𝗺𝗽𝗼𝘂𝗻𝗱 𝗘𝗳𝗳𝗲𝗰𝘁 Imagine the AI saying: "Naming updated per PR #234. Over-testing removed per PR #219 feedback." It learned your taste—like a smart colleague with receipts. ━━━━━━━━━━━━━━━━━━━━ 𝗧𝗵𝗲 𝗟𝗲𝘃𝗲𝗿𝗮𝗴𝗲 𝗛𝗶𝗲𝗿𝗮𝗿𝗰𝗵𝘆 Bad code = one line affected Bad AGENTS.md instruction = 𝗲𝘃𝗲𝗿𝘆 𝘀𝗲𝘀𝘀𝗶𝗼𝗻 affected Treat agent config like production code. Highest-ROI investment you can make. ━━━━━━━━━━━━━━━━━━━━ Stop treating AI interactions as disposable. Start treating them as investments. That's how you go from "AI User" to "𝗔𝗜 𝗠𝘂𝗹𝘁𝗶𝗽𝗹𝗶𝗲𝗿." What's one pattern you've compounded into your AI workflow? 👇 #AgenticCoding #SoftwareEngineering #TechLeadership #GenAI #DeveloperProductivity
Explore categories
- Hospitality & Tourism
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Employee Experience
- Healthcare
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Career
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development