한국어
문서
모드

모드

다양한 사용 사례를 위한 모드입니다.

주의: 모드는 이제 opencode 설정의 agent 옵션을 통해 구성됩니다. mode 옵션은 더 이상 사용되지 않습니다. 자세히 알아보기.

opencode의 모드를 사용하면 다양한 사용 사례에 맞게 동작, 도구, 프롬프트를 커스터마이즈할 수 있습니다.

두 가지 기본 제공 모드가 포함되어 있습니다: buildplan. 이를 커스터마이즈하거나 opencode 설정을 통해 직접 모드를 구성할 수 있습니다.

세션 중에 모드를 전환하거나 설정 파일에서 구성할 수 있습니다.


기본 제공

opencode는 두 가지 기본 제공 모드가 있습니다.

Build

Build는 모든 도구가 활성화된 기본 모드입니다. 파일 작업과 시스템 명령에 대한 전체 접근이 필요한 개발 작업을 위한 표준 모드입니다.

Plan

계획 및 분석을 위해 설계된 제한된 모드입니다. Plan 모드에서는 다음 도구가 기본적으로 비활성화됩니다:

  • write - 새 파일을 생성할 수 없음
  • edit - 기존 파일을 수정할 수 없음, 단 계획 자체를 상세히 기술하기 위한 .opencode/plans/*.md 파일은 예외
  • patch - 패치를 적용할 수 없음
  • bash - 셸 명령을 실행할 수 없음

이 모드는 AI가 코드를 분석하고, 변경 사항을 제안하거나, 코드베이스에 실제 수정을 가하지 않고 계획을 세우길 원할 때 유용합니다.


전환

세션 중에 Tab 키를 사용하여 모드를 전환할 수 있습니다. 또는 설정한 switch_mode 키 바인딩을 사용하세요.

참고: 코드 포매팅 설정에 대한 정보는 포매터를 확인하세요.


설정

기본 제공 모드를 커스터마이즈하거나 설정을 통해 직접 모드를 만들 수 있습니다. 모드는 두 가지 방법으로 설정할 수 있습니다:

JSON 설정

opencode.json 설정 파일에서 모드를 구성하세요:

opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "mode": {
    "build": {
      "model": "anthropic/claude-sonnet-4-20250514",
      "prompt": "{file:./prompts/build.txt}",
      "tools": {
        "write": true,
        "edit": true,
        "bash": true
      }
    },
    "plan": {
      "model": "anthropic/claude-haiku-4-20250514",
      "tools": {
        "write": false,
        "edit": false,
        "bash": false
      }
    }
  }
}

Markdown 설정

Markdown 파일을 사용하여 모드를 정의할 수도 있습니다. 다음 위치에 배치하세요:

  • 전역: ~/.config/opencode/modes/
  • 프로젝트: .opencode/modes/

~/.config/opencode/modes/review.md

---
model: anthropic/claude-sonnet-4-20250514
temperature: 0.1
tools:
  write: false
  edit: false
  bash: false
---
 
You are in code review mode. Focus on:
- Code quality and best practices
- Potential bugs and edge cases
- Performance implications
- Security considerations
 
Provide constructive feedback without making direct changes.

Markdown 파일 이름이 모드 이름이 됩니다 (예: review.mdreview 모드를 생성합니다).

이러한 설정 옵션을 자세히 살펴보겠습니다.


모델

이 모드의 기본 모델을 재정의하려면 model 설정을 사용하세요. 다양한 작업에 최적화된 다른 모델을 사용하는 데 유용합니다. 예를 들어, 계획에는 더 빠른 모델을, 구현에는 더 강력한 모델을 사용할 수 있습니다.

opencode.json

{
  "mode": {
    "plan": {
      "model": "anthropic/claude-haiku-4-20250514"
    }
  }
}

온도

temperature 설정으로 AI 응답의 무작위성과 창의성을 제어하세요. 낮은 값은 응답을 더 집중적이고 결정적으로 만들고, 높은 값은 창의성과 다양성을 높입니다.

opencode.json

{
  "mode": {
    "plan": {
      "temperature": 0.1
    },
    "creative": {
      "temperature": 0.8
    }
  }
}

온도 값은 일반적으로 0.0에서 1.0 사이입니다:

  • 0.0-0.2: 매우 집중적이고 결정적인 응답, 코드 분석 및 계획에 이상적
  • 0.3-0.5: 약간의 창의성이 있는 균형 잡힌 응답, 일반 개발 작업에 적합
  • 0.6-1.0: 더 창의적이고 다양한 응답, 브레인스토밍 및 탐색에 유용

opencode.json

{
  "mode": {
    "analyze": {
      "temperature": 0.1,
      "prompt": "{file:./prompts/analysis.txt}"
    },
    "build": {
      "temperature": 0.3
    },
    "brainstorm": {
      "temperature": 0.7,
      "prompt": "{file:./prompts/creative.txt}"
    }
  }
}

온도가 지정되지 않으면 opencode는 모델별 기본값을 사용합니다 (대부분의 모델은 0, Qwen 모델은 0.55).


프롬프트

prompt 설정으로 이 모드의 사용자 정의 시스템 프롬프트 파일을 지정하세요. 프롬프트 파일에는 모드의 목적에 맞는 지침이 포함되어야 합니다.

opencode.json

{
  "mode": {
    "review": {
      "prompt": "{file:./prompts/code-review.txt}"
    }
  }
}

이 경로는 설정 파일이 위치한 곳을 기준으로 합니다. 따라서 전역 opencode 설정과 프로젝트별 설정 모두에서 작동합니다.


도구

tools 설정으로 이 모드에서 사용 가능한 도구를 제어하세요. 특정 도구를 true 또는 false로 설정하여 활성화하거나 비활성화할 수 있습니다.

{
  "mode": {
    "readonly": {
      "tools": {
        "write": false,
        "edit": false,
        "bash": false,
        "read": true,
        "grep": true,
        "glob": true
      }
    }
  }
}

도구가 지정되지 않으면 모든 도구가 기본적으로 활성화됩니다.

사용 가능한 도구

모드 설정을 통해 제어할 수 있는 모든 도구입니다.

도구설명
bash셸 명령 실행
edit기존 파일 수정
write새 파일 생성
read파일 내용 읽기
grep파일 내용 검색
glob패턴으로 파일 찾기
list디렉토리 내용 나열
patch파일에 패치 적용
todowrite할 일 목록 관리
todoread할 일 목록 읽기
webfetch웹 콘텐츠 가져오기

사용자 정의 모드

설정에 추가하여 직접 사용자 정의 모드를 만들 수 있습니다. 두 가지 방법을 사용한 예시입니다:

JSON 설정 사용

opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "mode": {
    "docs": {
      "prompt": "{file:./prompts/documentation.txt}",
      "tools": {
        "write": true,
        "edit": true,
        "bash": false,
        "read": true,
        "grep": true,
        "glob": true
      }
    }
  }
}

Markdown 파일 사용

프로젝트별 모드는 .opencode/modes/에, 전역 모드는 ~/.config/opencode/modes/에 모드 파일을 생성하세요:

.opencode/modes/debug.md

---
temperature: 0.1
tools:
  bash: true
  read: true
  grep: true
  write: false
  edit: false
---
 
You are in debug mode. Your primary goal is to help investigate and diagnose issues.
 
Focus on:
- Understanding the problem through careful analysis
- Using bash commands to inspect system state
- Reading relevant files and logs
- Searching for patterns and anomalies
- Providing clear explanations of findings
 
Do not make any changes to files. Only investigate and report.

~/.config/opencode/modes/refactor.md

---
model: anthropic/claude-sonnet-4-20250514
temperature: 0.2
tools:
  edit: true
  read: true
  grep: true
  glob: true
---
 
You are in refactoring mode. Focus on improving code quality without changing functionality.
 
Priorities:
- Improve code readability and maintainability
- Apply consistent naming conventions
- Reduce code duplication
- Optimize performance where appropriate
- Ensure all tests continue to pass

사용 사례

다양한 모드의 일반적인 사용 사례입니다.

  • Build 모드: 모든 도구가 활성화된 전체 개발 작업
  • Plan 모드: 변경 없이 분석 및 계획
  • Review 모드: 읽기 전용 접근과 문서 도구를 사용한 코드 리뷰
  • Debug 모드: bash와 read 도구가 활성화된 조사에 집중
  • Docs 모드: 시스템 명령 없이 파일 작업을 사용한 문서 작성

다양한 사용 사례에 따라 다른 모델이 적합할 수도 있습니다.