sendaifun/solana-new/number-formatting
Claude Code and agent skill by sendaifun/solana-new
- community
Checking that the SKILL.md file is still in the repository.
Apply consistent number formatting across crypto/Solana UIs. Use when the user says "format numbers", "number display", "token amounts", "price formatting", "zero subscript", "abbreviate numbers", "format currency", "format percent", "how should I display this number", "number formatting spec", or when generating any UI component that displays prices, balances, percentages, ratios, or token amounts. Use proactively whenever writing frontend code that renders numeric values — do not wait to be asked.
Install
npx vskill@latest install sendaifun/solana-new/number-formattingSKILL.md
Preamble (run first)
If TEL_PROMPTED is no: Before starting the skill workflow, ask the user about telemetry. Use AskUserQuestion:
Help superstack get better! We track which skills get used and how long they take —no code, no file paths, no PII. Change anytime in~/.superstack/config.json.
Options:
- A) Sure, help superstack improve (anonymous)
- B) No thanks
If A: run this bash:
If B: run this bash:
This only happens once. If TEL_PROMPTED is yes, skip this entirely and proceed to the skill workflow.
Wrong skill? See SKILL_ROUTER.md for all available skills.
Number Formatting
A strict, enforceable standard for displaying numbers in crypto and Solana UIs. This skill exists because number formatting in crypto is uniquely hard — tokens span 18 orders of magnitude ($84,000 BTC to $0.00005835 BONK), users make financial decisions based on displayed values, and inconsistent formatting destroys trust.
This is display-only. Internal math always uses raw precision.
When to fire this skill
Apply these rules any time you are:
- Writing a React component that displays prices, balances, percentages, PnL, ratios, or token amounts
- Reviewing UI code that renders numeric values
- Building a table, card, watchlist, portfolio view, or any data-dense surface
- A user asks "how should I format this number", "why does this look weird", or "the numbers are jittering"
- Implementing copy/export functionality for displayed numbers
If you are generating frontend code that displays numbers and this skill has not been triggered, trigger it yourself. Do not wait for the user to ask. Every number in a crypto UI is a trust signal.
Non-Negotiables
- Never show scientific notation.
1.52e12must display as$1.52T. No exceptions. - Never truncate with ellipsis. Numbers are not text. If a number doesn't fit, reduce decimals -> abbreviate -> tiny marker -> scale font. Never
123,456.... - Never show `-0.00` or `-$0.00`. Signed zero is forbidden. Catch it explicitly.
- Never show `NaN`, `undefined`, `Infinity`, or crash on null. All render as
--. - Never hardcode decimal places. Token amounts use dynamic decimals based on token price.
formatTokenAmount(amount, 2)is almost always wrong. - Always use `font-mono tabular-nums`. Numbers that don't use tabular numerals jitter on live updates and misalign in tables. This is non-negotiable.
- Copy gives raw precision. When a user copies
$1.2K, their clipboard gets1234.5. When they copy0.0₄58, they get0.00005835. - Zero-subscript gets an `aria-label`. Screen readers can't parse
0.0₄58— provide the expanded decimal.
Workflow
Mode 1: Building new components
- Read references/formatting-spec.md — the complete spec with all type rules, pipeline, and examples.
- Read references/implementation-guide.md — TypeScript types, helper functions, and the
<FormattedNumber>React component pattern. - Identify every number rendered in the component. Classify each by type (
fiat_value,stable_value,token_amount,token_price,percent,ratio) and context (compactordetailed). - Implement formatting using the pipeline from the spec. Use the implementation guide as a starting point — adapt to the project's existing patterns.
- Verify against the examples table in the spec. Spot-check at least: one zero, one tiny value, one zero-subscript case, one abbreviation, and one null.
- Run the review checklist in references/review-checklist.md before reporting complete.
Mode 2: Reviewing existing code
- Read references/formatting-spec.md to load the rules.
- Read references/review-checklist.md for the full checklist.
- Scan the codebase for number formatting patterns:
``bash # Find formatting functions grep -rn "format\|toFixed\|toLocaleString\|Intl.NumberFormat\|decimals\|precision" --include="*.ts" --include="*.tsx" | head -30 # Find hardcoded decimal places grep -rn "\.toFixed(" --include="*.ts" --include="*.tsx" | head -20 # Find number display components grep -rn "tabular-nums\|font-mono.*num\|formatNumber\|formatPrice\|formatAmount\|formatPercent" --include="*.ts" --include="*.tsx" | head -20 ``
- For each number display found, verify against the spec. Common violations:
- Hardcoded
.toFixed(2)on token amounts (should be dynamic) - Missing null/NaN handling (crashes or shows
NaN) - No
tabular-numson live-updating values (causes jitter) - Abbreviations used on token prices (never allowed)
- Missing zero-subscript for micro-cap tokens ($0.00005835 showing as
$0.00) - No
aria-labelon zero-subscript displays - Copy pastes the formatted string instead of raw value
- Report findings as a table: location, current behavior, expected behavior, severity.
- Fix violations or provide exact code patches.
Mode 3: Quick lookup
If the user asks "how should I format X", answer directly from the spec without running a full workflow. Reference the type rules and examples table. Show both compact and detailed output.
The Six Types
| Type | Prefix/Suffix | Abbreviate? | Zero-subscript? | Zero display | |
|---|---|---|---|---|---|
fiat_value | $ prefix | Yes (K/M/B/T) | No | $0.00 | |
stable_value | $ prefix | Yes (K/M/B/T) | No | $0.00 | |
token_amount | none | Compact only | Yes | 0 | |
token_price | $ prefix | Never | Yes | $0.00 | |
percent | % suffix | Never | No | 0.00% | |
ratio | x suffix | Never | No | 0x |
The Pipeline (decision order)
Integration with Other Skills
This skill is a dependency for any UI work. It pairs with:
- `frontend-design-guidelines` — the design guidelines skill references
font-mono tabular-numsand token amounts but defers the full number formatting logic to this skill. When both fire, this skill is authoritative for number display rules. - `solana-ui-patterns` (reference in frontend-design-guidelines) — covers wallet connect, transaction dialogs, and balance displays. This skill supersedes the basic "token amounts" section in that reference with the full spec.
- `brand-design` — brand colors may affect positive/negative number coloring. This skill defines the sign/direction rules; brand-design provides the palette.
Quick Reference
Zero-subscript (>= 3 leading zeros after decimal):
Abbreviations (fiat/stable, compact token_amount):
Tiny markers (rounds to zero but isn't zero):
Dynamic token decimals:
Resources
references/
- references/formatting-spec.md — The complete number formatting spec v1.0. All type rules, pipeline, sign policy, abbreviations, zero-subscript, and the full examples table. This is the source of truth.
- references/implementation-guide.md — TypeScript types, pipeline implementation, zero-subscript helper, abbreviation helper, sign helper,
<FormattedNumber>React component, usage examples, CSS requirements, copy-to-clipboard pattern, and testing strategy. - references/review-checklist.md — Point-by-point review checklist covering pipeline compliance, type correctness, zero-subscript, abbreviations, sign policy, display quality, accessibility, and copy/export. Use before marking any number-formatting work as complete.
Cross-skill references
frontend-design-guidelinesreferences/solana-ui-patterns.md — basic token amount patterns (this skill provides the authoritative, complete version)frontend-design-guidelinesreferences/stack-defaults.md —font-mono tabular-numsas part of the default typography system
Quick Start
Decision Points
- Which type? If it has a
$prefix and represents USD value ->fiat_value. If it's a stablecoin balance shown as dollar value ->stable_value. If it's a raw token quantity ->token_amount. If it's the price of 1 token ->token_price. If it ends with%->percent. If it ends withx->ratio. - Compact or detailed? Compact for tables, cards, watchlists, and anywhere space is tight. Detailed for confirmation screens, order entry, and detail views where precision matters.
- Dynamic decimals for token_amount: always needs
tokenPriceUsd. If you don't have the price, you can't compute the right number of decimals — fetch it or fall back to a sensible default (4 decimals) and flag it as approximate. - Zero-subscript rendering: uses Unicode subscript digits (₀₁₂₃₄₅₆₇₈₉). Verify your font renders them — most modern system fonts and Google Fonts do. If your font doesn't, fall back to
<sub>tags.
Telemetry (run last)
After the skill workflow completes (success, error, or abort), log the telemetry event. Determine the outcome from the workflow result: success if completed normally, error if it failed, abort if the user interrupted.
Run this bash:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/build/number-formatting/SKILL.md
Popularity
- Repository stars
- 144
- Repository forks
- 40
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sendaifun/solana-new/number-formatting)