본문 바로가기
목차
개발환경

Gemini-cli: Custom Slash Command 만들기

by ds31x 2026. 3. 26.
728x90
반응형

이 문서는 Gemini CLI에서 슬래시(/)로 시작하는 custom slash command 정의하고 사용하는 방법을 기술.

1. Overview

  • Custom slash command 를 추가하면 복잡한 프롬프트를 짧은 명령어로 저장해 두고 필요할 때마다 호출할 수 있음.

예를 들어 /review "초보자"와 같은 형식으로 코드 리뷰를 요청할 수 있음.


2. 저장 위치 (Storage Locations)

Custom slash command 의 정의(or 설정) 파일(.toml)은 다음 두 위치 중 하나에 저장 가능함:

  • Global Commands (All projects): ~/.gemini/commands/
  • Local Commands (Project-specific): .gemini/commands/ (Relative to project root)

3. 파일 형식 및 구조 (File Format and Structure)

파일 이름이 곧 명령어 임.

  • explain.toml 파일인 경우, /explain 명령어를 생성.
  • 하이픈과 언더바, 영문자로 파일명을 만들 것.

예시: /review.toml 파일 내용

description = "코드를 수준별로 리뷰."

prompt = """
제공된 코드를 리뷰해.
대상 수준: {{args}}

초보자라면 쉬운 용어로, 중급자라면 성능과 아키텍처 위주로 설명할 것.
모든 답변은 한국어로 작성해야 함.
"""
  • description: /help 명령어 실행 시 표시될 명령어의 설명.
  • prompt: 명령어 실행 시 AI에게 전달될 실제 프롬프트.
  • {{args}}: 명령어 뒤에 입력하는 인자(argument)가 치환될 위치.
    • 예: /review "초보자" 실행 시 {{args}}"초보자"로 치환.

참고로 복수개의 인자를 집어넣어도 {{args}} 하나에 들어감(공백문자 포함하여).


4. 적용 및 사용

명령어 새로고침 (Reload Commands)

  • 새로운 파일을 생성하거나 수정했다면,
  • CLI 세션 내에서 다음 명령어를 실행하여 변경 사항을 적용:
/commands reload

명령어 사용 (Use the Command)

이후 다음과 같이 정의한 slash command를 사용할 수 있음:

/review "초보자"

같이 보면 좋은 자료들

2026.03.26 - [utils] - Gemini-cli: slash command

 

Gemini-cli: slash command

Gemini CLI의 slash command 소개Gemini CLI에서 /memory, /stats, /tools, /settings처럼 /로 시작하는 입력을 slash command 라고 지칭함.이는 built-in command 로 분류,이는 일반 prompt 가 아니라 CLI 자체를 제어하는 meta-lev

ds31x.tistory.com

 

https://geminicli.com/docs/cli/custom-commands/

 

Custom commands

 

geminicli.com

 

728x90