agentleFS
james5101james5101/jobtrack/.claude/skills/add-cli-command/SKILL.md

add-cli-command

Skill2 starsChanged 6 months agoMITView on GitHub

Add a new command to the jobtrack CLI (src/jobtrack/cli.py). Use this when the user asks for a new `jobtrack <verb>` subcommand. Keeps business logic out of cli.py and reuses the project's resolution + error patterns.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. dotnet/sdk★ 3.2ksame name
    2. lbedner/aegis-stack★ 146same name
    3. GCarin1/Doctrina★ 1same name
    4. miruky/harness-sample★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Format output with rich: Use the module-level console.

    line 14
  2. Very specific:

    Add a function to core.py: if there's new business logic.

    line 19
  3. Very specific:

    File path arguments: use typer.Option(..., exists=True, dir_okay=False) to get free validation.

    line 42

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add a new CLI command

The CLI lives in src/jobtrack/cli.py. It's a typer app with seven commands today: add, list, show, open, status, note, tag. The pattern is consistent — follow it.

Hard rules

  • Business logic goes in core.py, never in cli.py. The CLI parses args, calls a core function, formats output. If the new command needs new logic, add a function to core.py first and call it from the typer command.
  • Use _resolve_or_exit(query) for any command that takes an <id|company> argument. It handles ambiguity (prints a numbered list and exits 1) and not-found (exits 1) uniformly. Don't reimplement.
  • Format output with rich. Use the module-level console. Tables for lists, console.print_json for structured data, [green]...[/green] / [red]...[/red] for status messages.
  • Exit codes: 0 success, 1 resolution/runtime failure, 2 bad input (usage error).

The pattern

  1. Add a function to core.py if there's new business logic. Keep it pure (takes ids/values, returns or mutates via storage). Don't import typer or rich there.
  2. Add the typer command in cli.py:
    @app.command("verb")
    def verb_cmd(
        query: str = typer.Argument(..., help="ID or company"),
        # ... other args ...
    ):
        """One-line help string — shown by `jobtrack verb --help`."""
        meta = _resolve_or_exit(query)
        result = core.<the_thing>(meta.id, ...)
        console.print(f"[green]Did the thing to[/green] {meta.id}")
  3. Naming conflicts with Python builtins: the typer function name can shadow builtins (list, open, etc.) which makes for awkward Python. The existing pattern is to name the function <verb>_cmd and pass the verb as the first arg to @app.command():
    @app.command("list")
    def list_cmd(...): ...
  4. Enum arguments: typer renders ApplicationStatus natively as a constrained choice — see status_cmd. Use this rather than a free string with manual validation.
  5. File path arguments: use typer.Option(..., exists=True, dir_okay=False) to get free validation. See the add command's --resume for the pattern.
  6. Update the README quickstart. New commands belong in the ## Quickstart block. Keep the example minimal — one realistic invocation.
  7. Test the underlying core function in tests/test_core.py. CLI tests are intentionally light per the brief — there is no tests/test_cli.py today, and that's a deliberate choice. If you genuinely need argument-parsing coverage (e.g. a tricky flag combination), create tests/test_cli.py with typer's CliRunner; otherwise rely on core tests + manual smoke (uv run jobtrack verb --help).

Skeleton

@app.command("verb")
def verb_cmd(
    query: str = typer.Argument(..., help="ID or company"),
    flag: bool = typer.Option(False, "--flag", help="Describe."),
):
    """Imperative one-liner. (`jobtrack verb --help` shows this.)"""
    meta = _resolve_or_exit(query)
    try:
        result = core.do_the_thing(meta.id, flag=flag)
    except ValueError as e:
        console.print(f"[red]{e}[/red]")
        raise typer.Exit(2)
    console.print(f"[green]Done[/green] {result.id}")

If the command should also be exposed via MCP

Decide deliberately. The brief explicitly keeps add CLI-only because it needs files on disk at submit time. Most read-style commands belong in MCP too; most write-style commands do if they're things you'd do from a chat session. If yes, use the add-mcp-tool skill next.

Anti-patterns

  • ❌ Calling storage.* directly from the CLI. Go through core.
  • ❌ Catching core.AmbiguousQuery / core.NotFound inline — that's what _resolve_or_exit is for.
  • ❌ Using print() instead of console.print(). Loses the rich formatting and the Windows UTF-8 setup at the top of cli.py was specifically done for the console object.
  • ❌ Putting business logic tests in test_cli.py (if you create it). Business logic belongs in test_core.py; CLI tests are for argument parsing and exit codes only.

Verify

uv run pytest -v
uv run jobtrack verb --help     # confirm help text
uv run jobtrack verb <real-id>  # smoke test against the dev store

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.