“没有艺术的科学是瘫痪的,没有科学的艺术是空虚的。”

卡尔·萨根 (Carl Sagan) (美国天文学家,科普作家)

Tag: AI Tools

  • Cursor’s Chat and Composer: Key Differences and Advanced Tips

    1. Chat

    • Function: Chat works like an AI assistant. You can converse with it in natural language, ask questions, request code explanations, conduct code reviews, find errors, and more. It focuses on interactive Q&A and code assistance.
    • Positioning: Your code assistant.

    Advanced Usage Tips:

    • Context Awareness: Chat remembers previous conversations, so you can ask questions in a step-by-step manner without repeating contextual information each time. For example, you can first ask, “What does this code do?” and then ask, “How can I optimize the performance of this code?”.
    • Code Referencing:
      • You can directly reference code in Chat.
      • For example, select a code snippet and then type “Explain this code” or “Refactor this code.”
      • Chat can understand which part of the code you are referring to.
    • Specify Tasks: Clearly tell Chat what you want it to do, such as “Find the bug in this code,” “Generate unit tests for this code,” or “Translate this code into Python.”
    • Role-Playing: You can ask Chat to play a specific role, such as “Please act as a senior Java engineer and help me review this code.”
    • Utilize Preset Instructions: Cursor provides some preset instructions, such as:
      • @fix: Fix errors in the code.
      • @doc: Generate code comments.
      • @explain: Explain the code.
      • @test: Generate unit tests.
      • @improve: Improve code quality.
      • You can directly use these instructions in the Chat input box, for example, @fix this code.
    • Question-Asking Tips:
      • Ask questions clearly and concisely.
      • Provide sufficient contextual information.
      • Break down complex problems into smaller sub-problems.
      • Use code snippets or file names to reference code.
    • Code Review: Paste code into Chat and have it conduct a code review to identify potential issues and areas for improvement. You can ask it to focus on specific aspects, such as security, performance, readability, and so on.
    • Learning: When you encounter unfamiliar programming concepts or technologies, you can ask Chat questions to quickly gain relevant knowledge.

    2. Composer

    • Function: Composer is primarily used to generate entirely new code. You can provide requirement descriptions or give some example code, and then have Composer generate complete code snippets or files. It focuses more on code generation.
    • Positioning: Code generator.

    Advanced Usage Tips:

    • Detailed Requirement Descriptions: When describing the code you need to generate, be as detailed and specific as possible. The clearer the description, the more the code generated by Composer will meet your expectations.
    • Provide Example Code: If you have similar example code, you can provide it to Composer as a reference. This can help Composer better understand your needs and generate code that better matches your style.
    • Specify Programming Language and Framework: Clearly tell Composer the programming language and framework you want to use. For example, “Generate a to-do list component using React.”
    • Control Code Style: You can ask Composer to follow specific code style guides, such as “Generate Python code that conforms to the Google Style Guide.”
    • Gradually Refine: The code generated by Composer may not be perfect, and you need to modify and refine it according to the actual situation. You can repeatedly adjust the requirement description or modify the example code and then regenerate the code.
    • Combine with Chat: You can use Composer to generate code and then use Chat to explain, review, or modify the code.

    Summary:

    FeatureChatComposer
    Main FunctionInteractive Q&A, code assistanceCode generation
    Usage ScenariosFinding bugs, code explanation, code review, learningGenerating new code, quickly building project structures
    Interaction ModeConversationalRequirement descriptions or example code -> Generate code
    PositioningCode assistantCode generator
    Advanced TipsContext awareness, code referencing, specifying tasks, role-playing, etc.Detailed requirement descriptions, providing example code, specifying language and framework, etc.

    Some Additional Tips:

    • Experiment: Different prompts and instructions will produce different results. Try different methods to find the workflow that suits you best.
    • Follow Cursor’s Updates: The Cursor team is constantly improving the functionality of Chat and Composer and launching new features. Pay attention to Cursor’s update logs to keep up with the latest features and tips.
    • Make Good Use of Cursor’s Documentation and Community: Cursor officially provides detailed documentation and an active community. You can find more information about Chat and Composer in the documentation, and you can also exchange experiences with other users in the community.