?
사용자
Cursor Rules: 효과적인 코드 생성 프롬프트 작성 가이드
Cursor AI의 코드 생성 능력을 최대한 활용하여 원하는 코드를 빠르고 정확하게 얻고 싶을 때 유용한 프롬프트 작성법을 안내합니다.
#cursor rules#prompt engineering#code generation#ai
recipe.sh
# Cursor Rules: 효과적인 코드 생성 프롬프트 작성 가이드 이 문서는 Cursor AI를 사용하여 개발 및 메이킹 프로젝트에 필요한 코드를 효율적으로 생성하기 위한 프롬프트 작성 지침입니다. ## 1. AI의 역할 정의 AI에게 어떤 역할을 부여할지 명확하게 지정하면, AI는 해당 역할에 맞는 맥락과 전문성을 바탕으로 더 정확하고 유용한 답변을 생성합니다. **예시:** * `You are a senior Python developer specializing in data analysis.` * `You are an expert in front-end development using React and Tailwind CSS.` * `You are a cybersecurity analyst focused on identifying common web vulnerabilities.` ## 2. 명확하고 구체적인 목표 제시 AI가 수행해야 할 작업을 명확하고 구체적으로 설명하세요. 모호한 요청은 예상치 못한 결과를 초래할 수 있습니다. **좋은 예시:** * `Generate a Python function that takes a list of numbers and returns the median.` * `Create a React component that displays a list of user profiles fetched from a given API endpoint.` * `Write a SQL query to find all customers who placed an order in the last 30 days.` **나쁜 예시:** * `Make me a Python thing for numbers.` * `Show me some React stuff.` * `Help with SQL.` ## 3. 제약 조건 및 요구사항 명시 코드의 스타일, 라이브러리 사용, 성능 요구사항, 특정 패턴 준수 등 제약 조건이나 필수 요구사항을 명시하면 AI는 이를 고려하여 코드를 생성합니다. **예시:** * `Use the 'requests' library for HTTP calls. Do not use 'urllib'.` * `The React component should be a functional component using hooks.` * `Ensure the generated SQL query is optimized for performance on large datasets.` * `The code should follow PEP 8 style guidelines.` * `Avoid using global variables.` ## 4. 입력 데이터 및 컨텍스트 제공 AI가 코드를 생성하는 데 필요한 관련 정보, 예시 데이터, 기존 코드 스니펫 등을 제공하면 AI는 더 정확한 맥락을 파악하고 원하는 결과에 가까운 코드를 생성할 수 있습니다. **예시:** * `Here is the JSON structure of the API response: ...` * `Given this existing class definition: ...` * `The data I will be processing looks like this: [1, 5, 2, 8, 3]` ## 5. 출력 형식 지정 원하는 코드의 출력 형식을 지정할 수 있습니다. 코드 블록, 특정 파일 형식, 주석 포함 여부 등을 명시할 수 있습니다. **예시:** * `Provide the code within a markdown code block.` * `Include inline comments explaining each major step.` * `Generate a complete, runnable script.` * `Output only the function definition, without any surrounding text.` ## 6. 반복 및 개선 AI가 생성한 코드가 완벽하지 않을 수 있습니다. 필요하다면 피드백을 제공하고 수정을 요청하여 코드를 개선하세요. **예시:** * `This code works, but can you make it more readable?` * `The function throws an error when the input list is empty. Please add error handling.` * `Can you refactor this to use a more functional approach?` * `Add unit tests for this function using Jest.` ## 7. 복잡한 작업 분할 매우 복잡하거나 규모가 큰 작업은 한 번에 요청하기보다 여러 단계로 나누어 요청하는 것이 좋습니다. 각 단계마다 AI의 도움을 받아 진행하고, 이전 단계의 결과물을 다음 단계의 입력으로 활용하세요. **예시:** 1. `Generate the basic structure for a Node.js Express server.` 2. `Add an endpoint to handle POST requests for user registration.` 3. `Implement basic validation for the username and password fields.` 4. `Integrate with a mock database to store user information.` 이 가이드라인을 따르면 Cursor AI의 코드 생성 기능을 더욱 효과적으로 활용하여 개발 생산성을 크게 향상시킬 수 있습니다.
3
스크랩
23
좋아요
0
댓글