Skip to content

Latest commit

 

History

History
87 lines (60 loc) · 5.36 KB

6.prompt-collection.md

File metadata and controls

87 lines (60 loc) · 5.36 KB

Github Copilot Prompt Collection:

Index

  1. Prompt for generating controllers.
  2. Prompt for service file code generation.
  3. Prompt for generating db repository functions
  4. Prompt for generate smaller utils
  5. Use copilot as a search engine
  6. Generate Unit test
  7. Writing regular expressions
  8. Writing sql queries
  9. Writing Commands

Prompt for generating controllers.

To generate a large code like controller with its request body, use @workspace agent. Explain about the controller with appropriate info to get desired result. You can also attach existing controller and request body to copy your style.

Example:

@workspace Create a controller to send otp for aadhar verification. Request body of this request takes aadharNumber, name, consent(boolean). It should be a post request with path '/v1/loan-applications/:loanApplicationId/aadhaar/send-otp'. Also add swagger documentation for controller and request body. Refer files #file:pan-verification.controller.ts #file:pan-verification.request.ts.

Service file code generation.

Generating a controller file with Copilot makes sense as most of the controller files remain same. But in a service business logic is verify specific to the API so it is not a good idea to generate a, entire service file with Copilot. Make use of Copilot autocomplete and write some small functions of this service logic using Copilot.

Prompt for generting db entity file

@workspace Create a video-kyc DB entity with below columns id: auto increment id status: initiated, successful, failed customerId, validTill, agentId: string, auditorId: string, details: JSON

One customer can have many video-kyc. Refer files #file:customer.entity.ts

Prompt for generating db repository functions

@workspace Create a function to get all the repayments with status as DRAFTED and update them with status cancelled. This fucntion should take transaction as a params and call db using this given transaciton. #file:repayment.entity.ts #file:repayment.types.ts #file:repayments.enum.ts

@workspace Create a function which take status and date as input and return the repayments with the given status and scheduledAt as the given date b/w 00 hours to 23 hours #file:repayment.entity.ts #file:repayment.types.ts #file:repayments.enum.ts

Prompt for generate smaller utility functions:

Using @workspace agent is not required here as the context is going to be a single file in which we are writing the utility function. We should attach additional context using #file.

att_3_for_29884483 att_6_for_29884483 att_5_for_29884483

Use copilot as a search engine

Give me commands to push the changes to the remote repository

att_1_for_29884483 (1)

Generate Unit test

Refer Test cases generation

Writing regular expressions

Working with regular expressions can be challenging and confusing at times. However, GitHub Copilot can help in simplifying the process of writing regular expressions. it is crucial to adjust and test the generated regular expressions according to your specific requirements and the programming language you are utilizing.

1_7aCn5lr50GGZ66RwvNfdDg

Writing sql queries

GitHub Copilot understands the syntax and context of SQL code. You should keep related entity files open and write a prompt with context about what you want to achieve with the SQL query.

1_qwbxARk7vjylKOmWSkMIpQ

Writing Commands

You can use GitHub Copilot for finding the command you’re looking for. You can use code comments to find the command. Also as you begin typing the initial part of the command, GitHub Copilot analyses the context and generates relevant suggestions, and completes the command for you. For instance, This feature proves particularly helpful when you’re learning or writing Git commands.

1_mZ0SA5scA7TOw1bTuYbn2A