quickstart.mdx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ---
  2. title: "Workflows Quick Start"
  3. sidebarTitle: "Quick Start"
  4. description: "A step-by-step guide to creating your first Cline workflow."
  5. ---
  6. In this tutorial, you will create a powerful workflow that automates the process of reviewing a GitHub Pull Request. This example demonstrates how to combine CLI tools, file analysis, and user interaction into a seamless process.
  7. ### Prerequisites
  8. * You have Cline installed.
  9. * You have the [GitHub CLI (`gh`)](https://cli.github.com/) installed and authenticated.
  10. * You have a Git repository open with a Pull Request you want to test this on.
  11. ## Creating a Pull Request Review Workflow
  12. This workflow will automate the process of fetching PR details, analyzing the code changes for issues, and drafting a review comment.
  13. <Steps>
  14. <Step title="Create the Workflow File">
  15. First, create the directory structure for your project-specific workflows.
  16. 1. In the root of your project, create a new folder named `.clinerules`.
  17. 2. Inside `.clinerules`, create another folder named `workflows`.
  18. 3. Finally, create a new file named `pr-review.md` inside the `workflows` folder.
  19. </Step>
  20. <Step title="Write the Workflow Content">
  21. Open the `pr-review.md` file and add the following content. This workflow will gather PR details, analyze the changes, and help you submit a review.
  22. ````markdown pr-review.md
  23. # Pull Request Reviewer
  24. This workflow helps me review a pull request by analyzing the changes and drafting a review.
  25. ## 1. Gather PR Information
  26. First, I need to understand what this PR is about. I'll fetch the title, description, and list of changed files.
  27. ```bash
  28. gh pr view PR_NUMBER --json title,body,files
  29. ```
  30. ## 2. Examine Modified Files
  31. Now I will examine the diff to understand the specific code changes.
  32. ```bash
  33. gh pr diff PR_NUMBER
  34. ```
  35. ## 3. Analyze Changes
  36. I will analyze the code changes for:
  37. * **Bugs:** Logic errors or edge cases.
  38. * **Performance:** Inefficient loops or operations.
  39. * **Security:** Vulnerabilities or unsafe practices.
  40. ## 4. Confirm Assessment
  41. Based on my analysis, I will present my findings and ask how you want to proceed.
  42. ```xml
  43. <ask_followup_question>
  44. <question>I've reviewed PR #PR_NUMBER. Here is my assessment:
  45. [Insert Analysis Here]
  46. Do you want me to approve this PR, request changes, or just leave a comment?</question>
  47. <options>["Approve", "Request Changes", "Comment", "Do nothing"]</options>
  48. </ask_followup_question>
  49. ```
  50. ## 5. Execute Review
  51. Finally, I will execute the review command based on your decision.
  52. ```bash
  53. # If approving:
  54. gh pr review PR_NUMBER --approve --body "Looks good to me! [Summary of analysis]"
  55. # If requesting changes:
  56. gh pr review PR_NUMBER --request-changes --body "Please address the following: [Issues list]"
  57. # If commenting:
  58. gh pr review PR_NUMBER --comment --body "[Comments]"
  59. ```
  60. ````
  61. <Note>
  62. When you run this workflow, you will replace `PR_NUMBER` with the actual number of the pull request you want to review (e.g., `/pr-review.md 123`).
  63. </Note>
  64. </Step>
  65. <Step title="Run the Workflow">
  66. Now you're ready to run your new workflow.
  67. 1. Open the Cline chat panel.
  68. 2. Type `/pr-review.md` followed by the PR number (e.g., `/pr-review.md 42`) and press Enter.
  69. 3. Cline will fetch the PR details, analyze the code, and present you with its findings before submitting the review.
  70. <Tip>
  71. As Cline executes commands (like `gh pr view`), it may show you the output and pause. You will need to click the **Proceed While Running** button to allow Cline to analyze the content and continue with the workflow.
  72. </Tip>
  73. </Step>
  74. </Steps>
  75. ### Other Common Use Cases
  76. This is just one example. You can create workflows for a wide variety of tasks, such as:
  77. * **Creating Components:** Automate the boilerplate for new files (like React components or API endpoints).
  78. * **Running Tests:** Create a workflow that runs your test suite and summarizes the results.
  79. * **Deploying Your Application:** Automate your deployment pipeline using tools like `docker` and `kubectl`.
  80. * **Refactoring Code:** Guide Cline through a complex refactoring process step-by-step.
  81. Explore Cline's capabilities and your own development processes to find repetitive tasks that can be turned into efficient workflows.