Skip to main content

SKY-A104 · AI-code defects

Public CLI surface drift

Medium

A command-line tool's flags, such as --dry-run, are a public interface: scripts, CI jobs and other people's muscle memory depend on them. SKY-A104 reports a change that removes or renames a flag without keeping the old spelling.

Languages
Python (argparse, Click, Typer)
Turned on by
skylos . --ai-defects --diff origin/main (or -a) on a change
Quality gate
counted toward the gate limits (full and diff scans). Counts toward max_ai_defects when the scan has a change to compare.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A renamed flag breaks every script that still passes the old one, often only when that script next runs in production or CI. Coding agents rename flags while tidying code and rarely mention it in the summary.

What Skylos flags

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

invoicer/cli.py · Python · changed
import argparse  def build_parser():    parser = argparse.ArgumentParser(prog="invoicer")    parser.add_argument("--input", required=True)Removed:     parser.add_argument("--dry-run", action="store_true")Added:     parser.add_argument("--preview", action="store_true")    return parser

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

invoicer/cli.py · Python · changed
import argparse  def build_parser():    parser = argparse.ArgumentParser(prog="invoicer")    parser.add_argument("--input", required=True)Removed:     parser.add_argument("--dry-run", action="store_true")Added:     parser.add_argument("--preview", "--dry-run", action="store_true")    return parser

Why Skylos leaves it alone

The new name was added and the old spelling kept as an alias, so scripts that pass --dry-run still work.

More languages

Python

Flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

invoicer/sync.py · Python · changed
import click  @click.command()Removed: @click.option("--force", is_flag=True)@click.option("--limit", type=int, default=100)Removed: def sync(force, limit):Removed:     click.echo(f"syncing {limit} invoices (force={force})")Added: def sync(limit):Added:     click.echo(f"syncing {limit} invoices")

Not flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

invoicer/sync.py · Python · changed
import click  @click.command()Removed: @click.option("--force", is_flag=True)Added: @click.option("--force/--no-force", default=False)@click.option("--limit", type=int, default=100)def sync(force, limit):    click.echo(f"syncing {limit} invoices (force={force})")

Why Skylos leaves it alone

The option line changed, but --force is still on the new line (now with a --no-force partner), so nothing callers use was removed.

How Skylos decides

  1. Runs with --ai-defects when there is a change to compare: in a diff scan (--diff or --diff-base), or in a full scan of a Git checkout with uncommitted changes. It reads the Git diff of each changed file against the base.
  2. Reads a file when it looks like a command-line module: named cli.py, commands.py or main.py, under a cli/ or commands/ folder, or with add_argument(, click.option(, typer.Option( or Option( anywhere in its diff.
  3. Collects the --flag names on removed and added lines that hold one of those option calls. Commented-out lines are skipped.
  4. Reports each flag that was on a removed line and is on no added line in the same file, once per flag. The line is the removed line's number in the base version.

How to fix it

Keep the old spelling working: add it as an alias next to the new name, and remove it only in a release whose notes say so. If the flag really must go, say so in the pull request so the reviewer can check callers.

invoicer/cli.py · Python · the fix, against the flagged file
import argparse  def build_parser():    parser = argparse.ArgumentParser(prog="invoicer")    parser.add_argument("--input", required=True)Removed:     parser.add_argument("--preview", action="store_true")Added:     parser.add_argument("--preview", "--dry-run", action="store_true")    return parser

When it can be wrong

  • A deliberate removal of a deprecated flag is reported. That is intended: the finding asks the reviewer to confirm the break.
  • A flag moved to a different file in the same change is reported, because added and removed flags are compared within one file.
  • A flag removed by deleting its whole line is reported at that line's number in the base version. A --diff scan keeps only findings on changed lines of the new file, so it usually drops this one; a full scan of a checkout with uncommitted changes, or -a without --diff, reports it. The Click example above is checked that way.
  • Only Python option calls are read. Command-line flags declared in other languages, a removed subcommand or a changed default are not seen.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • An inline # skylos: ignore[SKY-A104] comment does not silence it in Skylos 5.6.0: this rule reports a path relative to the project, and the inline-ignore lookup does not match it. Use the setting below.

    Python
    parser.add_argument("--preview", action="store_true")  # skylos: ignore[SKY-A104]
  • [tool.skylos] ignore = ["SKY-A104"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.