원클릭으로
add-api
Scaffolds a new API endpoint with router, handler, OpenAPI docs, and TS bindings. Use when adding REST endpoints to trader-api.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Scaffolds a new API endpoint with router, handler, OpenAPI docs, and TS bindings. Use when adding REST endpoints to trader-api.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generates numbered SQL migration files for tables, indexes, and views. Use when adding or modifying database schema.
Crawls exchange API documentation and generates structured markdown specs. Use when integrating a new exchange or updating API specifications.
Systematically diagnoses build, runtime, DB, API, and frontend errors with classification and fix workflow. Use when encountering errors or test failures.
Commits code changes with automated CHANGELOG and design document updates. Runs build/lint verification before commit. Use after completing a feature, bug fix, or refactoring.
Scaffolds a new exchange connector with connector, provider, and trait implementations. Use when integrating a new exchange.
Adds a new trading strategy across 5 locations (mod.rs, routes, backtest, SDUI schema, frontend). Use when implementing a new strategy.
| name | add-api |
| description | Scaffolds a new API endpoint with router, handler, OpenAPI docs, and TS bindings. Use when adding REST endpoints to trader-api. |
| disable-model-invocation | true |
| user-invocable | true |
| argument-hint | <리소스명> [GET|POST|PUT|PATCH|DELETE] |
| allowed-tools | Read, Grep, Edit, Write, Bash(cargo *) |
| context | fork |
| agent | rust-impl |
새 엔드포인트를 $ARGUMENTS 사양으로 추가합니다.
# 기존 라우트 모듈 확인
ls crates/trader-api/src/routes/
# 라우터 등록 위치 확인
grep -n "Router" crates/trader-api/src/routes/mod.rs
위치: crates/trader-api/src/routes/<리소스>.rs (신규 또는 기존 파일)
use axum::{extract::*, Json};
use crate::error::ApiErrorResponse;
/// 리소스 조회
#[utoipa::path(
get,
path = "/api/v1/<리소스>/{id}",
params(("id" = String, Path, description = "리소스 ID")),
responses(
(status = 200, description = "성공", body = MyResponse),
(status = 404, description = "리소스 없음")
),
tag = "<리소스>"
)]
pub async fn get_resource(
State(state): State<AppState>,
Path(id): Path<String>,
) -> Result<Json<MyResponse>, ApiErrorResponse> {
// Repository 패턴 사용
let data = MyRepository::find_by_id(&state.pool, &id)
.await
.map_err(|e| ApiErrorResponse::internal(e.to_string()))?
.ok_or_else(|| ApiErrorResponse::not_found("리소스를 찾을 수 없습니다"))?;
Ok(Json(data))
}
#[utoipa::path] 어노테이션 (OpenAPI 문서)Result<_, ApiErrorResponse> 반환validator::Validate 적용 (입력에)Decimal 사용#[derive(Serialize, Deserialize, TS)]
#[ts(export)]
pub struct MyResponse {
pub id: String,
// ...
}
#[derive(TS)] + #[ts(export)] (프론트엔드 타입 자동 생성)위치: crates/trader-api/src/routes/mod.rs
pub fn create_router(state: AppState) -> Router {
Router::new()
// ... 기존 라우트
.route("/api/v1/<리소스>", get(get_resources))
.route("/api/v1/<리소스>/:id", get(get_resource))
.with_state(state)
}
# 1. 컴파일 확인
cargo check -p trader-api
# 2. Clippy
cargo clippy -p trader-api -- -D warnings
# 3. 타입 바인딩 생성 (TS 타입이 있는 경우)
cargo test --features ts-binding
# 4. OpenAPI 스펙 확인
# API 실행 후 http://localhost:3000/api-docs 에서 확인