Translating Agent Configurations Across CLI Tools

Subagent structures have become a standard way to give command-line AI assistants specialized roles, but the lack of a universal schema means you often find yourself stuck with tool-specific syntax. When you try to reuse a configuration file from one environment in another, the mismatch in field names, nesting levels, and data types can turn a simple task into a debugging exercise. Understanding the underlying structure is the first step to making these tools interoperable.
The most common friction point involves the transition between markdown-based definitions and strict JSON schemas. Some harnesses prefer human-readable text files with specific headers, while others demand precise JSON objects with strict typing. This difference is not merely aesthetic; it dictates how the underlying parser interprets instructions, handles variable substitution, and manages context windows. A slight deviation in structure can cause the agent to ignore its own instructions entirely.
In this guide, we will break down the process of converting subagent formats between popular CLI tools, focusing on the structural differences between markdown-based and JSON-based definitions. We will look at how to map fields correctly, handle edge cases in configuration, and ensure that your agents retain their intended behavior when moved between environments. By the end, you will have a reliable method for translating these configurations without losing functionality. Note that while this guide discusses various tools, this site is not affiliated with Google, and the advice applies to any CLI harness supporting subagents.
You can also explore why CLI hits 429 errors often if you run into rate limits while testing these conversions, or check /prompt.txt for a standardized prompt template that works across many tools.
Frequently asked questions
What is a CLI subagent format?
A CLI subagent format is a structured configuration file that defines a specialized role for an AI assistant within a command-line interface. It typically includes instructions, context windows, and specific parameters that guide how the model responds to tasks. These formats vary significantly between tools, ranging from simple markdown files to complex JSON schemas, depending on the harness's parsing logic.
How does JSON differ from Markdown for subagents?
JSON provides strict data typing and nesting, making it ideal for programmatic parsing and complex configurations. Markdown is more human-readable and flexible, often using headers and lists to define structure. While JSON ensures consistency, Markdown allows for easier manual editing and natural language descriptions. The choice depends on whether you prioritize automation or readability.
Which format is better for large context windows?
JSON is generally better for large context windows because it can efficiently encode large blocks of text or complex data structures without ambiguity. Markdown can become cluttered and harder to parse when dealing with extensive instructions or nested lists. JSON's structured nature ensures that large amounts of data are handled consistently by the parser, reducing the risk of formatting errors.
What is the most common conversion error?
The most common error is mismatched field names, such as using 'instructions' in one tool and 'system_prompt' in another. Another frequent issue is incorrect nesting levels, where a subagent's configuration is placed at the root level instead of within a specific array or object. Always check the schema documentation for each tool to ensure fields are mapped correctly.
Can I use the same file for multiple tools?
Yes, but only if both tools support the same format, such as standard JSON or Markdown. If one tool requires JSON and the other requires Markdown, you will need to convert the file. Some tools allow for flexible input formats, but relying on this can lead to subtle bugs. It is safer to maintain separate configuration files for each tool to ensure compatibility.
How do I handle variables in converted formats?
Variables must be preserved during conversion, ensuring that the syntax for substitution matches the target tool's requirements. For example, if one tool uses '{{variable}}' and another uses '${variable}', you need to update the syntax accordingly. Test the converted file with a simple prompt to verify that variables resolve correctly before deploying it for complex tasks.
What tools can help with format conversion?
You can use simple scripting languages like Python or JavaScript to parse and transform JSON objects. For Markdown to JSON conversion, libraries like 'markdown-it' or 'pandoc' can help automate the process. Manual conversion is also feasible for small configurations, but automation reduces the risk of human error, especially when dealing with complex nested structures.
Is it safe to share subagent formats?
Yes, subagent formats are generally safe to share as they contain instructions and parameters, not sensitive data. However, ensure that any API keys or specific environment variables are removed or placeholder-based before sharing. It is also good practice to document the specific tool and version required for the format to avoid compatibility issues for others.
Step by step
- Analyze Source Format — Examine the structure of the source subagent configuration, identifying key fields, nesting levels, and data types. Note any tool-specific requirements or unique features that may need special handling during conversion.
- Map Fields to Target — Create a mapping between the source fields and the target tool's schema. Identify equivalent fields and determine how to transform the data to fit the target format, ensuring that semantic meaning is preserved.
- Convert and Generate — Use a script or manual process to convert the configuration, applying the field mappings and transformations. Generate the target format file, ensuring that syntax and structure are correct.
- Validate and Test — Run syntax and functional tests on the converted configuration. Verify that the subagent behaves as expected in the target tool, checking for any errors or unexpected behavior.
- Iterate and Refine — Based on test results, refine the conversion process, adjusting mappings or transformations as needed. Repeat the testing process until the configuration is fully functional and reliable.
Understanding the Structural Differences
The foundation of any subagent configuration lies in its structural definition. Different CLI tools interpret these definitions in distinct ways, leading to compatibility issues when files are shared. For instance, some tools treat subagents as first-class objects within a JSON array, while others embed them as nested properties within a larger configuration object. Understanding these differences is crucial for successful conversion.
Another key difference is the handling of instructions. Some tools expect a single string field for system prompts, while others allow for structured markdown with headers and lists. This variation affects how the AI model interprets the context and prioritizes information. When converting, you must ensure that the semantic meaning of the instructions is preserved, even if the syntactic representation changes.
The role of metadata also varies across tools. Some harnesses include metadata fields for versioning, authorship, or execution context, which can be ignored or cause errors in other tools. It is important to identify which metadata fields are essential for the target tool and which can be safely omitted or transformed. This selective preservation ensures that the converted configuration remains functional and efficient.
JSON Schema vs. Markdown Structure
JSON schema provides a rigid structure with defined types, ensuring that the configuration is parsed correctly by the tool. Markdown, on the other hand, offers flexibility and readability, allowing for natural language descriptions. When converting, you must map JSON fields to corresponding Markdown sections or vice versa, ensuring that the content is not lost in translation. This often involves transforming lists into headers and vice versa.
Field Mapping Strategies
Field mapping involves aligning the configuration fields of the source tool with those of the target tool. This requires a thorough understanding of both schemas and the semantic meaning of each field. For example, 'system_prompt' in one tool might correspond to 'instructions' in another. Careful mapping ensures that the AI model receives the correct context and instructions, maintaining the intended behavior of the subagent.
Converting JSON to Markdown
Converting JSON to Markdown involves transforming structured data into a human-readable format. This process typically involves iterating through the JSON object and generating corresponding Markdown headers, lists, and paragraphs. The key is to preserve the hierarchy and relationships between different parts of the configuration, ensuring that the Markdown file is both readable and functional for the target tool.
Start by identifying the root objects and arrays in the JSON structure. Each root object can be converted into a Markdown header, while nested objects can be converted into sub-headers or lists. Pay attention to field names and values, ensuring that they are accurately represented in the Markdown format. This approach maintains the logical flow of the configuration, making it easier for humans to read and understand.
Handle special characters and formatting carefully, as Markdown has specific rules for escaping and styling. For example, JSON strings containing quotes or newlines must be properly escaped to avoid breaking the Markdown structure. Additionally, consider using code blocks for large blocks of text or complex data structures, ensuring that they are preserved exactly as intended.
Mapping Fields to Headers
Mapping JSON fields to Markdown headers involves translating the hierarchical structure of the JSON object into a series of headers and sub-headers. Each level of nesting in the JSON object corresponds to a deeper level of header in the Markdown file. This approach ensures that the logical structure is preserved, making it easier for users to navigate and understand the configuration.
Handling Lists and Arrays
Lists and arrays in JSON can be converted into Markdown unordered or ordered lists, depending on the content. Each item in the array becomes a list item, preserving the order and content. This approach is particularly useful for configuration options or parameter lists, where the order and structure are important. Ensure that special characters within list items are properly escaped to avoid formatting issues.

Converting Markdown to JSON
Converting Markdown to JSON requires parsing the text-based structure and transforming it into a structured JSON object. This process involves identifying headers, lists, and code blocks, and mapping them to corresponding JSON fields. The goal is to create a valid JSON object that can be parsed by the target tool, preserving the original content and structure as much as possible.
Start by parsing the Markdown file into a structured format, such as an abstract syntax tree (AST). This allows you to easily identify and extract different sections of the document, such as headers, lists, and paragraphs. Once the structure is identified, you can map these elements to JSON fields, ensuring that the hierarchy and relationships are preserved. This approach ensures that the converted JSON file is valid and functional.
Pay attention to data types and formatting when converting Markdown to JSON. For example, numbers, booleans, and arrays must be correctly typed in the JSON output. Additionally, handle special characters and escaping carefully, ensuring that they are preserved in the JSON string. This attention to detail ensures that the converted configuration is accurate and reliable.
Parsing Markdown Structure
Parsing Markdown structure involves breaking down the text-based document into its constituent parts, such as headers, lists, and paragraphs. This can be done using a Markdown parser library, which generates a structured representation of the document. This structured representation makes it easier to map the content to JSON fields, ensuring that the hierarchy and relationships are preserved.
Generating JSON Objects
Generating JSON objects from the parsed Markdown structure involves mapping each element to a corresponding JSON field. Headers become keys, lists become arrays, and paragraphs become string values. This process requires careful attention to data types and formatting, ensuring that the resulting JSON object is valid and can be parsed by the target tool. Testing the output is crucial to ensure accuracy.
Handling Edge Cases and Special Formats
Edge cases often arise when converting between different formats, particularly when dealing with special characters, nested structures, or unique field requirements. For example, some tools may require specific field names or data types that do not have a direct equivalent in the source format. Identifying and handling these edge cases is crucial for a successful conversion, ensuring that the configuration remains functional and accurate.
Another common edge case is the handling of whitespace and indentation. Markdown is sensitive to whitespace, while JSON is not. When converting from Markdown to JSON, it is important to strip unnecessary whitespace and ensure that the JSON structure is properly formatted. Conversely, when converting from JSON to Markdown, preserving indentation and spacing can improve readability and maintain the original structure.
Consider the impact of versioning and compatibility. Different versions of CLI tools may have different schema requirements, leading to compatibility issues. When converting configurations, it is important to specify the target version and ensure that the converted file is compatible with that version. This may involve adding version-specific fields or removing deprecated ones to ensure smooth operation.
Dealing with Special Characters
Special characters in configuration files can cause parsing errors if not handled correctly. When converting formats, ensure that characters like quotes, newlines, and tabs are properly escaped or encoded. This is particularly important when dealing with JSON strings, where special characters must be escaped to avoid breaking the structure. Using a reliable parsing library can help automate this process and reduce the risk of errors.
Managing Nested Structures
Nested structures in configuration files can be challenging to convert, as they require careful mapping of parent-child relationships. When converting from Markdown to JSON, ensure that nested lists and headers are correctly represented as nested objects and arrays. This requires a deep understanding of the target schema and the ability to accurately translate the hierarchical structure into a valid JSON format.

Testing and Validation Strategies
Testing and validation are critical steps in the conversion process, ensuring that the converted configuration functions as intended. This involves running the converted file through the target tool and verifying that the subagent behaves correctly. Common tests include checking for syntax errors, validating field mappings, and ensuring that the AI model receives the correct context and instructions.
Start by performing a syntax check on the converted file, ensuring that it is valid JSON or Markdown. This can be done using built-in tools or libraries specific to the target format. Once the syntax is verified, proceed to functional testing, where you execute the subagent with a set of test prompts and verify that the output matches expectations. This helps identify any issues with field mapping or content transformation.
Consider using automated testing tools to streamline the validation process. These tools can run a series of predefined tests and generate reports on the results, making it easier to identify and fix issues. Automated testing is particularly useful when dealing with complex configurations or when performing multiple conversions, as it ensures consistency and reduces the risk of human error.
Syntax Validation
Syntax validation ensures that the converted file adheres to the structural rules of the target format. This involves checking for valid JSON syntax, proper Markdown formatting, and correct escaping of special characters. Using a dedicated parser or linter can help identify and fix syntax errors quickly, ensuring that the file is ready for functional testing.
Functional Testing
Functional testing involves running the converted configuration through the target tool and verifying that the subagent behaves as expected. This includes testing various input prompts and verifying that the output matches the intended behavior. Functional testing helps identify issues with field mapping, content transformation, and context handling, ensuring that the converted configuration is reliable and accurate.
Automation and Scripting
Automation can significantly simplify the conversion process, especially when dealing with large configurations or multiple tools. By writing scripts to handle the conversion, you can reduce the risk of human error and ensure consistency across conversions. Automation is particularly useful when dealing with repetitive tasks, such as converting multiple subagent files or testing different configurations.
Start by identifying the repetitive steps in the conversion process, such as parsing, mapping, and validation. These steps can be automated using scripting languages like Python or JavaScript. Libraries for parsing JSON and Markdown are widely available, making it easy to write scripts that handle these tasks efficiently. Automation also allows for easy integration with CI/CD pipelines, ensuring that configurations are validated and converted automatically.
This approach is especially relevant when managing multiple agents, as discussed in how to build managed agents in Gemini, where consistency across many configurations is key to avoiding drift and ensuring reliable performance.
Writing Conversion Scripts
Writing conversion scripts involves defining the logic for parsing, mapping, and generating the target format. This requires a clear understanding of both the source and target schemas, as well as the ability to handle edge cases and special characters. Using well-structured functions and modular code makes it easier to maintain and update the scripts as the schemas evolve.
Integrating with CI/CD
Integrating conversion scripts with CI/CD pipelines ensures that configurations are automatically validated and converted whenever changes are made. This involves setting up triggers for specific events, such as commits or pull requests, and running the conversion scripts as part of the build process. This approach ensures that configurations are always up-to-date and compatible with the target tools, reducing the risk of deployment issues.

Best Practices for Interoperability
Interoperability between different CLI tools is enhanced by following best practices in configuration design. This includes using standard field names, maintaining clear documentation, and ensuring that configurations are version-controlled. By adhering to these practices, you can reduce the friction associated with format conversion and make it easier to share configurations across tools.
Another best practice is to design configurations with flexibility in mind. This involves avoiding tool-specific features that may not be supported by other tools, and using standard formats whenever possible. This approach ensures that configurations are portable and can be easily converted between different environments. It also makes it easier to switch between tools, as the configurations remain consistent and predictable.
Documenting the conversion process is also important, especially when dealing with complex configurations. This includes documenting the mapping of fields, handling of edge cases, and any tool-specific requirements. Clear documentation makes it easier for others to understand and replicate the conversion process, reducing the learning curve and improving overall efficiency.
Standardizing Field Names
Standardizing field names across different tools reduces the complexity of conversion, as it minimizes the number of mappings required. This involves identifying common field names and using them consistently across configurations. When a field name is not standard, it should be clearly documented and mapped to the corresponding field in the target tool. This approach ensures that conversions are straightforward and reliable.
Maintaining Clear Documentation
Clear documentation is essential for successful conversion, as it provides context and guidance for the conversion process. This includes documenting the structure of the configuration, the mapping of fields, and any tool-specific requirements. Well-maintained documentation makes it easier for others to understand and replicate the conversion process, reducing the risk of errors and improving overall efficiency.
Troubleshooting Common Issues
Despite careful planning, issues can arise during the conversion process. Common problems include syntax errors, field mapping mismatches, and content loss. Troubleshooting these issues requires a systematic approach, starting with identifying the error and then tracing it back to the source of the problem. This often involves reviewing the conversion script, checking the configuration files, and testing with different inputs.
Syntax errors are often the easiest to identify, as they are usually reported by the parser or linter. Field mapping mismatches can be more subtle, requiring careful comparison of the source and target schemas. Content loss occurs when information is not correctly transformed or preserved during conversion, leading to incorrect behavior. Identifying the root cause of these issues is key to resolving them effectively.
If you encounter errors during testing, refer to why CLI hits 429 errors often to ensure that your testing isn't being rate-limited, which can mimic conversion failures. Additionally, check best local alternatives to Gemini AI Studio if you need a different model to test your converted configurations against.
Identifying Syntax Errors
Syntax errors are often the first indicator of a problem in the conversion process. These errors are usually reported by the parser or linter, providing specific line numbers and descriptions. Identifying and fixing these errors is the first step in resolving more complex issues. Using automated syntax checkers can help catch these errors early, reducing the time spent on debugging.
Resolving Field Mismatches
Field mismatches occur when a field in the source configuration does not have a corresponding field in the target configuration, or when the field names are different. Resolving these mismatches involves mapping the fields correctly and ensuring that the content is preserved. This may require manual intervention or adjustments to the conversion script, depending on the complexity of the mismatch.

Test the keyless API with a one-line curl call right from your terminal to see how fast and reliable it is for your scripts.