Clone & Summarize
Clone a public GitHub repo, read the diffs of the last 10 commits, and have the agent write its own code review — all from a single prompt.
What you'll build
A 20-line script that clones t3code inside a cloud sandbox, reads the actual diffs with git log -p, and downloads a markdown review to your machine.
The Script
Create a file called repo.ts:
typescript
import { createClient } from "swarmlord";
import { writeFileSync, mkdirSync } from "fs";
// prepare
const client = createClient({ apiKey: process.env.SWARMLORD_API_KEY! });
const session = await client.agent("build").createSession();
// run agent
await session.send(
"Clone https://github.com/pingdotgg/t3code into /workspace/repo. Read the diffs of the last 10 commits to main using git log -p. Write your own review and summary of the changes to /workspace/summary.md. Once you are done, let me know.",
{ onText: delta => process.stdout.write(delta) }
);
// download artifacts
mkdirSync("output", { recursive: true });
const summary = await session.getFile("/workspace/summary.md");
writeFileSync("output/summary.md", summary);
console.log("\nDownloaded output/summary.md");
await session.end();Run It
bash
export SWARMLORD_API_KEY="your-key-here"
bun repo.tsThe agent streams its work in real-time — running git clone, inspecting the diffs with git log -p, and writing a structured review. When it finishes, output/summary.md lands on your local disk.
Output
This is the actual summary.md produced by the script above:
markdown
# Review and Summary of Recent Changes in T3 Code
## Summary of Changes
### 1. Configurable Base Directory and Path Derivation
- **Key Change:** Introduced `T3CODE_HOME` to replace or augment `T3CODE_STATE_DIR`.
- **Details:** The system now derives all operational paths (state, database, logs,
worktrees, attachments) from a single base directory.
- **Impact:** Simplifies configuration and ensures consistency across components.
### 2. Refactoring with Effect TS
- **Key Change:** Significant migration of side-effecting code to use the Effect library.
- **Details:** Replaced standard fs and path modules with FileSystem and Path services
from @effect/platform.
- **Impact:** Improved testability, error handling, and resource management.
### 3. Attachment Handling Improvements
- **Key Change:** Refactored how attachments are resolved and stored.
- **Details:** Changed resolveAttachmentPath to accept an attachmentsDir instead of a
general stateDir.
- **Impact:** Better separation of concerns and more robust file resolution.
## Review and Observations
- **Architecture:** The project is leaning heavily into Functional Programming patterns
using Effect. This provides strong typing for errors and dependencies but increases
the learning curve for new contributors.
- **Code Quality:** Moving path derivation into a centralized deriveServerPaths function
reduces duplication and potential bugs.
- **Testing:** The use of scoped temporary directories in tests is a great practice,
ensuring artifacts don't pollute the developer's machine or CI.How It Works
| Step | What happens |
|---|---|
createClient | Authenticates with the swarmlord API |
agent("build").createSession() | Spins up a session with a Linux sandbox and all tools enabled |
session.send(prompt) | The agent invokes the shell tool to git clone and git log -p, reads the diffs, then writes a review using the write tool |
getFile | Downloads the text file from the sandbox to your machine |
session.end() | Cleans up the session and its sandbox |
Swap in any repo
Replace the GitHub URL in the prompt with any public repository. The agent handles authentication-free clones, branch detection, and diff analysis automatically.