AI Library
The Age of Autonomous Scientific Discovery
Kim Kyung-jin, Attorney at Law
AI Scientists and Self-Driving Labs
This book follows how AI scientists and self-driving labs are changing the way science generates and verifies claims. It covers literature-based discovery, natural-language protocols translated into robot commands, multi-agent research systems, closed-loop laboratories, materials search, the verification gap, chains of evidence, research harnesses, journal ethics, and legal responsibility.
AI Library
A New Era of Life Sciences Opened by Artificial Intelligence
Structural Proteomics, Genomic Foundation Models, Autonomous Laboratories, and Global Governance
Kim Kyung-jin, Attorney at Law
This book is a research volume compiled with artificial intelligence. A human selected the materials and structured the work, while AI models drafted the sentences and cross-checked the facts.
AI Library
The Double Structure of Digital Sovereignty
Europe’s Departure from Palantir and the Chains of American Big Tech
Kim Kyung-jin, Attorney at Law
This is a record of 2026, when European intelligence agencies and defense ministries began removing analytics tools from America’s Palantir. It covers the replacement decisions made by France’s General Directorate for Internal Security (DGSI), Germany’s Federal Office for the Protection of the Constitution (BfV), and the Netherlands Ministry of Defense; the incident in which US export controls severed an ally’s ac…
New English Edition
Artificial Intelligence in Horticulture
Kim Kyung-jin, Attorney at Law
Across five chapters and ten sections, this book examines computer vision for crop diagnosis, harvesting robots and autonomous field systems, smart greenhouses and digital twins, precision irrigation and supply-chain quality control, high-throughput phenotyping, and predictive breeding.
New English Edition
Artificial Intelligence in Food Crop Agriculture
Kim Kyung-jin, Attorney at Law
Across six chapters and eighteen sections, the book examines digital agricultural infrastructure, remote sensing, crop diagnosis, yield forecasting, precision irrigation, genomics, molecular breeding, agricultural robotics, climate-smart agriculture, and global food security.
New English Edition
The Future of Forestry and Agroforestry
Kim Kyung-jin, Attorney at Law
Driven by Artificial Intelligence and Digital Innovation
Across five chapters and fifteen sections, the book follows satellites, drones, LiDAR, digital twins, forest-specific language models, wildfire and pest forecasting, forestry robotics, agroforestry, timber traceability, and forest carbon markets.
New English Edition
Smart Livestock Farming: AI Enters the Barn
Kim Kyung-jin, Attorney at Law
Sensors listen, cameras watch, and artificial intelligence helps farmers decide.
Across five chapters and fifteen sections, the book follows precision livestock farming from animal health and reproduction to robotic milking, virtual fencing, digital twins, methane reduction, welfare, and data ownership.
Table of Contents
Han Dong-hoon, Busan Buk-gu Gap: A Record of the 100 Days Before and After the Election (Mar. 26-Jul. 3, 2026)
Kim Kyung-jin
Table of Contents and 13 sections
From March 26 to July 3, 2026, this record follows the spring after expulsion, the Busan Buk-gu Gap by-election, victory as an independent, and the first bill submitted in the National Assembly.

Table of Contents
Artificial Intelligence and Medicine
Kim Kyung-jin, Attorney at Law
AI in clinical care, hospitals, education, and research
AI in medical imaging, risk prediction, treatment planning, hospital operations, education, and research, with patient safety, privacy, and accountability.
[AI Library] Chapter 25: Building Sub-agents: A Hands-On Workshop
Mastering Claude Code
Chapter 25: Building Sub-agents: A Hands-On Workshop
Kim Kyung-jin
Mastering Claude Code
Creating Sub-agents with the /agents Command
Open Claude Code in VS Code and type /agents. A guidance message appears: "Continue in the terminal." Due to limitations of the IDE extension, some slash commands run only in the terminal. This is not a major issue. Opening the terminal executes the command immediately, and the sub-agent management screen appears.
What you can do on this screen is clear.
You can view all agents registered in the current project. Project agents and built-in agents appear in separate categories. You can select, edit, or delete existing agents. You can also create new agents.
Selecting "Create new agent" starts an interactive configuration guide. Two options appear: manual configuration or delegation to Claude.
When you choose to delegate to Claude, your task is simply to explain in natural language what the agent should do and when it should be called. The more concrete and comprehensive the description, the better the result.
At this stage, you also decide whether to create a project agent or a personal (global) agent. Project agents are stored in the project's .claude/agents/ folder and work only within that project. Personal agents are stored in the global Claude Code settings in the home directory and can be used in any project.
A Temporary Agent option also exists. It is an agent created and discarded for a single session, but since actual usage is rare, I will not cover it in depth.
[Figure 25-1] /agents command execution screen: Terminal screenshot showing the project agent list and built-in agent list separated by category.
One practical tip: when creating an agent, you may encounter an error stating "the folder already exists." In this case, temporarily rename the existing agents folder, create the agent, move the existing agents to the new folder, then delete the old folder. This is a known bug but does not affect functionality.
YAML Metadata Configuration
A sub-agent is fundamentally a single Markdown file. Understanding this fact clarifies the concept greatly. Just as skills are Markdown files, sub-agents are also Markdown files.
The file structure divides into two parts: YAML front matter at the top and instruction content in the body below.
Let us examine the key fields that go into YAML front matter.
name is the agent's identifier. The main session references the sub-agent by this name.
description is the critical field that determines the agent's invocation conditions. When the main session receives a user request, it scans the descriptions of registered agents to decide which agent to delegate to. This follows the same principle as how skill descriptions determine trigger accuracy. A vague description leads to the wrong agent being called; a specific description results in accurate delegation.
tools specifies the set of tools this agent can use. You can select "all" to allow all tools, or apply restrictions like "read-only." The disallowed_tools field lets you explicitly block specific tools.
model determines which language model the sub-agent uses. Assigning a different model from the main session is one of the core strengths of sub-agents. You can tune cost and quality by assigning Haiku for fast exploration, Sonnet for code generation, and Opus for complex reasoning.
Enabling memory allows the sub-agent to record its work history in the agent-memory folder. I will cover this separately later.
color is the color displayed in the terminal when this agent is running. It helps visually distinguish multiple sub-agents running simultaneously. It appears only in the terminal and not in the IDE extension.
Beyond these, additional front matter fields are supported, including permission_mode, max_turns, and auto_compact. The default value for auto_compact is around 95 percent; lowering this percentage more aggressively prevents context corruption inside the sub-agent.
[Table 24-1] Primary YAML Front Matter Fields
Below the YAML front matter, the body follows. The body is the system prompt that the sub-agent references when it wakes up. It is the full text of instructions that the sub-agent reads when the main session decides to use it and the agent begins actual work.
Building the AI Trend Hunter Agent Live
Let us move concepts into hands-on practice. Here, we build a sub-agent called the "AI Trend Hunter" from start to finish.
Run /agents in the terminal and select "Create new agent." Create it as a project agent and delegate automatic generation to Claude.
Describe what this agent should do: "An agent that tracks the latest AI trends and discovers subjects worth turning into content. It collects trend signals using the Perplexity API and X (formerly Twitter) and organizes them into a format usable for video planning." Descriptions work better when more specific, and you can revise them later, so perfection is not required.
Claude Code begins creating the agent. One point to note: Claude Code does not simply generate a Markdown file from the agent description alone. It customizes the agent by referencing the structure and content of the current project. If the project involves running a YouTube channel and creating content about Claude Code and automation, that context is reflected in the agent's system prompt.
You make several choices during the generation process.
Tool selection: specify which tools this agent can use. Selecting "all" permits all tools; selecting only "read-only" and "MCP" allows only file reading and MCP server calls. Does a research agent need file modification permissions? Asking yourself this question is where constraint application begins.
Model selection: choose Sonnet. Trend research requires rapidly scanning vast information, making Sonnet's speed more suitable than Opus's deep reasoning.
Color selection: choose a color to visually identify this agent in the terminal.
Memory configuration: select "Enable." The meaning of this setting is covered in detail in the next section.
When generation completes, a Markdown file is created in the .claude/agents/ folder. Opening the file shows YAML front matter with name, description, tools, model, memory, and color configured, and the body contains a system prompt beginning with "You are an elite AI trend hunter." It includes mission, search targets, how to use memory, and how to search past context.
[Figure 25-2] Markdown file structure of the generated AI Trend Hunter agent: YAML front matter and system prompt body.
Now we run this agent. In the terminal, ask the main session to "Run the AI Trend Hunter," and the main session references the registered agent descriptions to call the AI Trend Hunter. You see the agent operating in the terminal. It performs web searches, collects information, and conducts analysis.
Press Ctrl+O while it runs to see the agent's thinking process. You can also check what prompt the main session sent to this sub-agent. Press Ctrl+B to send the agent to the background, allowing you to continue conversation with the main session while waiting for the sub-agent to complete.
When execution finishes, the results return to the main session. A report organized with Hot Signals, Warm Signals, recommended video ideas, and key patterns appears.
One item to check: the generated agent's description may be too long. An excessively long description wastes tokens the model must count. However, it may raise invocation accuracy, so appropriate balance must be found.
Running an audit with a tool like the Agent Builder Skill automatically detects issues such as missing tool restrictions, unconfigured max turns, and oversized descriptions.
Agent Memory
If you open the agent-memory folder before running the AI Trend Hunter for the first time, you will see a folder for the AI Trend Hunter, but it contains no files. Memory files are automatically generated after the agent runs for the first time.
Once the first run is complete, memory files appear inside the agent-memory/ai-trend-hunter/ folder. What do these files contain?
A sub-agent awakens in a completely fresh context each time. It has no conversation history and no memory of previous sessions. But if a memory file exists, things change. When a sub-agent awakens, it can read the memory file and reference what it learned in the past. Not complete memory, but context like "this source was useful last time" and "we already covered this topic" persists.
[Figure 25-3] How agent memory works: First run → Memory file automatically created → Subsequent runs reference memory file → Memory file updated after work
This structure prevents the trend research agent from reporting content it already covered two hours ago. Because "recent scans" remain in memory, it avoids duplication and focuses on new signals.
Memory is the mechanism through which a sub-agent accumulates learning across sessions. If you want to build an agent that improves with use, activating memory is the starting point.
Protecting the main context with sub-agents
Let's verify the context-preservation effect of sub-agents with numbers.
The AI Trend Hunter agent has finished running. In the process of searching the web, analyzing sources, classifying signals, and writing reports, this agent consumed approximately 40,000 tokens.
Now let's run the /context command in the main session. The main session's current context usage is 29,000 tokens.
Let's reflect on what this number means. If we had performed the same research directly in the main session without a sub-agent, at least 40,000 tokens would have been added to the main session's context. Combined with existing conversation, a significant portion of the reading window would be filled with research results. Later, when doing other work,code review, documentation, debugging,available context would shrink.
With a sub-agent, work totaling 40,000 tokens is handled in a separate context. Only summaries,hot signals, warm signals, recommended ideas,are delivered to the main session. The main session's context remains clean.
[Figure 25-4] Context preservation effect comparison: Direct handling uses 69,000+ tokens in main session vs. delegating to sub-agent uses 29,000 tokens in main session
This is one of the most practical reasons to use sub-agents. The reading window is a finite resource, and sub-agents are the barrier that protects it.
Claude Code's built-in sub-agents
Before building a custom sub-agent, Claude Code comes with built-in sub-agents. If you've ever seen an "agent" label appear in the terminal while using Claude Code, you've encountered these built-in sub-agents.
The Explore agent searches and analyzes the codebase. It runs on the Haiku model and has read-only permissions. It's cheap and fast, but cannot modify files or generate code. It's automatically invoked when you need to understand codebase structure or find specific patterns.
The Planning agent performs research and creates plans. It inherits the parent session's model. If the main session runs on Opus, the planning agent also runs on Opus. It has read-only permissions and is frequently invoked in Plan Mode.
The General agent is invoked when multi-step tasks are needed. It inherits the parent model and has access to all tools. Unlike the previous two agents, it can modify files, execute commands, and generate code.
[Table 24-2] Comparison of built-in sub-agents
One of Claude Code's core developers has disclosed the custom sub-agents he personally uses: Build Validator, Code Architect, Code Simplifier, On-call Guide, and Verify App.
The fact that the creator of Claude Code operates such a variety of sub-agents within his own tool proves the practical value of sub-agents.
Claude Code's official documentation also publishes examples of sub-agents. You can find the complete markdown structure for Code Reviewer, Debugger, Data Scientist, Database Query Validator, and others, making them worth consulting when designing your own sub-agents.
We've learned the hands-on skills of building and operating sub-agents. One more fact to verify remains. Sub-agents follow the main session's instructions, work independently, and return results in a one-way structure. But what would a structure look like where agents converse with each other, assign tasks to one another, and cooperate toward a shared goal?
Artificial intelligence expert Lawyer Kim Kyung-jin
AI legal policy specialist, former lawmaker, author of multiple books
If this book stayed with you even briefly, please support the publication of the next story.
(Voluntary support account: Nonghyup 302-1096-0948-81, Account holder: Kim Kyung-jin)
Kim Kyung-jin
Attorney · Former Member of the National Assembly · AI Policy Researcher
© 2026 Kim Kyung-jin. All rights reserved.













