AI 코딩도구

opencode.json 추천 템플릿(권한/모델/커맨드 세트

wins007 2026. 1. 24. 15:57

아래는 바로 복붙해서 쓰는 opencode.json 추천 템플릿 3종입니다.
(공통 목표: 키는 커밋 금지, 권한은 ask로 안전하게, 자주 쓰는 커맨드 세트 제공)

위치: 프로젝트 루트에 opencode.json 생성
글로벌 설정은 ~/.config/opencode/opencode.json 쪽에 두면 됩니다.


1) 템플릿 A: “안전 기본형” (처음 쓰는 분 추천)

  • 편집/쉘 실행은 항상 확인(ask)
  • 기본 모델 + 작은 모델 분리(가벼운 질문은 small_model로)
  • 키는 환경변수 참조
{
  "$schema": "https://opencode.ai/config.json",
  "theme": "opencode",

  "model": "openai/gpt-4.1",
  "small_model": "openai/gpt-4.1-mini",

  "provider": {
    "openai": {
      "options": {
        "apiKey": "{env:OPENAI_API_KEY}"
      }
    }
  },

  "permission": {
    "edit": "ask",
    "write": "ask",
    "bash": "ask"
  },

  "share": "manual",
  "autoupdate": true
}

✅ 추천 환경변수 설정(WSL):

echo 'export OPENAI_API_KEY="YOUR_KEY"' >> ~/.bashrc
source ~/.bashrc

2) 템플릿 B: “팀/기관용” (보안 강화 + 규칙/문서 지시)

  • 기본 플러그인/자동 공유 비활성에 가까운 운영
  • 프로젝트 규칙 문서(가이드/컨벤션)들을 instructions로 묶어 “항상 준수”하게
{
  "$schema": "https://opencode.ai/config.json",

  "model": "anthropic/claude-sonnet-4-5",
  "small_model": "anthropic/claude-haiku-4-5",

  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "{env:ANTHROPIC_API_KEY}"
      }
    }
  },

  "permission": {
    "edit": "ask",
    "write": "ask",
    "bash": "ask"
  },

  "share": "disabled",
  "autoupdate": true,

  "instructions": [
    "CONTRIBUTING.md",
    "docs/guidelines.md",
    ".cursor/rules/*.md"
  ]
}

✅ 포인트

  • 팀마다 “코딩 규칙/커밋 규칙/테스트 규칙”을 문서로 만들어 두고, instructions로 묶어두면 AI가 스타일을 크게 덜 망가뜨립니다.

3) 템플릿 C: “실전 커맨드 세트” (테스트/리팩토링/리뷰 자동화)

  • /test, /lint, /fix, /review 같은 반복 작업을 커맨드로 박아두는 버전
  • 모델/에이전트 지정도 가능(가벼운 커맨드는 small_model 권장)
{
  "$schema": "https://opencode.ai/config.json",

  "model": "openai/gpt-4.1",
  "small_model": "openai/gpt-4.1-mini",

  "provider": {
    "openai": {
      "options": {
        "apiKey": "{env:OPENAI_API_KEY}"
      }
    }
  },

  "permission": {
    "edit": "ask",
    "write": "ask",
    "bash": "ask"
  },

  "command": {
    "test": {
      "description": "Run full tests and summarize failures + suggested fixes",
      "template": "Run the full test suite. Summarize failing tests and propose minimal fixes. If changes are needed, describe the exact files/lines to edit.",
      "agent": "build",
      "model": "openai/gpt-4.1-mini"
    },

    "lint": {
      "description": "Run lint and propose fixes",
      "template": "Run the linter for this repo. Summarize issues by category and propose fixes. Prefer minimal diffs.",
      "agent": "build",
      "model": "openai/gpt-4.1-mini"
    },

    "review": {
      "description": "Code review focused on security/perf/maintainability",
      "template": "Review the current changes (git diff). Focus on security, performance, maintainability, and edge cases. Provide prioritized feedback and suggested patches.",
      "agent": "code-reviewer"
    },

    "refactor": {
      "description": "Refactor a target module safely",
      "template": "Refactor $ARGUMENTS. Preserve behavior, keep diffs small, and add/adjust tests only if needed. Explain the refactor plan first, then implement.",
      "agent": "plan",
      "model": "openai/gpt-4.1"
    }
  },

  "agent": {
    "code-reviewer": {
      "description": "Strict reviewer: security/perf/maintainability",
      "model": "openai/gpt-4.1",
      "prompt": "You are a strict code reviewer. Flag security risks, hidden bugs, performance issues, and unclear logic. Prefer actionable, minimal patch suggestions.",
      "tools": {
        "write": false,
        "edit": false
      }
    }
  },

  "share": "manual",
  "autoupdate": true
}

사용 예시

  • TUI에서:
    • /test
    • /lint
    • /review
    • /refactor packages/api/src/auth.ts

추가 팁(중요)

1) 키는 파일 참조로도 가능(더 안전)

예: ~/.secrets/openai-key 파일을 만들어두고:

{
  "provider": {
    "openai": {
      "options": {
        "apiKey": "{file:~/.secrets/openai-key}"
      }
    }
  }
}

2) “프로젝트별 설정 + 글로벌 설정” 분리 추천

  • 글로벌: 테마/기본 모델/공급자(키는 env)
  • 프로젝트: commands, instructions, permissions