Light Thinking for LLMs: Generating and Tuning a Disk Cleanup Tool

    This article shows how to use "light thinking" mode with large language models to generate a cross-platform disk cleanup CLI tool. It covers why long internal reasoning slows down deterministic engineering tasks, how to write a one-line prompt with acceptance criteria upfront, a review checklist for deletion-capable code, performance tuning techniques, and practical constraints on the model service side. Readers will learn how clear constraints, executable acceptance checks, and default-on safety matter more than model intelligence for high-frequency ops utilities.

    1. Background: The First Response When a Disk Fills Up

    Running out of disk space on a dev machine, test machine, or local workstation is a high-frequency, low-tolerance event. Typical symptoms include: build artifacts failing to write to disk, log writes failing, database temporary file creation errors, and container runtimes refusing to start because they cannot write. At this point, the first-response goal is not “complete remediation” but quickly locating the biggest space consumers and safely reclaiming space.

    The traditional approach relies on a handful of system commands and manual experience: descending into directories level by level to check usage, sorting by file size, identifying cache directories and build intermediates, and confirming what is safe to delete before cleaning up. The problem with this process is that the steps can be automated, but the judgment of “what can be deleted” is highly context-dependent, and the cost of accidental deletion is far higher than the disk being full itself.

    Therefore, an ideal helper tool should have three characteristics: read-only first (analyze before cleaning), explainable (output the Top N space consumers rather than just a total), and safe by default (cleanup actions require explicit confirmation and exclude critical directories).

    2. Why “Thinking Too Long” Actually Slows Down Delivery

    Over the past year, some models in the industry perform very long internal reasoning before answering, showing high time-to-first-token and long waits before output. For coding tasks, long thinking is not always a positive:

    • The task itself is highly deterministic: Disk analysis is a typical engineering problem with “clear rules and well-defined boundaries,” so the marginal benefit of over-reasoning is very low.
    • The interaction rhythm is interrupted: Ops scenarios emphasize a “short feedback loop.” Waiting several minutes for the first piece of code significantly lengthens incident response time.
    • Context gets diluted: Overly long reasoning tends to branch into irrelevant tangents, which actually increases the cost of subsequent manual review.

    A more suitable strategy is “light thinking + strong constraints“: eliminate uncertainty through prompts and acceptance criteria, rather than letting the model repeatedly reason internally. The prompt template below puts this idea into practice.

    3. How to Write a One-Line Prompt: Put Acceptance Criteria Up Front

    1. Write a cross-platform CLI tool: first scan a specified directory, output the Top 20 subdirectory
    2. sizes at the first level, support --min-size filtering and --json output; cleanup mode is off by
    3. default and requires --confirm to execute, with a built-in exclusion list (system directories,
    4. version control metadata directories, user config directories). Provide complete runnable code
    5. and usage instructions.

    This prompt contains four kinds of key information: input (specified directory), output format (Top 20 / JSON), safety boundaries (no deletion by default, explicit confirmation, exclusion list), and deliverables (complete code + usage). Writing acceptance criteria into the prompt significantly compresses the model’s room for free play, and in practice the usability of generated results improves noticeably.

    4. Review Checklist for Generated Code

    Model-generated code cannot be run directly, especially tools with deletion semantics. It is recommended to go through the following in order:

    1. Path handling: Whether paths are uniformly converted to absolute paths, and whether symlinks are avoided, to prevent accidental operations on link targets.
    2. Exclusion rules: Whether they cover critical system directories, version control metadata directories, and the current working directory itself.
    3. Deletion semantics: Whether a two-stage design of “move to a recycle/quarantine directory” or “mark first, then delete” is used.
    4. Permissions and exceptions: Whether it skips and summarizes when encountering directories without permission, or interrupts directly; skipping and outputting statistics is recommended.
    5. Observability: Whether it outputs scan duration, number of failed items, and estimated reclaimable space.

    A schematic core structure (pseudocode):

    1. EXCLUDE = {"/", "/boot", "/etc", "/usr", ".git", ".config"}
    2. def scan(root, min_size):
    3. rows = []
    4. for d in iter_subdirs(root):
    5. if is_excluded(d): continue
    6. size = dir_size(d)
    7. if size >= min_size: rows.append((size, d))
    8. return sorted(rows, reverse=True)[:20]
    9. def clean(targets, confirm=False):
    10. if not confirm:
    11. print("dry-run:", targets); return
    12. for t in targets:
    13. quarantine_move(t) # quarantine first, do not physically delete immediately

    5. Performance and Experience Tuning

    • Incremental scanning: Build a full index on the first run, then only scan changed directories afterward, avoiding recomputing from the root every time.
    • Parallelization: Directory traversal is naturally parallelizable, but watch out for amplified random disk reads; limiting the concurrency level is recommended.
    • Result caching: Persist “path → size → last modified time” as a local index file to support offline review.
    • Layered output: Give the total and Top consumers first, then drill down on demand, avoiding flooding the screen all at once.

    6. Real-World Constraints on the Model Service Side

    In practice, two kinds of engineering problems are commonly encountered: first, throughput fluctuation, where the same model shows noticeably different generation speeds under different access methods; second, unstable connections, where long-output scenarios are prone to interruption, requiring the frontend to implement resumable answers or segmented retries. General mitigation measures include: splitting large tasks into smaller segments for submission, caching generated results locally, and implementing exponential backoff retries on the client.

    For a more stable low-latency experience, a common industry path is deploying lightweight models locally, or using general-purpose cloud capabilities (such as container platforms hosting inference services, object storage for model and index files, and monitoring/alerting to track service availability). Baidu AI Cloud offers corresponding product categories for these general capabilities, which can be flexibly combined according to team size and compliance requirements.

    7. Summary

    The value of “generating a disk cleanup tool with one sentence” lies not in how smart the model is, but in whether the constraints are written clearly, whether acceptance is executable, and whether safety is on by default. Lowering the thinking intensity and strengthening the prompt and guardrails is the right way to approach these high-frequency ops utilities.