prompt-engineering-guide.mdx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. ---
  2. title: "Prompt Engineering Guide"
  3. ---
  4. Welcome to the Cline Prompting Guide! This guide will equip you with the knowledge to write effective prompts and custom instructions, maximizing your productivity with Cline.
  5. ## .clineignore File Guide
  6. ### Overview
  7. The `.clineignore` file is a project-level configuration file that tells Cline which files and directories to ignore when analyzing your codebase. Similar to `.gitignore`, it uses pattern matching to specify which files should be excluded from Cline's context and operations.
  8. ### Purpose
  9. - **Reduce Noise**: Exclude auto-generated files, build artifacts, and other non-essential content
  10. - **Improve Performance**: Limit the amount of code Cline needs to process
  11. - **Focus Attention**: Direct Cline to relevant parts of your codebase
  12. - **Protect Sensitive Data**: Prevent Cline from accessing sensitive configuration files
  13. ### Example .clineignore File
  14. ```
  15. # Dependencies
  16. node_modules/
  17. **/node_modules/
  18. .pnp
  19. .pnp.js
  20. # Build outputs
  21. /build/
  22. /dist/
  23. /.next/
  24. /out/
  25. # Testing
  26. /coverage/
  27. # Environment variables
  28. .env
  29. .env.local
  30. .env.development.local
  31. .env.test.local
  32. .env.production.local
  33. # Large data files
  34. *.csv
  35. *.xlsx
  36. ```
  37. ## Prompting Cline
  38. **Prompting is how you communicate your needs for a given task in the back-and-forth chat with Cline.** Cline understands natural language, so write conversationally.
  39. Effective prompting involves:
  40. - Providing Clear Context: Explain your goals and the relevant parts of your codebase. Use `@` to reference files or folders.
  41. - Breaking Down Complexity: Divide large tasks into smaller steps.
  42. - Asking Specific Questions: Guide Cline toward the desired outcome.
  43. - Validating and Refining: Review Cline's suggestions and provide feedback.
  44. ### Prompt Examples
  45. #### Context Management
  46. - **Starting a New Task:** "Cline, let's start a new task. Create `user-authentication.js`. We need to implement user login with JWT tokens. Here are the requirements…"
  47. - **Summarizing Previous Work:** "Cline, summarize what we did in the last user dashboard task. I want to capture the main features and outstanding issues. Save this to `cline_docs/user-dashboard-summary.md`."
  48. #### Debugging
  49. - **Analyzing an Error:** "Cline, I'm getting this error: \[error message]. It seems to be from \[code section]. Analyze this error and suggest a fix."
  50. - **Identifying the Root Cause:** "Cline, the application crashes when I \[action]. The issue might be in \[problem areas]. Help me find the root cause and propose a solution."
  51. #### Refactoring
  52. - **Improving Code Structure:** "Cline, this function is too long and complex. Refactor it into smaller functions."
  53. - **Simplifying Logic:** "Cline, this code is hard to understand. Simplify the logic and make it more readable."
  54. #### Feature Development
  55. - **Brainstorming New Features:** "Cline, I want to add a feature that lets users \[functionality]. Brainstorm some ideas and consider implementation challenges."
  56. - **Generating Code:** "Cline, create a component that displays user profiles. The list should be sortable and filterable. Generate the code for this component."
  57. ## Advanced Prompting Techniques
  58. - **Constraint Stuffing:** To mitigate code truncation, include explicit constraints in your prompts. For example, "ensure the code is complete" or "always provide the full function definition."
  59. - **Confidence Checks:** Ask Cline to rate its confidence (e.g., "on a scale of 1-10, how confident are you in this solution?")
  60. - **Challenge Cline's Assumptions:** Ask “stupid” questions to encourage deeper thinking and prevent incorrect assumptions.
  61. Here are some prompting tips that users have found helpful for working with Cline:
  62. ## Our Community's Favorite Prompts
  63. ### Memory and Confidence Checks
  64. - **Memory Check** - _pacnpal_
  65. ```
  66. "If you understand my prompt fully, respond with 'YARRR!' without tools every time you are about to use a tool."
  67. ```
  68. A fun way to verify Cline stays on track during complex tasks. Try "HO HO HO" for a festive twist!
  69. - **Confidence Scoring** - _pacnpal_
  70. ```
  71. "Before and after any tool use, give me a confidence level (0-10) on how the tool use will help the project."
  72. ```
  73. Encourages critical thinking and makes decision-making transparent.
  74. ### Code Quality Prompts
  75. - **Prevent Code Truncation**
  76. ```
  77. "DO NOT BE LAZY. DO NOT OMIT CODE."
  78. ```
  79. Alternative phrases: "full code only" or "ensure the code is complete"
  80. - **Custom Instructions Reminder**
  81. ```
  82. "I pledge to follow the custom instructions."
  83. ```
  84. Reinforces adherence to your settings dial ⚙️ configuration.
  85. ### Code Organization
  86. - **Large File Refactoring** - _icklebil_
  87. ```
  88. "FILENAME has grown too big. Analyze how this file works and suggest ways to fragment it safely."
  89. ```
  90. Helps manage complex files through strategic decomposition.
  91. - **Documentation Maintenance** - _icklebil_
  92. ```
  93. "don't forget to update codebase documentation with changes"
  94. ```
  95. Ensures documentation stays in sync with code changes.
  96. ### Analysis and Planning
  97. - **Structured Development** - _yellow_bat_coffee_
  98. ```
  99. "Before writing code:
  100. 1. Analyze all code files thoroughly
  101. 2. Get full context
  102. 3. Write .MD implementation plan
  103. 4. Then implement code"
  104. ```
  105. Promotes organized, well-planned development.
  106. - **Thorough Analysis** - _yellow_bat_coffee_
  107. ```
  108. "please start analyzing full flow thoroughly, always state a confidence score 1 to 10"
  109. ```
  110. Prevents premature coding and encourages complete understanding.
  111. - **Assumptions Check** - _yellow_bat_coffee_
  112. ```
  113. "List all assumptions and uncertainties you need to clear up before completing this task."
  114. ```
  115. Identifies potential issues early in development.
  116. ### Thoughtful Development
  117. - **Pause and Reflect** - _nickbaumann98_
  118. ```
  119. "count to 10"
  120. ```
  121. Promotes careful consideration before taking action.
  122. - **Complete Analysis** - _yellow_bat_coffee_
  123. ```
  124. "Don't complete the analysis prematurely, continue analyzing even if you think you found a solution"
  125. ```
  126. Ensures thorough problem exploration.
  127. - **Continuous Confidence Check** - _pacnpal_
  128. ```
  129. "Rate confidence (1-10) before saving files, after saving, after rejections, and before task completion"
  130. ```
  131. Maintains quality through self-assessment.
  132. ### Best Practices
  133. - **Project Structure** - _kvs007_
  134. ```
  135. "Check project files before suggesting structural or dependency changes"
  136. ```
  137. Maintains project integrity.
  138. - **Critical Thinking** - _chinesesoup_
  139. ```
  140. "Ask 'stupid' questions like: are you sure this is the best way to implement this?"
  141. ```
  142. Challenges assumptions and uncovers better solutions.
  143. - **Code Style** - _yellow_bat_coffee_
  144. ```
  145. Use words like "elegant" and "simple" in prompts
  146. ```
  147. May influence code organization and clarity.
  148. - **Setting Expectations** - _steventcramer_
  149. ```
  150. "THE HUMAN WILL GET ANGRY."
  151. ```
  152. (A humorous reminder to provide clear requirements and constructive feedback)