---
name: refactoring-code-to-satisfy-strict-size-constraints
description: "Refactors code to meet strict size budgets by profiling byte usage, compacting data structures, and trimming redundant logic, then running tests and benchmarks. Use when source code must shrink while preserving logic and performance."
license: CC-BY-4.0
compatibility: "Needs access to: GitHub, Terminal."
metadata:
  author: "BotBento Editorial"
  version: "2026-10-15"
  source: "https://botbento.com/usecases/refactoring-code-to-satisfy-strict-size-constraints/"
  kind: skill
  hermes:
    tags: ["coding", "optimization", "refactoring", "benchmarking"]
    category: coding
    requires_toolsets: ["terminal"]
---
# Refactoring code to satisfy strict size constraints

Analyze code to reduce binary footprint while preserving logic and competitive performance.

## When to use

Inspect source code to identify byte-heavy patterns, simplify data structures, and prune redundant logic to meet strict size targets. The bot runs automated test suites and benchmarks after each refactoring pass to verify correctness against baseline engines.

## Inputs

- `code`: Source code or repository the person wants refactored to reduce its size.
- `target_size_budget`: Maximum allowed build or binary size the refactored code must meet.

## Steps

1. When you ask: Submit code and target size budget (A person submits source code and a target size budget in chat.)
2. Profile byte usage and minify logic
3. Review optimized build and tests

## Instructions

Analyze the target codebase for size optimization opportunities such as data structure compacting and logic trimming. Run test matches against the baseline test suite in terminal to verify rule compliance and performance. Do not commit or push changes to github without user approval.

## Approvals

- Committing or pushing refactored code to GitHub requires user approval.

## Output

Report of the optimized build, byte-size results, and test and benchmark outcomes. (format: markdown)

## Source

Summarized in our own words from [Show HN: Sameshi – a ~1200 Elo chess engine that fits within 2KB](https://news.ycombinator.com/item?id=47014500) (Hacker News, checked 2026-10-15). Any results described there are the authors’ own.

From the BotBento use-case directory: https://botbento.com/usecases/refactoring-code-to-satisfy-strict-size-constraints/. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
