Current location: Home> Cursor ai Tutorial> Cursor AI Add Documents

Cursor AI Add Documents

Author: LoRA Time: 20 Mar 2025

During the daily development process, we often need to consult technical documents, API references, framework guides and other contents. Cursor AI provides document addition function, allowing AI to directly access and parse project-related documents, thus providing more accurate code suggestions and answers to questions.

This guide will explain how to use Cursor AI to add documentation to help you manage and utilize technical data more efficiently.

Cursor AI allows developers to manually upload or online citation of technical documents , allowing AI to understand the project context while writing code and provide more accurate suggestions based on these documents.

The Add Document feature is suitable for the following scenarios:

  • Large-scale projects : Let AI understand project code specifications and API rules

  • Using external API : Add API documentation to let the AI provide request examples directly

  • Teamwork : All members can use the same documentation to improve code consistency


How to add documents in Cursor AI?

Cursor AI provides two ways to add documents:

✅Method 1: Upload the document directly

1. In the Cursor AI chat window, enter @Docs
2. Select "Add new doc"
3. Upload your document file (supports .md, .pdf, .html and other formats)
4. After AI parses the document, it can quote related content during chat or code editing.

Example: Upload project API documentation

Developer : @Docs → Add api_reference.md
Cursor AI : The API documentation has been added, you can query using @api_reference in the chat.


✅Method 2: Quoting existing documents online

1. Enter @Docs in the chat window
2. Select "Add online doc"
3. Enter the document URL (for example, the official API document address)
4. AI parses document content and uses relevant information when code suggests

Example: Quoting React official documentation

Developer : @Docs → Add https://react.dev/docs
Cursor AI : The React document has been successfully added, and you can query it with @ReactDocs in the chat.


How to use the added document?

After adding a document, you can quote it in code writing and chat conversations , allowing AI to provide more accurate suggestions based on document content.

✅Query documents in chat

Developer : @ReactDocs useEffect How to use it?
Cursor AI : According to React documentation, useEffect is used to deal with side effects, such as API calls, event listening, etc. The sample code is as follows:

 jsx copy edit useEffect(() => { fetchData();
}, []);

✅Use document support when editing code

When you write code in Cursor AI, the AI will also automatically refer to the added documentation to ensure that the code complies with best practices and project specifications .

Example: Sample requests provided based on API documentation

Developer input:

 javascript copy edit fetch('/api/users')

Cursor AI automatic completion (see API documentation):

 javascript copy edit fetch('/api/users', { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

The AI knows that the API requires the Authorization header , so authentication logic is automatically added.


Example of usage

A very useful feature of Cursor AI is the ability to add document references. This is especially useful for little-known or private libraries, as the documentation for these libraries may not be used during AI training.

To add a document entry, we use the @ symbol and then Docs select from the drop-down menu:

3.jpg

This will open a window requesting the URL of the document. Let's add the PyTorch documentation as an example:

1.jpg

After inserting the URL, we can name the document entry. In this case, we use PyTorch. We can then use this name in the chat prompt to reference this document @PyTorch.

4.jpg

You can also manage document references in the Features tab of the Cursor settings:

2.jpg