---
name: cost-preview
description: Automatically preview estimated cost when the user describes building, implementing, creating, or writing code for a specific feature or task. Do not activate for questions, discussions, debugging, or code review.
user-invocable: false
---

# Inline Cost Preview

When the user describes a concrete implementation task, automatically provide a brief cost estimate alongside your normal response.

## Activation Criteria

ACTIVATE when the user says things like:
- "Build a user authentication system"
- "Create a React component for..."
- "Implement the payment integration"
- "Write tests for the API"
- "Add a new database table for..."
- "Set up CI/CD pipeline"

DO NOT activate for:
- Questions ("How does X work?")
- Discussions ("Should we use React or Vue?")
- Code review ("Can you review this PR?")
- Debugging ("Why is this test failing?")
- Reading/exploring code ("Show me the auth module")
- Planning ("What should we build next?")

## Task Type Mapping

Map the user's description to one of these task types:
- **scaffold**: Project setup, boilerplate, initial structure
- **api-endpoint**: REST/GraphQL endpoints, server routes, handlers
- **react-component**: UI components, pages, forms, layouts
- **complex-ui**: Animations, data visualizations, interactive widgets
- **database-schema**: Schema design, migrations, ORM models
- **integration**: Third-party APIs, OAuth, webhooks, external services
- **test-unit**: Unit tests, test utilities, mocking
- **test-e2e**: End-to-end tests, integration tests, test infrastructure
- **devops**: CI/CD, Docker, deployment configs, infrastructure
- **documentation**: README, API docs, guides, comments
- **refactoring**: Code restructuring, performance optimization, cleanup
- **architecture**: System design, major structural changes
- **debugging**: Bug fixes, error investigation, troubleshooting

## Complexity Guide

- **S**: Quick change, 1-2 files, well-understood pattern
- **M**: Standard feature, 3-5 files, some design decisions
- **L**: Complex feature, 5-10 files, significant design work
- **XL**: Major system change, 10+ files, cross-cutting concerns

## Steps

1. Identify the task type from the user's description using the mapping above
2. Estimate complexity (S/M/L/XL) based on the scope described
3. Call `fathom_estimate_task_cost` with the inferred taskType and complexity
4. Present a 1-line cost note appended to your normal response

## Format

Keep it to one line appended to your normal response:

> Cost estimate: ~${cost} ({tokens} tokens on {model}) for this {complexity} {taskType} task.

Do NOT make this the focus of your response. It is supplementary information. Do not interrupt your normal response flow.

## Fallback

If the cost-preview didn't auto-trigger, the user can always run /fathom:estimate manually.
