With the rising popularity of AI coding tools like Cursor, Windsurf, and Cline, you may wonder how these coding agents were built. While the engineering behind them is complex, one way to gain a better understanding is by examining the system prompt of Cline.
The original system prompt can be found here, which is very long and complex:
Output from the tokenizer:
This long system prompt is attached to every message sent to LLM APIs (OpenAI/Claude/DeepSeek…) with your code, which might be why using your own APIs instead of purchasing credits from Windsurf or Cursor could actually cost more (see Windsurf blog):
…many people will say something along the lines of “let me bring my own API key or pay per token and forget all this credit system nonsense.” We believe there may be some underestimation on how many tokens we are processing on every reasoning step through the combination of knowledge retrieval, encoding of developer actions, and long history, all to give the magic that users feel with Cascade. We are only a couple weeks post-launch and already processing hundreds of billions of tokens with just Claude 3.5 Sonnet every single day. We get nice discounts from these API providers and pass all of the savings from those discounts to our users. So, it is probably not a great idea for users to take these costs on themselves without these discounts…
After studying the system prompt, I think it only does the following three things:
The following shows a more detailed summary of each section but I suggest you go over the original system prompt details to better understand coding agents’ behavior.
Describes how tools function, emphasizing a step-by-step execution approach where each tool is used sequentially and requires user approval.
Defines the XML-style syntax for invoking tools, ensuring consistency and proper parsing during execution.
Lists available tools, their descriptions, parameters, and usage examples. Covers system commands, file operations, searching, and external resource interaction.
Outlines best practices for using tools, including selecting the right tool for the task, confirming success before proceeding, and ensuring iterative execution.
Explains the Model Context Protocol (MCP) system, which enables external servers to provide additional tools and resources. Covers how to create, modify, and integrate MCP servers.
Distinguishes between write_to_file
and replace_in_file
, guiding when to use each for optimal efficiency while maintaining file integrity.
Defines two operational modes:
Lists available system functionalities, including CLI execution, file management, search, and web interactions.
Specifies constraints and guidelines, such as respecting the working directory, avoiding unnecessary user questions, and ensuring precise code modifications.
Provides details about the operating system, shell, home directory, and current working directory for environment-specific tool execution.
Outlines the structured approach to task completion:
attempt_completion
, avoiding unnecessary back-and-forth.