AI News Hub Logo

AI News Hub

Claude Managed Agents - How to Build a GitHub Repo Review Agent

DEV Community
Jayakumar Ramalingam

Creating an AI agent almost always requires much more than crafting a prompt. A model, infrastructure, execution logic, runtime, and hosting are typically required. That is where Claude Managed Agents transform the game. By leaving the responsibility of the orchestration layer up to the Claude team, you can define the agent’s behavior by crafting prompts, providing tools, and establishing constraints. Then the Anthropic managed cloud runtime will take care of the execution session, execution environment, and many other aspects of the orchestration. As an example, we’re going to create a GitHub Repository Review Agent that will check out a given repository, analyze its source code and documentation, find any possible problems, and generate a useful Markdown report based on that analysis. What is important here, is that this approach puts the focus on prompts and behavior rather than infrastructure. When using a typical agent architecture, there is always the need for you to implement or adapt an orchestration mechanism, integrate calls to various tools, deal with the runtime infrastructure, make decisions on where the agent will be hosted, handle concurrent execution, consider file handling, and establish streaming methods for delivering results to users. Claude Managed Agents takes care of many of those aspects in its managed environment. Instead of spending most of your time building scaffolding, you spend more time defining: what the agent should do what tools it can use what environment it should run in what output you want it to produce That is the real shift. It is still engineering, but it is a more prompt-first and behavior-first development model. We’ll create a workflow that does the following: mounts a GitHub repository into a managed session inspects repository structure, docs, and code layout identifies architecture smells and risk areas writes a Markdown report with a prioritized 30-day action plan You need: Python 3.10+ an Anthropic API key the anthropic Python package a GitHub token if you want to mount a private repository pip install anthropic The environment is the managed cloud container template where your session runs. It is where networking rules, packages, and mounted resources are controlled. Here is a simple environment: import anthropic client = anthropic.Anthropic() environment = client.beta.environments.create( name="repo-review-env", config={ "type": "cloud", "networking": { "type": "unrestricted" }, }, ) print(environment.id) For real usage, I would usually tighten the network rules instead of leaving them fully open. A more controlled version might look like this: environment = client.beta.environments.create( name="repo-review-env-locked-down", config={ "type": "cloud", "networking": { "type": "limited", "allowed_hosts": [ "api.github.com", "raw.githubusercontent.com" ], }, }, ) This is where the managed model becomes much clearer. Instead of building the full runtime loop yourself, you mainly define the behavior you want. agent = client.beta.agents.create( name="Repository Review Agent", model="claude-opus-4-7", // any model like sonnet etc system=""" You are a senior software architect performing an initial engineering review. Your job: 1. Inspect the repository structure, documentation, and key code paths. 2. Identify architecture smells, risky areas, missing docs, and maintainability issues. 3. Distinguish between critical issues, medium-priority improvements, and optional cleanup. 4. Create a file at /mnt/session/outputs/review_report.md. The report must contain: - Executive summary - Repository structure overview - Risk areas - Documentation gaps - Suggested refactors - A prioritized 30-day action plan Be practical. Do not invent facts. Base findings only on the repository contents. """, tools=[ { "type": "agent_toolset_20260401", "default_config": {"enabled": True} } ], ) print(agent.id, agent.version) This is one of the biggest differences with Claude Managed Agents. You define the model, prompt, tools, and expected behavior, and the platform handles the managed runtime side. Now we start a session and mount a GitHub repository into it. import os session = client.beta.sessions.create( agent={"type": "agent", "id": agent.id, "version": agent.version}, environment_id=environment.id, title="Initial architecture review", resources=[ { "type": "github_repository", "url": "https://github.com/owner/repo", "mount_path": "/workspace/repo", "authorization_token": os.environ["GITHUB_TOKEN"], "branch": "main", } ], ) print(session.id, session.status) At this point, the main infrastructure concern is no longer “where do I deploy this agent?” The session is already running inside the managed environment. Next, we stream the session and send the task. with client.beta.sessions.stream(session_id=session.id) as stream: client.beta.sessions.events.send( session_id=session.id, events=[ { "type": "user.message", "content": [ { "type": "text", "text": """ Review the mounted repository at /workspace/repo. Focus on: - architecture and module boundaries - signs of tight coupling - test coverage clues - configuration and secrets handling - developer experience issues - the highest-value improvements for the next 30 days Write the final report to /mnt/session/outputs/review_report.md """ } ], } ], ) for event in stream: if event.type == "agent.message": for block in event.content: if block.type == "text": print(block.text, end="", flush=True) elif event.type == "session.status_idle": print("\n--- Agent finished ---") break elif event.type == "session.status_terminated": print("\n--- Session terminated ---") break This is where the workflow starts to feel different from a typical DIY agent setup. You are not building a custom orchestration loop with your own runtime machinery. You are giving the Claude Managed Agent a task and letting the managed system execute it. Once the session is done, we can download the Markdown file the agent created. import time time.sleep(2) files = client.beta.files.list( scope_id=session.id, betas=["managed-agents-2026-04-01"], ) for f in files.data: print(f.filename, f.size_bytes) if f.filename == "review_report.md": content = client.beta.files.download(f.id) content.write_to_file("review_report.md") print("Saved review_report.md locally") Now you have a report generated by the agent inside the managed environment. Full example When using Claude Managed Agents, you will still need to design your agent with all its considerations related to prompts, tools, capabilities, and outputs. However, there is no longer as much work in the runtime layer as before. This is the change in focus: less time spent on setting up the runtime environment less concern regarding the necessary infrastructure less trouble trying to manage the scalability of your own agent loop more attention to getting the right behavior out of the box In a production system, I would not initialize the environment and agent on each request. This should be done only once, then the same object should be used, and both should be carefully versioned with prompt and network access minimized. I would also use a secure application layer in front of my workflow and not expose it directly. "Managed" does not mean there is no architecture here. It only means it is raised to a new level. Claude Managed Agents are intriguing because they shift the developer's focus from implementation details to the behavior and outcome. While you could spend a lot of time building the runtime for your own purposes, Managed Agents offer an easy way to focus solely on modeling what you are looking for: the model, prompt, tools, and the environment – with everything else taken care of by a managed system that runs your agent inside.