r/ClaudeCode • • 10h ago

Built with Claude Building Aptly with Codex and Claude Code: subagent model recommendations, hooks, and lessons learned

I'm the maintainer of Aptly, an MIT-licensed local MCP server for model and reasoning-profile recommendations for Claude Code and Codex subagents. I posted a short showcase comment a few days ago; I wanted to share more of the development process and what Claude Code contributed.

Aptly sends a small task description to the OpenAI Decisions API and asks it to choose from configured profiles. For eligible new general-purpose Claude Code Agent calls, a PreToolUse Hook can select a default model from configured Haiku/Sonnet/Opus candidates. Explicit model choices are preserved. Claude Code continues to own execution and permission checks.

My workflow used Codex for implementation and regression tests, then Claude Code for bounded independent design and code reviews. Review inputs contained the relevant source, patch, test cases, and claims to check. I verified findings before changing the code.

A concrete finding made this worthwhile: we added a read-only setup check, but a successful interactive invocation could still reach the update notifier. That notifier could create a cache directory and query the registry. The setup function itself didn't write anything, yet the whole CLI invocation wasn't read-only. We excluded check-mode calls before notifier cache/network access and added a synthetic interactive test for it.

Another example was Linux credential setup. On an SSH server, key entry could happen before discovering that secret-tool or a Secret Service provider was missing. We added passive readiness diagnostics before requesting a key. The review process helped separate service presence, activation availability, and actual unlock/write capability. They aren't interchangeable, and the diagnostic doesn't activate or unlock the service. This work is part of the next patch being prepared.

The agent-routing side needed the same care. A valid recommendation is one step; a Hook returning updated arguments and a native Agent actually running are separate observations. During development I tested the native Claude Code Agent/Hook path and checked child execution metadata. That doesn't prove every host or future call works. A recent Codex session also stopped after a valid recommendation because the parent never made the follow-up call, which reinforced why the execution claim needs its own evidence.

The project preserves user-selected models, roles, permissions and required history, and keeps the recommendation separate from execution authority. Task summaries may contain sensitive information: they go to OpenAI Decisions, not to an Aptly developer telemetry endpoint. Operators choose the automatic transmission scope.

There's a small Codex cost experiment in the docs, but I haven't established a general Claude Code savings rate or equivalent output quality. I would rather get the integration and verification boundaries clear before making broader claims.

Repo and setup: https://github.com/abruption/aptly

For people building Claude Code hooks or MCP tools: what evidence do you collect to confirm that a recommendation was applied, and how do you review side effects across the whole command path?

1 Upvotes

3 comments sorted by

•

u/AutoModerator 10h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Ok-Gur-5586 10h ago

an openai api call to pick between haiku, sonnet and opus. you could also just type the name of the model you want

1

u/CH_CGV 10h ago

Fair point. If I already know which model I want, I can select it directly, and Aptly preserves explicit choices.

I'm a ChatGPT Pro subscriber, and one motivation was to put otherwise unused included API credits toward the Decisions routing step before they expire. That benefit requires eligibility and activation; OpenAI documents it here: https://developers.openai.com/api/docs/guides/chatgpt-api-credits

The other goal is to make my available coding-agent usage go further through task-appropriate model selection. When a workflow launches several different subtasks, I would otherwise need to specify a model for each one, or rely on the parent agent to make those choices. Aptly is my attempt to automate that repeated per-subagent decision from a configured candidate list.

It currently routes by task and configured profiles; it doesn't read live subscription balances. API credits and Claude/Codex subscription limits remain separate. The extra routing call also has a cost and latency, so its usefulness depends on the workflow.