<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Samir Sobhy</title>
    <description>The latest articles on DEV Community by Samir Sobhy (@aicodesmart).</description>
    <link>https://dev.to/aicodesmart</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4110276%2Fae59f938-161f-4de2-861c-43cd6c38044f.png</url>
      <title>DEV Community: Samir Sobhy</title>
      <link>https://dev.to/aicodesmart</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aicodesmart"/>
    <language>en</language>
    <item>
      <title>How to Prompt Coding Agents Without Losing Control of Your Codebase</title>
      <dc:creator>Samir Sobhy</dc:creator>
      <pubDate>Tue, 08 Sep 2026 18:46:14 +0000</pubDate>
      <link>https://dev.to/aicodesmart/how-to-prompt-coding-agents-without-losing-control-of-your-codebase-1afi</link>
      <guid>https://dev.to/aicodesmart/how-to-prompt-coding-agents-without-losing-control-of-your-codebase-1afi</guid>
      <description>&lt;p&gt;Coding agents become much more useful when you stop treating the prompt as a request for code and start treating it as a specification for a change.&lt;/p&gt;

&lt;p&gt;A request such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fix the login problem.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;contains almost none of the information required to review the resulting implementation.&lt;/p&gt;

&lt;p&gt;Which login problem?&lt;/p&gt;

&lt;p&gt;Which files may change?&lt;/p&gt;

&lt;p&gt;What behavior must remain unchanged?&lt;/p&gt;

&lt;p&gt;How will we know the fix actually works?&lt;/p&gt;

&lt;p&gt;For work inside an existing repository, a simple four-part framework is usually more useful:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task → Context → Scope → Acceptance Criteria&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Task: define observable behavior
&lt;/h2&gt;

&lt;p&gt;Start with the smallest useful description of what should change.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Add filtering.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Task:
Add a Completed / Incomplete filter to the task-list page.

Expected behavior:
- "Completed" shows only completed tasks.
- "Incomplete" shows only incomplete tasks.
- "All" remains the default.
- The filter must work together with the existing text search.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent now has a behavior to implement instead of a vague direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Context: make the repository part of the prompt
&lt;/h2&gt;

&lt;p&gt;You usually do not need to paste half the codebase.&lt;/p&gt;

&lt;p&gt;Ask the agent to inspect the relevant project files first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context:
- Read src/components/TaskList.tsx.
- Read src/hooks/useTasks.ts.
- Follow the patterns already used by the project.
- Check the project's existing instructions before making changes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal is not to dictate the implementation.&lt;/p&gt;

&lt;p&gt;The goal is to make the agent learn the local conventions before inventing new ones.&lt;/p&gt;

&lt;p&gt;Permanent conventions are better stored in project-level instructions when your coding tool supports them.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Use the package manager already configured in the repository.
- Do not edit generated files.
- Discover validation commands from project configuration.
- Preserve unrelated changes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps individual prompts focused on the task.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Scope: control the size of the diff
&lt;/h2&gt;

&lt;p&gt;A coding agent can solve the right problem in the wrong way.&lt;/p&gt;

&lt;p&gt;One common failure mode is unnecessary expansion of scope: changing an API, introducing another dependency, restructuring adjacent modules, or “cleaning up” unrelated code.&lt;/p&gt;

&lt;p&gt;Explicit constraints reduce that risk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scope:
- Modify only src/components/ and src/hooks/.
- Do not change the backend API.
- Do not add a dependency without asking.
- Do not refactor unrelated code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This has another benefit: smaller diffs are easier for humans to review.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Acceptance criteria: make verification part of the task
&lt;/h2&gt;

&lt;p&gt;“Make sure it works” is not an acceptance criterion.&lt;/p&gt;

&lt;p&gt;Use an observable check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Acceptance criteria:
- Existing task-list behavior still works.
- Filtering and text search work simultaneously.
- Add a test for the combined behavior if this project has automated tests.
- Run the relevant validation command.
- If the command is unknown, inspect project configuration instead of guessing.
- If validation cannot be run, say so explicitly.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last two lines matter.&lt;/p&gt;

&lt;p&gt;An agent should not infer that a repository uses &lt;code&gt;npm test&lt;/code&gt;, &lt;code&gt;pytest&lt;/code&gt;, &lt;code&gt;cargo test&lt;/code&gt;, or any other command purely because that command is common.&lt;/p&gt;

&lt;p&gt;Let the repository define the verification process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging requires evidence
&lt;/h2&gt;

&lt;p&gt;A bug-fixing prompt should give the agent enough information to distinguish a diagnosis from a guess.&lt;/p&gt;

&lt;p&gt;A useful shape is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Problem:
[What the user sees]

Steps to reproduce:
1. [...]
2. [...]
3. [...]

Expected:
[...]

Actual:
[...]

Evidence:
[error message or relevant log]

Task:
Identify the most likely root cause from the code and evidence.
If the cause cannot be confirmed, state what information is missing.
Apply the smallest change that addresses the root cause.
Run the relevant checks afterward.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important sentence is not “fix the bug.”&lt;/p&gt;

&lt;p&gt;It is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identify the root cause from the available evidence.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That discourages patches that merely hide the symptom.&lt;/p&gt;

&lt;h2&gt;
  
  
  Refactoring needs the opposite constraint
&lt;/h2&gt;

&lt;p&gt;A refactoring prompt is different because the goal is internal change without external change.&lt;/p&gt;

&lt;p&gt;Define what must remain invariant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal:
Refactor [module] without changing observable behavior.

Must remain unchanged:
- Public API.
- Existing outputs.
- Known edge-case behavior.
- Existing tests.

Allowed changes:
- Internal organization.
- Function extraction.
- Naming.
- Removing duplication.
- Simplifying conditions.

Do not:
- Add features.
- Fix unrelated bugs.
- Change tests merely to make the refactor pass.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the distinction between “better internals” and “different software” explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature, bug fix, and refactor are three different conversations
&lt;/h2&gt;

&lt;p&gt;A useful mental model is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature work:&lt;/strong&gt; specify the new behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug fixing:&lt;/strong&gt; specify the evidence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring:&lt;/strong&gt; specify the invariants.&lt;/p&gt;

&lt;p&gt;All three still need scope and verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  The final prompt should request a report
&lt;/h2&gt;

&lt;p&gt;After the change, ask the agent to return something short and auditable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When finished, report:
1. Files changed.
2. What changed.
3. Validation commands actually executed.
4. Results.
5. Any assumption you had to make.
6. Anything you could not verify.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is more useful than asking for a long description of the model's internal reasoning.&lt;/p&gt;

&lt;p&gt;You want evidence about the work product.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt quality is not prompt length
&lt;/h2&gt;

&lt;p&gt;The best coding prompt is not necessarily the longest one.&lt;/p&gt;

&lt;p&gt;A 500-word prompt with no acceptance criteria can still produce a risky change.&lt;/p&gt;

&lt;p&gt;A much shorter prompt containing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a precise task,&lt;/li&gt;
&lt;li&gt;relevant context,&lt;/li&gt;
&lt;li&gt;strict scope,&lt;/li&gt;
&lt;li&gt;and a real verification method&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;can be substantially easier to trust.&lt;/p&gt;

&lt;p&gt;Coding agents do not remove the need for review.&lt;/p&gt;

&lt;p&gt;They make it more important to define what should be reviewed.&lt;/p&gt;

&lt;p&gt;The practical goal is therefore not to write a “perfect AI prompt.”&lt;/p&gt;

&lt;p&gt;It is to create a task that is &lt;strong&gt;constrained enough to implement and specific enough to verify&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;Full Arabic guide and reusable prompt templates: &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[[AICodeSmart](https://www.aicodesmart.com/cursor-claude-code-prompts/)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>agents</category>
      <category>coding</category>
      <category>llm</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>From LLM to AI Agent: What Actually Happens When an Agent Uses a Tool?</title>
      <dc:creator>Samir Sobhy</dc:creator>
      <pubDate>Fri, 04 Sep 2026 19:20:55 +0000</pubDate>
      <link>https://dev.to/aicodesmart/from-llm-to-ai-agent-what-actually-happens-when-an-agent-uses-a-tool-4pp9</link>
      <guid>https://dev.to/aicodesmart/from-llm-to-ai-agent-what-actually-happens-when-an-agent-uses-a-tool-4pp9</guid>
      <description>&lt;p&gt;An LLM can generate an answer.&lt;/p&gt;

&lt;p&gt;But an AI Agent needs to do something beyond generating text.&lt;/p&gt;

&lt;p&gt;The important distinction is the layer around the model:&lt;/p&gt;

&lt;p&gt;LLM → Instructions → Tools → State/Memory → Permissions → Control Loop&lt;/p&gt;

&lt;p&gt;For example, imagine an agent that needs to retrieve the current weather.&lt;/p&gt;

&lt;p&gt;The LLM itself does not magically call the weather API.&lt;/p&gt;

&lt;p&gt;A typical flow looks like this:&lt;/p&gt;

&lt;p&gt;The application defines an available tool.&lt;br&gt;
The model decides that the tool is required.&lt;br&gt;
The model returns a structured tool call.&lt;br&gt;
The application executes the actual API request.&lt;br&gt;
The API result is returned to the model.&lt;br&gt;
The agent evaluates the result.&lt;br&gt;
It either finishes the task or chooses another action.&lt;br&gt;
So the architecture is closer to:&lt;/p&gt;

&lt;p&gt;User&lt;br&gt;
  ↓&lt;br&gt;
Goal + Instructions + Context&lt;br&gt;
  ↓&lt;br&gt;
AI Agent&lt;br&gt;
  ↓&lt;br&gt;
LLM chooses next action&lt;br&gt;
  ↓&lt;br&gt;
Tool required?&lt;br&gt;
  ├── No → Continue / Finish&lt;br&gt;
  │&lt;br&gt;
  └── Yes&lt;br&gt;
       ↓&lt;br&gt;
     Tool / API&lt;br&gt;
       ↓&lt;br&gt;
    Observation&lt;br&gt;
       ↓&lt;br&gt;
   Agent evaluates result&lt;br&gt;
       ↓&lt;br&gt;
 Next action / Final answer&lt;/p&gt;

&lt;p&gt;This is also why I would not start every project by building a sophisticated autonomous agent.&lt;/p&gt;

&lt;p&gt;If the workflow is predictable, a traditional workflow can be simpler,cheaper, and easier to debug.&lt;/p&gt;

&lt;p&gt;Use an Agent when the path itself needs to change according to the context and the results of previous actions.&lt;/p&gt;

&lt;p&gt;Another important engineering decision is permissions.&lt;/p&gt;

&lt;p&gt;If an agent can send emails, modify records, access databases, or trigger external APIs, its capabilities should be limited to what the task actually requires.&lt;/p&gt;

&lt;p&gt;For production systems, I would also consider:&lt;/p&gt;

&lt;p&gt;Maximum iterations&lt;br&gt;
Execution timeouts&lt;br&gt;
Tool failure handling&lt;br&gt;
Logging&lt;br&gt;
Human approval for sensitive actions&lt;br&gt;
Cost limits&lt;br&gt;
Prompt-injection defenses&lt;/p&gt;

&lt;p&gt;The interesting part of AI Agents isn't simply giving an LLM more tools.&lt;/p&gt;

&lt;p&gt;It's designing the system around the model so that decision → action → observation → next decision happens safely and predictably.&lt;/p&gt;

&lt;p&gt;I wrote a practical Arabic guide covering the architecture, Agent vs Workflow, Single-Agent vs Multi-Agent, Function Calling, Python/CrewAI, testing, cost, and security:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.aicodesmart.com/ai-agents-explained-how-to-build/" rel="noopener noreferrer"&gt;https://www.aicodesmart.com/ai-agents-explained-how-to-build/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Developer takeaway:&lt;br&gt;
Don't ask "How can I make this an Agent?" first.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;p&gt;"Does this problem actually require dynamic decision-making?"&lt;/p&gt;

&lt;h1&gt;
  
  
  ai #programming #agents #python #automation
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
      <category>api</category>
    </item>
  </channel>
</rss>
