Mycroft: From CLI to API
Humanitarians AI Fellow Aishwarya Patil turns the patent agent CLI into a callable web API that reuses the already-verified Claims and Lineage Agents. A git mistake briefly cost an uncommitted file, and the video explains what went wrong and what protected the work.
This video follows Humanitarians AI Fellow Aishwarya Patil as she turns the patent agent command-line tool into a real, callable web API. It also covers a genuine git mistake: one new file went missing after a single git command, not because the code was wrong, but because it had never been committed. The video explains the API design, how the file was recovered and the simple habit that would have avoided the problem.
Why an API and not just the CLI
The command-line interface works, but only from a terminal. A real HTTP endpoint changes who can use the tool. Any client, whether a browser, a frontend or another service, can ask for a patent reading the same way, without shelling out to Python directly. The API is what makes the patent agent reachable by other software.
Wrapping the same verified logic
The API does not reimplement anything. It is one route that takes one publication number and calls the same claims agent and lineage agent that had already been tested through the command line, in the same way. A classify flag mirrors the purpose of the CLI's no-classify option, so a caller can skip the one step that always costs something real. Because the logic is shared, the work already done to verify the agents carries over to the new interface.
The mistake
Midway through the build, a git pull failed because the branches had diverged after a forced update on the remote. Fixing that meant resetting the local main branch and rebasing the work branch on top of it. The rebase succeeded, but the new file did not survive. It had been staged but not committed, and switching branches during the fix wiped it out. Git gave no warning.
What actually protected the work
The file was not lost for good because the same content still existed locally, outside git, from building and testing it a few minutes earlier. She recreated it, committed it immediately this time, and verified it again against the same two real patents that had already confirmed the command-line version was correct. The recovery depended on a copy outside version control and on re-running a known check, not on git itself.
A second find while fixing the first
Checking the readme before committing turned up something unrelated. An earlier update documenting the lineage agent's broader testing had never made it into the main branch at all. That documentation gap was fixed in the same pass instead of being left for later.
Key takeaways
- A command-line tool only works from a terminal; an HTTP endpoint lets browsers, frontends and other services use it.
- The API wraps the already-tested claims and lineage agents instead of reimplementing them.
- A classify flag in the API serves the same purpose as the CLI's no-classify option.
- A staged but uncommitted file can disappear when you switch branches or reset, and git will not warn you.
- Commit new work immediately.
- Re-verify recovered work against the same known test cases.
- Reading the readme before a commit can reveal documentation that never reached the main branch.
Try it yourself
Before switching branches or resetting anything in git, run git status first and check for files that are staged but not committed. Commit or stash them, and only then change branches. If you have a CLI tool of your own, consider which single function you could expose as one HTTP route while reusing the logic you have already tested.
Chapters
Full transcript(auto-generated, with timestamps)
Introduction
[0:00]Hi, I'm Aishwarya from the team. This video covers turning the patent agent CLI into a real callable web API and a real Git mistake that briefly cost the whole file. One new file. One Git
The Real Loss
[0:14]Command later, it was gone. Not because the code was wrong, because it was never actually committed. Method, the CLI
Why an API, Not Just the CLI
[0:21]Works, but it only works from a terminal. A real HTTP endpoint means any client, a browser, a front end, another service can ask for a patent reading the same way without shelling out to Python directly. The API doesn't re-implement
Wrapping the Same, Already-Verified Logic
[0:37]Anything. One route, one publication number in, the same claims agent and lineage agent that were already tested through the CLI called the same way. A real classify flag, same purpose as the CLI's no classify option. Skip the one part that always costs something real. Mid-build, a Git pull failed
The Real Mistake
[0:58]Diverged branches, a forced update on the remote. Fixing that meant resetting the local main and rebasing the work branch on top of it. The rebase succeeded. The uncommitted new file didn't survive it. It was staged, not committed, and the branch switched during the fix wiped it out. The real
What Actually Protected the Work
[1:15]File wasn't lost for good because the same content still existed locally outside Git from building and testing it minutes earlier. Recreated, committed immediately this time, verified again against the same two real patents that had already confirmed the CLI was correct. Checking the readme before committing turned up
A Second Real Find, While Fixing the First
[1:35]Something else. An earlier real update documenting the lineage agent's broader testing had never actually made it into the main branch at all. Fixed in the same pass, not left for later. Your turn. Before switching
Your Turn: Check git status First
[1:49]Branches or resetting anything in Git, run Git status first. A file that's staged but not committed can disappear the moment you check out somewhere else and it won't warn you. From Clyde to API
Outro
[2:02]Built with Claude for humanitarian's AI.
More from Mycroft Financial AI
3:29The Denominator Problem: When Percentages Mislead | Uday Sonawane| Mycroft
1:40Mycroft: Building the Frontend
4:46How AI Understands Intent and Routes User Requests | Mycroft AI
3:05Extract, Don't Decide: Using LLMs for Structured Signal Extraction | Mycroft
2:11Automated Testing, Pytest & GitHub Actions CI/CD | Mycroft AI
1:59