프롬프트 엔지니어링 가이드: AI가 우리 코드의 75%를 작성할 때까지는 필요 없었다

발행: (2026년 2월 20일 오전 07:13 GMT+9)
9 분 소요
원문: Dev.to

I’m happy to help translate the text, but I need the actual content you’d like translated. Could you please paste the text (or the portion you want translated) here? I’ll keep the source line exactly as you provided and preserve all formatting, markdown, and code blocks.

AI‑Assisted Coding: A Prompting Framework that Works

Six months ago our team adopted AI coding tools. Productivity jumped 30 % the first week, but code quality dropped, bug reports rose, and PR review time doubled. The problem wasn’t the AI – it was how we were prompting it.

Below is the prompting framework we refined over six months of trial‑and‑error. It works with Cursor, GitHub Copilot, Claude Code, ChatGPT, and similar models.

1. Why Most Prompts Fail

Most developers talk to the model like they’re talking to a junior teammate:

“Build a login page.”

The model dutifully returns a page without error handling, accessibility, loading states, rate‑limiting, or modern styling – often using a deprecated library.
If the prompt is vague, the output is generic.

2. The Four‑Element Prompt Template

Every prompt should contain all of the following:

#ElementWhat to Include
1Context – what already exists? What is the tech stack? Which architectural patterns does the codebase use?
2Goal – the specific thing you want to accomplish.
3Non‑functional requirements – error handling, testing, performance, accessibility, security, etc.
4Negative constraints – what the AI must avoid (anti‑patterns, disallowed libraries, etc.).

3. Example Prompt (Positive + Negative)

Prompt

Add search to the products page

Full Prompt (using the template)

Situation:
- Next.js 14 app with App Router
- PostgreSQL via Prisma
- Tailwind CSS
- Existing products page at app/products/page.tsx (server component) that fetches all products

Goal:
- Implement search so users can type a query and see filtered results.
- Search must cover product name **and** description.

Requirements:
- Debounced input (300 ms) to avoid excessive queries.
- URL‑based search params (shareable/bookmarkable).
- Loading state while searching.
- “No results” state with a clear message.
- Minimum 3 characters before triggering a search.
- Graceful handling of Prisma errors (show error state, don’t crash).

Constraints:
- No client‑side filtering (dataset > 50 k products).
- No new dependency for search – use Prisma full‑text search.
- Do **not** use `useEffect` for data fetching (use server components + `searchParams`).
- Follow the existing code style (see other pages for reference).

Result: The output is production‑ready rather than a quick demo.

4. Negative Prompting – Tell the AI What Not to Do

“Implement the user registration endpoint.
Do NOT:

  • Use any() types
  • Catch errors silently (every catch must log and re‑throw or return an error response)
  • Skip input validation
  • Return the password hash in the response
  • Use synchronous bcrypt (use the async version)
  • Create the database table (it already exists, see schema.prisma)”

Because models are trained on millions of code snippets—many of which contain bad practices—the negative list steers them away from common pitfalls.

5. Show the Model Your Code Style

// ── example endpoint ──
// (paste an existing endpoint)

Following this exact pattern (error handling, response format, validation approach, naming convention), implement a new endpoint for .

Providing a concrete example is more reliable than describing the style in words; the model reverse‑engineers the patterns directly.

6. Build the Solution Incrementally

StepPrompt
1“Create the database query for searching products by name, with pagination. Only the query, not the API endpoint.”
2“Now wrap this in an API endpoint following our existing pattern. Add input validation with Zod.”
3“Add error handling. What happens if Prisma throws? What if the search param is empty?”
4“Write tests. Cover: successful search, empty results, invalid input, database error.”

Source:


각 단계는 이전 단계 위에 쌓이며, 초기에 정확성을 검증할 수 있게 합니다. Step 3이 실패하면 전체 구현을 다시 하는 것이 아니라 Step 3만 다시 하면 됩니다.

7. Self‑Review Prompt

코드가 생성된 후 모델에게 자체 감사를 요청합니다:

Review the code you just generated. Check for:
1. Security vulnerabilities (injection, auth bypass, data exposure)
2. Error‑handling gaps (uncaught exceptions)
3. Edge cases (empty input, concurrent access, very large input)
4. Performance issues (N+1 queries, missing indexes, unnecessary computation)

List every issue you find with the specific line number.

이는 AI가 도입하는 **60‑70 %**의 문제를 잡아내는 저비용 첫 검토이며, 인간 검토 전에 수행됩니다.

8. Explanation Prompt (When You’re Unsure)

Explain every line of this code. For each line:
1. What it does
2. Why it’s necessary
3. What would happen if it were removed

If any line is unnecessary, say so.

모델이 어떤 줄을 정당화하지 못한다면, 그 줄은 불필요하거나 위험할 가능성이 높습니다.

9. Formal Rules (What We Enforced After 6 Months)

  1. AI가 생성한 모든 코드는 인간이 작성한 코드와 동일한 PR 리뷰를 받는다.
    AI가 작성자이며, 개발자가 책임을 진다.

  2. 모든 줄을 설명할 수 없으면 커밋하지 않는다. Explanation Prompt를 사용한다.

  3. 아키텍처 결정은 팀이 내린다, 프롬프트가 아니다. AI는 코드를 작성하고, 인간은 무엇을· 작성할지를 결정한다.

  4. AI‑생성 코드는 다른 실패 모드를 가진다: 구문은 완벽하지만 의미적으로 틀릴 수 있다. 테스트가 안전망이다.

  5. 복잡한 생성 코드는 원본 프롬프트와 함께 문서화한다:

    // Generated with prompt:
    // "Implement rate limiting middleware using sliding‑window algorithm.
    //  Max 100 requests per minute per API key. Use Redis for storage.
    //  Return 429 with Retry‑After header."
    // Reviewed by: @jane on 2026‑02‑15

    이는 향후 개발자가 의도를 이해하고 필요 시 재생성하는 데 도움이 된다.

10. Measured Impact

MetricBefore FrameworkAfter Framework
Code written+30 %+25 % (프롬프트 작성 시간 때문에 약간 감소)
Bug rate+20 %–10 % (AI 도입 전 대비 10 % 버그 감소)
Net productivity gain~15 %~35 %
Prompt cost~60 seconds per prompt (버그 감소 효과를 고려하면 충분히 가치 있음)

TL;DR

  • 컨텍스트, 목표, 비기능 요구사항, 그리고 명시적인 “do not” 목록을 포함한 프롬프트.
  • 모델에게 당신의 코드 스타일 예시를 보여 주세요.
  • 작은 단계로 반복하고 모델에게 자신의 출력을 검토하도록 요청하세요.
  • 코드를 완전히 이해하지 못할 경우, 한 줄씩 설명을 요구하세요.
  • AI가 생성한 코드를 다른 기여와 동일하게 다루세요: 전체 PR 검토, 테스트, 문서화.

이 프레임워크를 따르면서 겸손한 15 % 생산성 향상이 ~35 % gain 으로 바뀌었으며 코드 품질도 크게 향상되었습니다. 🚀

토론 주제

수학은 명확합니다.

팀에서는 AI 코딩 도구를 어떻게 사용하고 있나요?
팀 표준을 개발하셨나요? 효과가 있었던 접근 방식과 실패한 사례를 듣고 싶습니다.
댓글 열림.

💡 AI Coding Prompt Templates Pack
프롬프트 템플릿과 커서‑룰 파일을 바로 사용할 수 있는 컬렉션을 원하신다면, 제가 AI Coding Prompt Templates Pack을 준비했습니다. 포함 내용은 다음과 같습니다:

  • 50개 이상의 프롬프트 템플릿
  • 8개의 커서‑룰 파일
  • Claude CodeCopilot용 워크플로 템플릿

편하게 확인해 보시고 의견을 알려 주세요!

0 조회
Back to Blog

관련 글

더 보기 »

서문

동기: 나는 일관성을 유지하기 위해 내 공부를 기록하고 싶었다. CS 전공에서는 직접 프로젝트를 구축하는 방법을 배우지 않기 때문에, 나는 내 …