Command-line tool for managing Hashnode blogs
hn is a CLI that allows you to manage your Hashnode blog from local Markdown files. You can stage changes, preview planned updates, and apply them to your Hashnode publication.
scoop bucket add hashnode-cli https://github.com/adil-adysh/scoop-bucket.git
scoop install hn
scoop update hn # update if already installed
hn --help # verify installationgit clone https://github.com/adil-adysh/hashnode-cli.git
cd hashnode-cli
go build -o hn ./cmd/hashnode-cli # Build locally
./hn --help # Verify installationcd hashnode-cli
go run ./cmd/hashnode-cli stage posts/export HASHNODE_TOKEN="your-token"
hn initCreates:
.hashnode/— CLI state directoryhashnode.sum— ledger
hn import- Converts posts to Markdown
- Generates snapshots and ledger entries
hn stage posts/my-article.md # Stage a file
hn stage posts/ # Stage directory
hn stage delete posts/old.md # Mark for deletion
hn stage list # View staged fileshn planShows:
- 🟢 CREATE — new posts
- 🟡 UPDATE — modified posts
- 🔴 DELETE — marked for deletion
- ⚪ SKIP — unchanged
hn apply --dry-run # Preview first
hn apply # Apply changes
hn apply --yes # Apply without confirmation for deletions| Command | Description |
|---|---|
hn init |
Initialize repository with Hashnode config |
hn import |
Import posts from Hashnode |
hn stage <path> |
Stage files for sync |
hn stage delete <path> |
Mark post for deletion |
hn unstage <path> |
Remove from staging |
hn stage list |
List staged files |
hn plan |
Preview planned changes |
hn apply |
Apply staged changes |
hn gc |
Clean unreferenced snapshots |
Series commands are not yet supported.
my-blog/
├── .hashnode/ # CLI state
│ ├── snapshots/ # SHA256 snapshots
│ ├── stage.yml # Staging intent
│ └── hashnode.lock # Concurrency lock
├── hashnode.sum # Ledger
├── posts/ # Markdown content
└── .gitignore
---
title: "Understanding Go Interfaces"
slug: "go-interfaces-deep-dive"
published: true
tags: ["go","programming"]
canonical: "https://myblog.dev/go-interfaces"
---Required: title
Optional: slug, published, tags, canonical
Working Tree → Staging Area → Ledger (hashnode.sum) → Remote (Hashnode API)
Flow: Stage → Plan → Apply → Garbage Collect
- Lock file prevents multiple simultaneous
apply - Ledger updates are applied atomically
- Snapshots are protected from accidental staging
hn gc --dry-run # Preview cleanup
hn gc # Remove unreferenced snapshots
hn gc --verify # Verify integrityAutomatically runs after staging, unstaging, or applying changes.
- Go 1.24+
- Cobra CLI
- genqlient for GraphQL
Build & run:
go build -o hn ./cmd/hashnode-cli
go run ./cmd/hashnode-cli stage posts/- Fork & clone
- Make changes with tests
- Submit PR with description
Apache License 2.0 — see LICENSE