입력 형식 및 예시
모호함을 없애도록 구체적인 입력 예시를 보여줍니다
입력 형식 및 예시은(는) CoddyKit의 무료 Claude Architect 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Claude Architect 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Why Input Formats Matter
A tool description is the primary mechanism Claude uses to decide when and how to call a tool. Names alone don't carry enough signal. A strong description covers purpose, return values, edge cases, applicability boundaries, and crucially the input formats.
This lesson focuses on one high-leverage technique: showing concrete input examples so the model never has to guess what a parameter should look like.
Ambiguity Is the Enemy
Imagine a tool with a parameter called date. Is it 2026-06-10? 06/10/2026? June 10? A Unix timestamp? Without an example, Claude has to infer the format, and inference under ambiguity is where malformed tool calls come from.
An ambiguous schema doesn't fail loudly. It fails quietly, by producing inputs your backend rejects. Concrete examples remove that ambiguity at the source.
Where Examples Live
You can place input examples in two complementary places:
- In the tool description text (overall usage examples).
- In each parameter's
descriptioninside the JSON Schema (per-field format).
Both feed the same selection-and-formatting engine. Put the format guidance closest to the field it governs, and add a holistic example for the whole call.
search_orders = {
"name": "search_orders",
"description": (
"Search a customer's orders by date range. "
"Dates use ISO 8601 (YYYY-MM-DD). "
"Example call: search_orders(start='2026-01-01', end='2026-03-31')."
),
"input_schema": {
"type": "object",
"properties": {
"start": {
"type": "string",
"description": "Inclusive start date, ISO 8601. Example: '2026-01-01'."
},
"end": {
"type": "string",
"description": "Inclusive end date, ISO 8601. Example: '2026-03-31'."
}
},
"required": ["start", "end"]
}
}A Weak Description vs a Strong One
Compare these. The weak version forces guessing; the strong one shows exactly what valid input looks like.
- Weak: "Look up a customer."
- Strong: purpose + input format + example + return values + edge cases.
Minimal, ambiguous descriptions are a classic anti-pattern that causes tool misrouting and malformed arguments.
# Weak: model must guess the id format
bad = {
"name": "get_customer",
"description": "Look up a customer."
}
# Strong: shows the exact format with an example
good = {
"name": "get_customer",
"description": (
"Fetch a verified customer profile by account ID. "
"account_id is the 8-char alphanumeric code from the "
"welcome email, e.g. 'A1B2C3D4' (not the email address). "
"Returns name, tier, and verified flag. "
"Returns isError if no match — ask for more identifiers, never guess."
)
}Show the Shape of Structured Inputs
When a parameter is an object or array, a single example is worth a paragraph of prose. Show the model the literal shape it should emit.
This is especially valuable for nested filters, list items, or any field where the structure isn't obvious from the type alone.
filter_param = {
"type": "object",
"description": (
"Structured filter. Example: "
'{"status": "shipped", "min_total": 50, '
'"tags": ["priority", "gift"]}. '
"Omit a key to leave that dimension unfiltered."
),
"properties": {
"status": {"type": "string", "enum": ["pending", "shipped", "delivered"]},
"min_total": {"type": "number"},
"tags": {"type": "array", "items": {"type": "string"}}
}
}Enums Beat Free Text for Fixed Sets
When a field has a known, finite set of valid values, encode them as an enum rather than describing them in prose. The schema then constrains the model directly.
For extensibility, add an "other" enum value plus a free-text detail field, so new cases don't force the model to invent an invalid value.
reason = {
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["defective", "wrong_item", "late", "other"],
"description": "Refund reason. Use 'other' for anything unlisted."
},
"detail": {
"type": "string",
"description": "Free text. Required only when category is 'other'."
}
},
"required": ["category"]
}Examples Reduce Hallucinated Inputs
Few-shot examples are one of the most reliable prompting tools. With 2-4 targeted examples per ambiguity, the model generalizes the pattern rather than just repeating it.
Applied to tool inputs, examples are best for consistency, edge cases, output format, and reducing hallucination, exactly the failure modes that produce bad tool arguments.
phone = {
"type": "string",
"description": (
"Phone in E.164 format. "
"Examples: '+14155552671', '+442071838750'. "
"Do NOT include spaces, dashes, or parentheses."
)
}Mark Required Only What's Always Present
Examples tell the model what valid input looks like; the required array tells it what must appear. A critical rule: mark a field required only if it is always present.
If you require a field that may be absent from the source, the model will fabricate a value to satisfy the schema. Optional-but-well-exemplified beats required-but-sometimes-missing.
schema = {
"type": "object",
"properties": {
"order_id": {"type": "string", "description": "e.g. 'ORD-90412'"},
"coupon_code": {
"type": "string",
"description": "Optional. e.g. 'SAVE10'. Omit if none on the order."
}
},
# coupon_code is NOT required — it may be absent.
"required": ["order_id"]
}Call Out Edge Cases in the Example
Good descriptions state applicability boundaries: what the tool does, and what it does NOT handle. Bake those boundaries into your examples so the model recognizes when an input is out of scope.
This keeps overlapping tools from being misrouted, since the example clarifies which tool owns which input shape.
lookup_order = {
"name": "lookup_order",
"description": (
"Look up ONE order by its order ID. "
"order_id format: 'ORD-' + 5 digits, e.g. 'ORD-90412'. "
"Does NOT search by customer name or email — "
"use search_orders for that. "
"Returns isError (category='validation') if the ID is malformed."
)
}Pair Input Examples With Structured Errors
Even with great examples, some inputs will be invalid. The tool's error contract should be just as explicit, so the model can recover.
Return structured errors: an isError flag plus errorCategory (transient / validation / business / permission), isRetryable, a message, and the attempted_query. Generic "Operation failed" blocks recovery; structured errors enable intelligent routing and a corrected retry.
{
"isError": true,
"errorCategory": "validation",
"isRetryable": true,
"message": "start must be ISO 8601 (YYYY-MM-DD); got '06/10/2026'.",
"attempted_query": {"start": "06/10/2026", "end": "2026-03-31"},
"partial_results": null
}Examples + Retry-With-Feedback
When a tool input comes back malformed, use retry-with-feedback: send the original request, the wrong output, and the exact validation error back to the model. Format and structural errors are exactly what this fixes.
Note the limit: retry helps when the input was misformatted, not when the needed info is simply absent from the source. Examples prevent the first class of error; nothing invents missing facts.
messages.append({
"role": "user",
"content": (
"Your tool call failed validation. "
"start must match YYYY-MM-DD. "
"You sent '06/10/2026'. "
"Reissue the call with the corrected format."
)
})
# Resend full history; the model keeps no state between turns.Quick Check
Apply the lesson to a real design decision.
Recap: Make Inputs Unambiguous
Key takeaways:
- Tool descriptions drive selection and formatting, so invest in them, not just names.
- Show concrete input examples at the field level and a full-call example in the description.
- Use enums (with an 'other' + detail field) for fixed sets; show the literal shape of objects and arrays.
- Mark a field required only if it is always present, otherwise the model fabricates.
- Back examples with structured errors (errorCategory, isRetryable, attempted_query) so retry-with-feedback can correct format mistakes, though it cannot supply absent facts.
Concrete examples are the cheapest, highest-leverage way to stop malformed tool calls before they happen.
자주 묻는 질문
“입력 형식 및 예시” 강의는 무료인가요?
네 — “입력 형식 및 예시” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Claude Architect 강의 전체를 잠금 해제할 수 있습니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
“입력 형식 및 예시”에서 뭘 배우나요?
모호함을 없애도록 구체적인 입력 예시를 보여줍니다 브라우저에서 직접 실행하는 실습 코드로 Claude Architect을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Claude Architect을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Claude Architect은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“입력 형식 및 예시” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Claude Architect 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Claude Architect 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 도구 설명이 선택을 좌우합니다
- 훌륭한 설명의 구조
- 도구 간 중복 피하기
- 입력 형식 및 예시