Building Autonomous AI Agent Loops: A Hands-Off Approach to Development
When coding with AI, manually specifying what to do and how to do each task can become quite tedious. Recently, I’ve noticed more people experimenting with looping AI agents where they let the AI handle everything autonomously. I tried this approach myself the other day using Claude Code Max, but since the application was quite large and token costs were adding up, I decided to build a new application using Gemini CLI instead. That larger application is now about 60% complete, and I’ll share it once it’s finished.
You can view the application demo here.
While building this larger application, I gained valuable experience and began thinking about a different approach with Gemini. After switching approaches, I discovered a more systematic and accurate method.
Here’s my thinking: When a customer wants software, they approach a software company. The company asks clarifying questions like “do you want it this way or that way?” and the customer responds. Then development begins. After that, the cycle repeats. When having AI do the work, I considered whether the back-and-forth of asking and answering about requirements should also be handled by AI or done manually. Currently, I’ve concluded that this Q&A process should be done with AI. Otherwise, I’m concerned the AI might produce something that’s not what I actually want. In the future though, I might try letting the AI decide what it thinks is best without asking for requirements first.

So I started interviewing Gemini using this approach to understand requirements before having it code the solution.
Below is what I wrote – it’s very much a draft. I also created a custom slash command for the Gemini CLI interview process.
I want to build a personal news website, where user can add rss feeds. Then system crawl and stored. Summarized and stored. User can see the news feeds all summarize. He is interested he can read the original article. I want it to use llm to summarize it. User should be able to choose the summarize in which language as well. For crawler, I want to use like firecrawl. For the LLM I am planning to use openrouter and some free models from there. User can set it up.
user register
user login
user see news feeds (summarized one)
user can add news rss feed
- it automatically get news from rss
- summarize using LLM openrouter - Open router key - sk-or-v1- for the models search https://openrouter.ai/models?fmt=cards&input_modalities=text&order=pricing-low-to-high&max_price=0 free models and use those.
- user can go in detail of the articles/news
- use firecrawl for crawling
- user can search
settings
- user can adjust most of the stuff there
I want you to develop in fullstack bun app.
Backend bun, hono, meilisearch, psql, https://github.com/kysely-org/kysely for query builder.
Frontend bun, vite, react, shardcn, tailwind, etc... must be modern, minimalist
use docker
- respect the existing ports in the system and don't stop them. Check available ports and use those.
I also created a custom slash command for the Gemini CLI interview.
[command]
name = "user-interview"
description = "Interview user about a project plan and generate spec"
prompt = """
You are an expert software architect and spec writer. The user's initial project description/plan is: $ARG
Your task: Conduct a detailed, in-depth interview with me about this plan. Ask probing, non-obvious questions about technical implementation details (e.g., specific APIs, error handling), architecture decisions (e.g., monolith vs. microservices), UI/UX tradeoffs (e.g., responsive design edge cases), edge cases (e.g., offline mode, high traffic), performance concerns, security implications (e.g., API key storage), scalability, maintainability, testing strategy (e.g., TDD vs. integration), dependencies (e.g., Firecrawl for RSS crawling, OpenRouter for LLM), alternatives considered, potential risks, features you might suggest (e.g., user notifications, search filtering), and any blind spots.
Be thorough and continue asking questions across multiple turns until you have gathered enough information to create a complete, professional specification. Do not ask obvious questions—focus on deep, insightful ones that reveal hidden assumptions or improvements.
Use Gemini CLI's built-in tools if needed (e.g., web search for tech refs, file write at the end).
Once confident the plan is fully fleshed out (only after sufficient back-and-forth), output the final spec in Markdown format with sections like: Overview, Requirements, Functional Specs, Technical Architecture (e.g., stack: Node.js/Python? Docker?), Components (e.g., RSS crawler with Firecrawl, LLM summarization via OpenRouter), UI/UX (e.g., language selection), Data Flow, Database (e.g., storage for summaries), Error Handling, Security, Testing (unit, E2E with Playwright), Deployment (e.g., Docker), and Roadmap.
Then, use the file_write tool to save it as .loop/plan.md in the current working directory. End your response with: 'Interview complete. Spec written to .loop/plan.md.'
"""
parameters = ["ARG"] # Supports one argument: your project description
After answering the questions, Gemini generated the plan and created it as .loop/plan.md in the project directory. I also created agent-loop.sh in the project root and ran it.
#!/bin/bash
# Set your project directory (update if needed)
PROJECT_DIR="/Users/setkyar/ygncode-lab/news/"
LOOP_DIR="$PROJECT_DIR/.loop"
MODEL="gemini-3-flash-preview"
mkdir -p "$LOOP_DIR" # Create .loop if it doesn't exist
cd "$PROJECT_DIR" || exit 1
while true; do
echo "Starting a new agent loop iteration..."
# Agent picks and does ONE task
gemini --model $MODEL --yolo -p "
READ $LOOP_DIR/plan.md and $LOOP_DIR/change-log.md.
plan.md is our end goal for the project. $LOOP_DIR/change-log.md is the changelog of what has been done so far and actively updated by you.
$LOOP_DIR/tasks.md contains a list of tasks that need to be done/completed for the project and it's actively updated by you.
Pick ONE task from $LOOP_DIR/tasks.md. Make sure to write unit/tests, E2E with Playwright and take screenshot and improve/verify.
Commit and push changes using git (via shell tool). ONLY do one task.
After you finish the task, update $LOOP_DIR/tasks.md and $LOOP_DIR/change-log.md accordingly."
echo "Agent loop iteration completed."
# Check if tasks remain
RESPONSE=$(gemini --model $MODEL --yolo -p "check if there are any new tasks in $LOOP_DIR/tasks.md that need to be done for the project.
If there are no new tasks left, output exactly 'true' (no quotes or extras), else output exactly 'false'.")
if [[ "$RESPONSE" == "true" ]]; then
echo "No tasks left. Generating new tasks..."
gemini --model $MODEL --yolo -p "check $LOOP_DIR/plan.md and our codebase. And see what we are missing and create/update tasks.md inside $LOOP_DIR with a prioritized list of new tasks (e.g., implement features, fix bugs, deploy)."
echo "New tasks generated. Continuing agent loop..."
else
echo "Tasks remain. Continuing to next iteration..."
sleep 2
fi
# Optional: Final check if fully done (e.g., after multiple generations, no more tasks)
FINAL_CHECK=$(gemini --model $MODEL --yolo -p "Review $LOOP_DIR/plan.md, codebase, and $LOOP_DIR/tasks.md. If the full app is complete (all features built, tested, deployable), output 'done'.")
if [[ "$FINAL_CHECK" == "done" ]]; then
echo "Full app complete! Exiting loop."
break
fi
done
While there are still improvements needed, I wanted to try it out so I went with this script for now. I think it can be modified as needed – for example, adding code review, refactoring, or using different AI models. I’ll try implementing these kinds of enhancements in the future.

This represents my current hands-off approach to experimenting with autonomous AI agent loops. By combining intelligent requirement gathering through AI interviews with automated development cycles, I’ve found a more systematic way to leverage AI for software development. The approach is still evolving, but the early results are promising. If you’re interested in exploring autonomous AI development workflows, I encourage you to give this approach a try and adapt it to your own needs. Feel free to experiment with the concepts shared here and see how they can improve your development process.
Note: This post was originally written in Myanmar language and translated to English with the assistance of Claude (Anthropic). Claude helped with translation, content structure improvements, and enhancing both the title and conclusion to make the content more accessible to an international audience.