Cursor Tips
Commit Message
Click here to quickly generate Git commit messages. But once you use it, you'll find that the generated messages are in English and cannot specify a format. Even if you add rules in Cursor Settings, you cannot effectively control the AI's behavior.
From my experience, you can customize it by adding a .cursorrule file to the root directory.

---
alwaysApply: true
---
All Git commit messages must be written in Chinese.
Format follows Conventional Commits: type: description
type values: feat / fix / refactor / chore / docs / style / test / perf
description in Chinese, no more than 72 characters
Examples:
feat: add user login endpoint
fix: fix token expiration not refreshed issue
The .cursorrules file for defining prompt words is a deprecated approach and may no longer take effect with future Cursor versions.
My version is Version: 2.5.26 + VSCode Version: 1.105.1, and it works well in my tests.
MCP
MCP (Model Context Protocol) is simply a universal interface protocol.
Third-party services can implement the interface to provide the agent with third-party capabilities, thus operating external systems.
For example, GitHub MCP allows the agent to directly operate repositories. Notion MCP allows the agent to read your knowledge base and continue writing content.
In Cursor, you can open the Marketplace to select MCP.

Hook
Agent lifecycle hooks — users can insert custom scripts at various stages of the agent's work to observe, intercept, or modify its behavior.
Cursor provides a rich set of lifecycle events, such as before/after using a tool, before/after modifying a file, before/after agent startup, etc.
Users can inject scripts at these event points. A common use case is to run a script before modifying a file to check if it involves files in sensitive directories.
{
"preToolUse": [{
"command": "./hooks/guard-sensitive-files.sh",
"matcher": "Write|StrReplace|Delete",
"failClosed": true
}]
}Or automatically run tests after editing:
{
"afterFileEdit": [{
"command": "sh -c 'git diff --name-only | grep _test. && npm test -- --changedSince=HEAD --no-coverage || true'"
}]
}How does my script know which directory files the agent is about to modify before the change? When the hook is called, a JSON is pushed into stdin.
So the script content is simple: read stdin → parse JSON → check file_path/command → decide whether to allow or block.
For details on what data is sent via stdin at each event node and what the script should return to indicate allow/block, please refer to the official documentation.
https://cursor.com/cn/docs/hooks#pretooluse
Subagent
My understanding: subagent = skill + fresh context.
Define a document, define some scenarios. When the main agent encounters these scenarios, it automatically outsources the task to the subagent.
Why doesn't the main agent do it itself?
Outsource simple tasks to cheaper models to save money.
Assigning tasks to the subagent creates a fresh context, saving money and reducing interference.
Users can actively request to invoke a subagent by typing /subagent_name. Example:

Use Multiple Models / Max Mode / Auto — The Three Modes
The brain icon to the right of the model name indicates that the model requires more computation and needs more time for thinking and reasoning.
Max Mode essentially allows you to fully utilize the top-tier models by consuming more tokens. It suits refactoring old projects or users who are not cost-sensitive.

Auto mode theoretically dynamically selects the model based on task characteristics, but in practice it frequently uses Cursor's own Composer 2, or a fine-tuned Kimi K2.5.
Use Multiple Models lets you manually pick a few large models to run the task together, then you choose which model performed best. It's like a horse race. Suitable for technology selection or core algorithm evaluation.

Cursor Cheat Sheet
AI coding assistants are essentially about prompt engineering, or rather context engineering. The richer the context, the more accurate the code.
If you find the model always hallucinating on a certain API or mentioning content inconsistent with your project's tech stack, you can quickly provide reference documentation to the model using @tech_stack_name/URL. Cursor has built-in official documentation for many mainstream tech stacks, effectively reducing the need to switch screens and avoiding interruptions.
