Claude Code and Codex for Mathematical Modeling: From Prompts to Agent Workflow in Practice

Building autonomous math modeling workflows with Claude Code, Codex, and AI Agent architecture.
This article explores how coding agents like Claude Code and Codex can transform mathematical modeling competitions by replacing tedious Q&A-style AI usage with autonomous Agent workflows. It breaks down five core capabilities — Tools, Hooks, Skills, Subagents, and Context — explaining how each contributes to a system where AI can independently read problems, build models, write code, debug, and draft papers, while cautioning about academic integrity boundaries.
From "Prompt Hoarder" to Agent Workflow
Mathematical modeling competitions have always been notorious for "grinding" — staying up all night reading problems, building models, writing code, tuning parameters, and formatting papers, a process that typically takes three days and nights. Recently, a Bilibili creator known as "Da Shi Xiong" (Big Brother) shared a hands-on tutorial demonstrating how to use coding agents like Claude Code and Codex to have AI autonomously complete the entire mathematical modeling workflow.
The video highlights a thought-provoking phenomenon: the internet is flooded with marketing content like "one-click national award papers" and "500 prompt mega-packs," yet when it comes to actual competitions, many people still don't know how to effectively use AI. The author calls this behavior of collecting massive prompt libraries without knowing how to apply them "practicing in isolation," turning everyone into "prompt hoarders."
The core argument of this article is: Rather than chasing the prompt arms race, it's better to understand an AI Agent workflow from the ground up. This is the key to leaping from "Q&A-style usage" to "having AI do the work for you."
The Fundamental Difference Between Agents and Traditional LLMs
The author first clarifies a key concept — agentic coding.
Agentic coding is one of the most significant paradigm shifts in AI programming since 2024. Its core idea originates from the Agent concept in reinforcement learning — an autonomous entity that can perceive its environment, make decisions, and take actions. In a software engineering context, this means AI is no longer just a passive code completion tool (like early GitHub Copilot), but has evolved into a complete execution system capable of understanding task objectives, autonomously planning execution steps, calling external tools, and iteratively correcting based on feedback. The technical foundation of this paradigm is the function calling capability of large language models and the ReAct (Reasoning + Acting) framework, proposed by Princeton University in 2022, which allows models to alternate between "thinking" and "acting" steps during reasoning.
Conversational tools like DeepSeek and Doubao are essentially "only able to answer but not do work for you." Users ask questions, the model provides text answers, and that's it. Coding agents like Claude Code and Codex, on the other hand, are "built specifically to get things done" — after a user submits a task, the model autonomously reasons, makes decisions, calls the appropriate tools to get results, continues reasoning, calls more tools, and loops until the task is complete.
This difference is especially pronounced in mathematical modeling scenarios:
- Traditional approach: Inefficient Q&A-style interaction where every step requires manual guidance
- Agent mode: Simply input the problem, and the AI reads the problem, builds models, writes code, runs experiments, fixes bugs, generates charts, and produces a paper draft on its own
Put simply, a traditional LLM is a "consultant," while an Agent is an "executor."
Environment Setup: Git, VS Code, and Claude Code
To run this Agent workflow, three fundamental tools need to be installed.
Git: AI's "Undo Button"
Git is a code version control tool, which the author likens to "AI's eraser." Just as you can erase a mistake when doing homework and rewrite it, whenever AI-generated code is unsatisfactory, you can use Git to roll back to a previous version at any time.
Git was created by Linux creator Linus Torvalds in 2005, originally for managing distributed development of the Linux kernel. In traditional software development, Git's core value lies in multi-person collaboration and version tracing. But in AI Agent workflows, Git plays an entirely new role: it becomes the "safety net" during the Agent's autonomous iteration process. Since coding agents autonomously modify files, run commands, and even refactor code structures, if an Agent makes a wrong decision during an iteration (such as deleting a critical function or introducing breaking changes), Git's branch and rollback (checkout/reset) mechanisms allow users to instantly restore to any historical state. This "reversibility" is an indispensable safety guarantee for AI-driven automated processes — after all, AI can "go off the rails" too.
VS Code: The Visual Control Panel
VS Code, as a code editor, paired with the official Claude Code extension, transforms command-line operations in a black terminal window into a visual interface, significantly lowering the barrier to entry for beginners.
Claude Code / Codex: The Core Agent
This is the brain of the entire workflow. One detail worth noting: OpenAI's Codex has been merged with ChatGPT, so seeing ChatGPT when downloading is normal and not an error.

For users in China, the author also offers a pragmatic solution: using tools like CitySwitch to connect to third-party model APIs (such as DeepSeek), bypassing the network and payment restrictions of official services. An API Key (Application Programming Interface Key) is a standard authentication mechanism in cloud services, used to identify the caller and track usage billing. In the LLM service space, providers like OpenAI, Anthropic, and DeepSeek all offer model access through RESTful APIs, billing by input/output token count. Third-party relay services work as API proxies, forwarding user requests to the target model provider while solving the network access restrictions and overseas payment challenges faced by Chinese users. Configuration requires correctly entering the API Key, request URL (typically ending in v1), and model mapping — matching the third-party interface's model names to the original provider's model identifiers to ensure requests are correctly routed to the target model, thereby better controlling usage costs.

Five Core Capabilities: The Skeleton of an Agent Workflow
The truly valuable part of this tutorial lies in its systematic breakdown of the five core concepts of an Agent. Understanding them is key to knowing "why AI goes off track midway" and "when to start a new context."
Tools: The Agent's "Hands and Feet"
Tools are the capability interfaces through which agents actually get work done. Analyzing problems uses read, creating and modifying code uses edit or write, and running tests uses bash. The author emphasizes that the key isn't having many tools, but rather that "the LLM decides on its own when to call which tool" — this is precisely what distinguishes agents from traditional scripts.
From a technical implementation perspective, agent tool calling relies on the function calling mechanism of large language models. This technology was first introduced by OpenAI in June 2023 for the GPT-3.5/4 API and was subsequently widely adopted by Anthropic, Google, and others. It works as follows: developers pre-define a set of function descriptions (including name, parameters, and purpose), and the model autonomously decides during reasoning whether to call a function and what parameters to pass. The model itself doesn't execute the function — instead, it outputs a structured call request, which is actually executed by an external runtime environment that returns the result to the model. This "model decides + external executes" architecture enables language models to break beyond pure text generation and truly interact with the external world — reading/writing files, executing code, accessing the network, operating databases, and more.

Hooks: Mandatory "Triggers"
If Tools are the hands and feet, Hooks are the triggers in the workflow — when a certain event occurs, a pre-defined piece of logic is automatically executed.
The author gives an elegant example: without Hooks, if you tell the AI to "always run tests after modifying code," the AI might comply or might forget sometimes. But once configured as Hooks, this action will always execute. The core value of Hooks is constraining the Agent, ensuring that things that shouldn't wait for AI to remember are forced to execute reliably.
The concept of Hooks has a long history in software engineering. Git itself has built-in hook mechanisms like pre-commit and post-merge, allowing scripts to run automatically before or after specific operations (for example, automatically running a code formatter before committing code). In the CI/CD (Continuous Integration/Continuous Deployment) domain, Webhooks are similarly the core mechanism for triggering automated pipelines. Introducing Hooks into AI Agent workflows essentially applies the mature "event-driven" pattern from software engineering to AI behavior management. This addresses an inherent weakness of large language models: probabilistic instruction compliance. Since LLM output is fundamentally probabilistic sampling, even when certain operations are explicitly required in system prompts, the model may skip them under certain conditions. Hooks transform these "soft requirements" into "hard constraints," ensuring deterministic execution at critical workflow nodes.
Skills: The Professional "Operations Manual"
Skills address not "whether AI can do it," but "what methods, steps, and standards AI should follow." The author packaged his own modeling process into a Skills library containing 15 steps and 136 sub-modules, covering problem analysis, data processing, model selection, optimization prediction and evaluation, and even award probability assessment.
In response to the criticism that "Skills are just prompts in disguise," the author offers an engineering perspective: prompts are one-time task instructions, while Skills are engineered, modular, and reusable task methodologies. The former requires copy-pasting every time, while the latter can be encapsulated into stable, reusable capability modules — they are fundamentally different at the engineering level. This distinction is similar to the difference between "ad hoc scripts" and "well-packaged function libraries" in software development — the former solves one-off problems, while the latter enables long-term reuse and continuous iterative optimization through standardized interfaces.
Subagent: On-Call "Specialist Employees"
The core value of Subagents lies in context isolation. If a single Agent handles everything from start to finish, its context rapidly expands, attention gets diluted, and hallucinations emerge. Subagents allow the main agent to act like a "head butler," focusing only on task scheduling while delegating sub-tasks like gathering materials and validating methods, each maintaining an independent context.
This design philosophy originates from Multi-Agent Systems (MAS), a classic research field in artificial intelligence. The core idea of MAS is to solve complex problems that are difficult for a single agent through the collaboration of multiple specialized agents. Since 2023, LLM-based multi-agent frameworks have proliferated, including Stanford's Generative Agents, MetaGPT, AutoGen, CrewAI, and others. These frameworks share the common feature of having different Agents assume different roles (such as product manager, architect, programmer, tester), coordinating work through message-passing mechanisms. Context isolation is the most critical engineering design: each sub-agent maintains only the context relevant to its own task, avoiding the "attention dilution" problem that occurs when a single Agent processes all information, while also significantly reducing token consumption costs for API calls.
Taking it further, you can also implement capability isolation and permission isolation — for example, allowing a "reading agent" to only read code and offer suggestions without modifying it, while a "coding agent" can read/edit/bash but cannot write papers.
However, the author also warns about a common misconception: more agents isn't always better. Twenty agents could lead to circular calls, chaotic context passing, redundant work in aggregating results, and even instruction conflicts. A simple bug can be fixed by the main agent in minutes — no need to make a big production out of it.
Context: The Agent's "Short-Term Memory"
Context is the implicit foundation underlying all four capabilities above. Transformer-based large language models need to compute attention between every token and all other tokens in the input sequence when processing text, with computational complexity growing quadratically with sequence length (O(n²)). This means the amount of information a model can "remember" has a hard upper limit — for example, Claude 3.5 has a context window of 200K tokens (approximately 150,000 characters), while GPT-4 Turbo has 128K tokens.
When an Agent performs complex mathematical modeling tasks, the problem files it reads, the code it generates, the logs it runs, and intermediate reasoning processes all continuously consume context space. Once context approaches saturation, the model exhibits "attention dilution": key information from early inputs gets "forgotten," causing a sharp decline in subsequent decision quality, producing hallucinations or logical inconsistencies. Understanding this limitation of context windows is essential to knowing when to split tasks and when to activate sub-agents — this is the foundational knowledge for efficiently using Agent workflows, and the technical basis for judging "when to start a new context."
All-in-One Integrated Tools: Lowering the Practical Barrier
For users who find "installing so many tools too troublesome," the author recommends an integrated tool called "Academic Room," which comes with Git, VS Code, and Claude Code pre-configured, along with built-in prompt configurators, multiple advanced models, paper plagiarism checking, and AI-content detection features.

The tool offers two execution modes:
- One-click generation: Fully autonomous with no intervention needed, suitable for automating routine assignments
- AI collaboration: Real-time interactive commands with AI, suitable for important competitions like national contests
The interface separates the modeling specialist, coding specialist, and paper-writing specialist into three agent cards, with a team leader console overseeing the whole process and real-time visibility into code, charts, and data. There's also a team collaboration feature to view teammates' work progress — in the author's words, "so you can see exactly which teammate is slacking off."
A Rational Perspective: Tool Dividends and Academic Boundaries
This workflow demonstrates the enormous potential of AI Agents in professional scenarios: evolving from a "Q&A tool" to an "autonomous execution partner" can indeed dramatically improve mathematical modeling efficiency. From an engineering practice standpoint, understanding the division of labor among Tools, Hooks, Skills, and Subagents is a universal skill for mastering modern AI programming tools, far more valuable in the long term than memorizing prompts.
But we also need to soberly recognize the boundaries. The video repeatedly mentions "reducing AI detection rates," "reducing the AI feel," "lowering duplication rates," and national competition "AI tool usage declarations" — all of which reflect the sensitive territory of academic integrity. When AI can produce papers end-to-end, how to define the line between "assistance" and "doing it for you," and how to use tools within the bounds of the rules, are questions every participant must approach with care.
The leap in technical capability should not come at the cost of academic integrity — this is perhaps the point that this "grind-killer" workflow should prompt us to think about most carefully.
Related articles

Anthropic Reportedly Building Predictive Surveillance System — AI Safety Pioneer Faces Ethical Backlash
Anthropic reportedly building a predictive surveillance system to monitor activists, sparking backlash. We analyze the ethical dilemma facing this AI safety leader.

Anthropic's Official Warning: "Double-Check Your Work" Has Become a Prompt Anti-Pattern
Anthropic warns that nudging prompts like "double-check" and "be thorough" are making Claude slower and costlier. Learn what to cut and what to keep.

Kojima's New Game Physint Dropped by Sony, Picked Up by Microsoft: The Reasons Behind It and What It Means for the Industry
Kojima's Physint dropped by Sony, picked up by Microsoft. Deep analysis of the reasons, Microsoft's strategy, Kojima's independence, and industry impact.