DEV Community

Arjun M
Arjun M

Posted on

I built a Python CLI toolkit because everything felt fragmented

Klix Preview

Most Python CLI tools start simple… and then slowly turn into chaos.

You begin with a couple of commands, maybe argparse, maybe click. Then you add prompts. Then state. Then formatted output. Then some sort of flow. And suddenly your “small CLI tool” looks like a badly stitched Frankenstein of utilities.

I got tired of that.

So I built Klix — a Python framework for building structured, interactive, and polished command-line applications.


The Problem

Building a real CLI app (not just a script) usually means juggling:

  • Command parsing
  • User input flows
  • State management
  • Formatted output
  • Navigation / interaction
  • Consistency across commands

Most tools solve one of these well. Very few help you build the whole experience cleanly.

So you either:

  • Glue multiple libraries together
  • Or reinvent half of it yourself

Neither option ages well.


What Klix Is

Klix is a command-first CLI framework that brings everything into one place:

  • Command routing (/commands)
  • Typed session state
  • Prompt-driven input
  • Rich terminal rendering
  • Middleware & lifecycle events
  • Lightweight layout system
  • Built-in UI helpers (forms, tables, panels, etc.)

Instead of stitching tools together, you build your app on a single structured runtime.


A Minimal Example

from dataclasses import dataclass
import klix

@dataclass
class State(klix.SessionState):
    count: int = 0

app = klix.App(
    name="demo",
    version="0.1.0",
    description="Simple Klix app",
    state_schema=State,
)

@app.command("/hello")
def hello(session: klix.Session):
    session.state.count += 1
    session.ui.print(f"Hello! Run #{session.state.count}")

app.run()

Enter fullscreen mode Exit fullscreen mode

That’s it. You get:

  • Structured commands
  • Persistent session state
  • Clean output
  • An interactive loop Without duct-taping libraries together.

What Makes It Different

Instead of being “just a CLI parser”, Klix treats your app like a system:

  1. Command-first design Everything revolves around commands like: /login /deploy /help
  2. Typed session state No more random globals or passing variables everywhere.
  3. Built-in interaction model Prompts, confirmations, selections — already handled.
  4. Rich output with fallback Pretty when possible, safe when not.
  5. Middleware & events Hook into lifecycle and behavior cleanly.
  6. Layout primitives Structure your CLI instead of dumping text endlessly. ---

What You Can Build

Klix is useful for things like:

  • Developer tools
  • Internal admin CLIs
  • Interactive setup tools
  • Terminal assistants
  • Workflow-driven apps
  • Data exploration tools Basically, anything where a CLI needs to feel like an experience, not a script.

Getting Started

Install Klix:

pip install klix

Enter fullscreen mode Exit fullscreen mode

Create a new project:

klix init my-app
cd my-app
python main.py

Enter fullscreen mode Exit fullscreen mode

You’ll get a working interactive CLI that you can start extending immediately.


Contributing

Klix is open source, and contributions are welcome.
You can help by:

  • Reporting bugs
  • Suggesting features
  • Improving docs
  • Adding examples
  • Contributing code If you’re contributing code:
  • Fork the repo
  • Create a feature branch
  • Make your changes
  • Submit a pull request Try to keep changes focused and readable. This is a developer tool, not a puzzle.

Current Direction

Klix is still evolving, but the goal is clear:

"Make building interactive CLI apps in Python simple, structured, and enjoyable."

Future improvements will focus on:

  • Better developer ergonomics
  • Richer UI components
  • Improved layout system
  • Plugin/extensibility model

Final Thoughts

I didn’t build Klix to replace everything.
I built it because building CLI apps felt unnecessarily messy. If you’ve ever tried to structure a non-trivial CLI and ended up fighting your own codebase, Klix might save you some time.

🔗 GitHub: https://github.com/Arjun-M/Klix

If nothing else, at least now your CLI doesn’t have to look like it evolved by accident.

Top comments (0)