Everyone must have often seen articles like “Use Cursor to Develop xxx in 30 Seconds” in WeChat public accounts. Typical clickbait, just take it as a joke.
Cursor is not yet powerful enough for someone with no coding knowledge to easily develop useful software, but it can indeed empower those who know how to code. Recently, many students in the group have asked me how to properly use Cursor:

Today, I will talk about a scenario where I use Cursor: quickly understanding the core logic of an open-source project.
Taking Cline[1] as an example, this is a VSCode plugin that allows VSCode to implement Cursor’s functionality. Coupled with DeepSeek’s latest model, some claim it can perfectly replace Cursor. So, if I fully understand the principles of Cline, I will have essentially understood the implementation principles of Cursor. Let’s see how to use Cursor to assist my learning of Cline’s source code.
First, clone the Cline code to your local machine and open it with Cursor. As shown in the figure below:

At this point, if someone completely unfamiliar with coding comes in, they will definitely want Cursor to explain the principles of this project right away. However, the codebase of this plugin is quite large, and letting Cursor explain without focusing on key parts will only yield a vague overall explanation, which is not helpful for your learning.
As engineers, before asking questions, we must have a preliminary understanding of what we want to inquire about; otherwise, we cannot ask useful questions. To gain a preliminary understanding of a software project, the first step is to look at the project’s file structure. By examining its file structure, we should be able to infer the general functionality of each folder’s code. This allows us to skip less important sections. For example, since this project is a VSCode plugin, there will certainly be some code that is necessary for it to be recognized and called by VSCode. We do not need to concern ourselves with that. We only need to focus on how it generates code using AI and how it automatically modifies code.
This is similar to when I get a new book; I usually look at the table of contents first to understand the overall structure of the book, and then I read it with questions in mind.
By browsing the project’s file structure, we can see that the logic related to AI-generated code should be in the src/core
folder. Within src/core/prompts
are the relevant prompts, and src/core/assistant-message
contains the logic for parsing the XML returned by the large model and implementing automated operations.
Cline’s functionality is very similar to Cursor; it can automatically execute commands, generate files, and modify existing files.
Taking the feature of Cline automatically modifying existing files as an example. Suppose our program already has a lot of code, and now I have installed Cline in VSCode, asking AI to help me add some functionality to this project. The process would be as follows:
-
Read the existing code -
Construct a prompt containing the existing code and our new requirements, and call the large model -
The large model returns a piece of content, and Cline parses this content to modify the corresponding parts of the relevant files.
Now, I want to learn what the content returned by the large model looks like. How does Cline parse this content and translate it into file operations?
So, I first pose the following question in Cursor:
@folder src/core/assistant-message
This is the logic for how the automation programming copilot Cline processes the information returned by the large model. Please read its code and tell me its parsing logic.
As shown in the figure below:

From the content it returns, we can see that the content returned to Cline by the large model is in XML format. Cline parses this XML to further execute specific operations. Among the content it returns, the supported operations include the following:

The feature I am most concerned about is how the replace_in_file
function is implemented, so I further ask:
Please explain the specific logic and process of replace_in_file in detail.
The returned content is as follows:

This content is quite lengthy, so let me summarize the key points it returns:
-
It shows the format of the content returned by the large model -
How the code parses the content returned by the large model -
How to modify the code
It has explained quite clearly, but since Cline is written in JavaScript, some students may not be as familiar with JS as they are with Python. Therefore, we will have the large model take one more step to translate it, rewriting the core code in Python and creating a demo to run this Python code:
Now, for the sake of my understanding, please help me implement a Python version of replace_in_file. Please create a folder named example in the root directory of the project. This folder should contain four files:
1. example_llm_response.txt: A simulated piece of content returned by the large model
2. example_old.py: A piece of code that needs to be modified
3. replacer.py: The Python version of replace_in_file
When I run replacer.py, it should modify example_old.py based on the content in example_llm_response.txt and generate example_new.py.
As shown in the figure below:

We can first look at the generated example_llm_response.txt
, which contains the following:
I will help you fix the bug in the calculate_multiply function.
<replace_in_file>
<diff>
<<<<<<<< SEARCH
def calculate_multiply(a, b):
# This is a buggy multiplication function
return a + b # Here it incorrectly uses addition
=======
def calculate_multiply(a, b):
# Fixed multiplication function
return a * b # Corrected to return the correct multiplication result
>>>>>>>> REPLACE
</diff>
</replace_in_file>
Now the multiplication function has been fixed, and it will return the correct result.
The code that needs to be modified, which has issues, is as follows:
def calculate_sum(a, b):
# Calculate the sum of two numbers
return a + b
def calculate_multiply(a, b):
# This is a buggy multiplication function
return a + b # Here it incorrectly uses addition
def greet(name):
# Greeting function
print("Hello " + name)
if __name__ == "__main__":
result = calculate_multiply(3, 4)
print(f"3 x 4 = {result}") # This will output an incorrect result
Running it directly will show that the final output is incorrect:

Now running replacer.py
will automatically generate example_new.py
, which contains the following:

As you can see, the output result is now correct. Although the last line of the new code’s comment is still problematic, it is understandable since this returned content is simulated.
Now, by directly reading the replacer.py file, we can understand Cline’s logic using Python syntax. The generated code does not rely on any third-party libraries, so it can theoretically run in any environment that can execute Python. Everyone can also directly modify the code with their own ideas to test its running effect.

The generated code here uses regular expressions to extract XML. In formal projects, we would definitely need to use specialized XML parsing modules. However, this demo using regular expressions helps us better understand the code.
I won’t post the complete code here; those with Cursor can try using it. Those without Cursor can use Cline + DeepSeek to try it out, and the results should be the same as mine.
Additionally, I will attach the code structure of Bolt.new that I parsed using Cursor, along with the sequence diagram generated using Mermaid syntax:

Summary
Cursor can not only write code but also help us learn code. When you ask questions, make sure to ask precisely about a specific feature; the more specific your question, the more specific the returned content will be.
Cline: https://github.com/cline/cline
END

Unheard Code·Knowledge Planet is now open!
One-on-one Q&A for crawler-related questions
Career consulting
Interview experience sharing
Weekly live sharing
……
Unheard Code·Knowledge Planet looks forward to meeting you~