Project — CLI Task Manager

Design a command-line task manager that combines the complete language-fundamentals stage.

What you will build

A command named tasker that stores tasks in a JSON file.

tasker add "Learn slices"
tasker list
tasker complete 1
tasker remove 1

This first checkpoint defines behaviour before implementation.

What you will learn

  • modules and packages;
  • structs, defined types, slices, and methods;
  • parsing input and returning errors;
  • JSON and file ownership;
  • dependency boundaries that make tests possible.

User stories

  1. As a learner, I can add a task with a non-empty title.
  2. I can list tasks in creation order.
  3. I can mark an existing task complete.
  4. I can remove a task.
  5. My tasks remain after the process exits.
  6. Invalid commands explain what I need to correct.

Command contract

tasker add <title>
tasker list [--all]
tasker complete <id>
tasker remove <id>
tasker help

Choose predictable exit behaviour:

  • 0: command completed successfully;
  • non-zero: invalid input, missing task, or storage failure;
  • ordinary output goes to stdout;
  • diagnostics and usage errors go to stderr.

The exact non-zero code policy can become more detailed later. Start consistent.

Domain model

type TaskID int

type Task struct {
    ID        TaskID    `json:"id"`
    Title     string    `json:"title"`
    Completed bool      `json:"completed"`
    CreatedAt time.Time `json:"created_at"`
}

Questions to answer before writing storage:

  • Can an ID be zero or negative?
  • Is an empty or whitespace-only title valid?
  • Are IDs reused after deletion?
  • Does complete succeed when already complete?
  • How are corrupted files reported?

Suggested decisions:

  • IDs start at 1 and are never reused within one data file.
  • Titles are trimmed and must remain non-empty.
  • Completing an already-complete task succeeds without changing state.
  • Corrupt data returns an error; it is never silently replaced.

Package shape

tasker/
├── go.mod
├── cmd/tasker/main.go
└── internal/task/
    ├── task.go
    ├── service.go
    ├── store.go
    └── file_store.go

Do not create extra packages until responsibility is clear.

Define the storage boundary

type Store interface {
    Load(ctx context.Context) ([]Task, error)
    Save(ctx context.Context, tasks []Task) error
}

For a small single-process project, replacing the whole file is understandable. A database would need a different, operation-oriented interface. Interfaces should match the consumer and use case rather than pretending every storage system is identical.

Acceptance checklist

  • A new data file is created only after the first successful change.
  • Whitespace-only titles are rejected.
  • Unknown and malformed commands return useful errors.
  • A corrupt JSON file is preserved and reported.
  • Writes do not intentionally leave half-written JSON.
  • Domain logic is tested without the real filesystem.
  • File behaviour is tested inside t.TempDir().

Practice

Write the command contract and domain rules in your own README. Then create the module and package directories without implementing the commands.

Summary

  • Begin a project with observable behaviour and failure decisions.
  • Give domain identifiers a distinct type.
  • Keep storage behind the behaviour the application needs.
  • Preserve corrupted user data instead of overwriting it silently.
  • Use acceptance criteria to decide when the project is complete.

Ready to wrap up?

Mark this complete when you can explain the main idea and finish the practice task.

Copyright © 2026