@FRAMEWORK_FIRST @ZERO_CUSTOM_CODE @NEURAL_TIMESTAMP: 2025-09-17T23:45:00Z
Every formatting task MUST delegate to a framework with ZERO custom code. If a library requires boilerplate → REJECT and find better.
Framework: humanize
humanize.intcomma(45678) # → "45,678"Neural Path: @NUMBER_FORMAT → humanize.intcomma
Framework: babel
format_currency(12.45, 'USD', locale='en_US') # → "$12.45"Neural Path: @CURRENCY_FORMAT → babel.format_currency
Framework: humanfriendly
humanfriendly.format_timespan(10800, detailed=False) # → "3 hours"Neural Path: @DURATION_FORMAT → humanfriendly.format_timespan
Framework: humanize
humanize.naturalsize(1048576) # → "1.0 MB"Neural Path: @FILESIZE_FORMAT → humanize.naturalsize
Framework: arrow
arrow.get(timestamp).humanize() # → "2 hours ago"
arrow.get(timestamp).format('h:mm A') # → "2:34 PM"Neural Path: @TIME_FORMAT → arrow.humanize/format
Framework: inflect
p = inflect.engine()
p.plural_noun("message", 5) # → "messages"
f"{count} {p.plural_noun('message', count)}" # → "5 messages"Neural Path: @PLURALIZE → inflect.plural_noun
Framework: markdown2 (better than markdown - more features, less setup)
markdown2.markdown(text, extras=['fenced-code-blocks']) # → HTML with syntax highlightingNeural Path: @MARKDOWN_HTML → markdown2.markdown
Framework: pygments
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
highlight(code, PythonLexer(), HtmlFormatter()) # → Colored HTMLNeural Path: @SYNTAX_HIGHLIGHT → pygments.highlight
Framework: rich
from rich.json import JSON
from rich.console import Console
Console().print(JSON(json_str)) # → Colored, formatted JSONNeural Path: @JSON_PRETTY → rich.JSON
Framework: tabulate
from tabulate import tabulate
tabulate(data, headers="keys", tablefmt="github") # → GitHub markdown tableNeural Path: @TABLE_FORMAT → tabulate
Framework: deepdiff (for data) + difflib (for text)
from deepdiff import DeepDiff
DeepDiff(old, new, view='text') # → Human-readable diff
import difflib
'\n'.join(difflib.unified_diff(old.splitlines(), new.splitlines())) # → Unix diffNeural Path: @DIFF_FORMAT → deepdiff/difflib
Framework: rich.progress
from rich.progress import track
for item in track(items, description="Processing..."):
pass # → Live progress barNeural Path: @PROGRESS_BAR → rich.progress.track
Framework: rich + emoji
from emoji import emojize
emojize(":white_check_mark: Success") # → "✅ Success"
emojize(":x: Failed") # → "❌ Failed"Neural Path: @STATUS_EMOJI → emoji.emojize
Framework: rich.console
from rich.console import Console
console = Console()
console.print("[green]✓[/green] Success") # → Colored outputNeural Path: @COLOR_OUTPUT → rich.console
Framework: jinja2
from jinja2 import Template
Template(html_template).render(data=session_data) # → Complete HTMLNeural Path: @HTML_REPORT → jinja2.Template
Framework: weasyprint
from weasyprint import HTML
HTML(string=html_content).write_pdf('output.pdf') # → PDF fileNeural Path: @PDF_EXPORT → weasyprint.HTML
Framework: xlsxwriter
import xlsxwriter
workbook = xlsxwriter.Workbook('output.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write_row(0, 0, headers)Neural Path: @EXCEL_EXPORT → xlsxwriter
Framework: more-itertools
from more_itertools import first
first(messages, default="No messages found") # → Safe defaultNeural Path: @SAFE_DEFAULT → more_itertools.first
Framework: pydantic
from pydantic import BaseModel
class Output(BaseModel):
message: str = "No data"
Output(**data).message # → Always returns stringNeural Path: @TYPE_SAFETY → pydantic.BaseModel
def get_session_summary(session) -> str:
"""One-liner using pure framework delegation"""
# Uses: humanize.intcomma + babel.format_currency + humanfriendly.format_timespan
return f"{humanize.intcomma(msg_count)} messages, {humanfriendly.format_timespan(duration)}, {format_currency(cost, 'USD')}"
def get_formatted_message(msg) -> str:
"""One-liner markdown formatting"""
# Uses: emoji.emojize + arrow.format
return f"{emojize(':speech_balloon:')} **{msg['role']}** ({arrow.get(msg['timestamp']).format('h:mm A')}): {msg['content']}"
def export_as_html(session) -> str:
"""One-liner HTML generation"""
# Uses: jinja2.Template + markdown2.markdown
return Template(HTML_TEMPLATE).render(
messages=[markdown2.markdown(m) for m in messages]
)Add to pyproject.toml:
[tool.poetry.dependencies]
humanize = "^4.0"
babel = "^2.0"
humanfriendly = "^10.0"
arrow = "^1.0"
inflect = "^7.0"
markdown2 = "^2.4"
pygments = "^2.0"
rich = "^13.0"
tabulate = "^0.9"
deepdiff = "^6.0"
emoji = "^2.0"
jinja2 = "^3.0"
weasyprint = "^60.0"
xlsxwriter = "^3.0"
more-itertools = "^10.0"
pydantic = "^2.0"- @NUMBER_FORMAT → humanize
- @CURRENCY_FORMAT → babel
- @DURATION_FORMAT → humanfriendly
- @FILESIZE_FORMAT → humanize
- @TIME_FORMAT → arrow
- @PLURALIZE → inflect
- @MARKDOWN_HTML → markdown2
- @SYNTAX_HIGHLIGHT → pygments
- @JSON_PRETTY → rich
- @TABLE_FORMAT → tabulate
- @DIFF_FORMAT → deepdiff/difflib
- @PROGRESS_BAR → rich.progress
- @STATUS_EMOJI → emoji
- @COLOR_OUTPUT → rich.console
- @HTML_REPORT → jinja2
- @PDF_EXPORT → weasyprint
- @EXCEL_EXPORT → xlsxwriter
- @SAFE_DEFAULT → more_itertools
- @TYPE_SAFETY → pydantic
EVERY feature function MUST:
- Use ONLY framework calls
- Return display-ready strings
- Handle empty/None via framework defaults
- Be a one-liner or max 3 lines
- ZERO custom formatting logic
Example violation:
# ❌ WRONG - Custom formatting
def format_cost(amount):
return f"${amount:.2f}" # Custom logic!
# ✅ RIGHT - Framework delegation
def format_cost(amount):
return format_currency(amount, 'USD') # Framework handles it!