StaticFlow CLI Publisher
Use this skill to publish Markdown/blog notes into LanceDB and verify results. It is a publish/verify skill, not a table-repair skill.
When To Use
- Publish one Markdown article (
write-article). - Batch import images (
write-images) or sync a notes directory (sync-notes). - Query/update/upsert data in
articles,images, andtaxonomies. - Update bilingual fields from files (
db update-article-bilingual). - Backfill article vectors (
db backfill-article-vectors). - Run backend-equivalent local API queries for verification/debug.
- Do routine post-batch index coverage only after successful writes on healthy tables.
- Manually complete a music wish (
complete-wish).
Execution Policy (Mandatory)
- Context-first: read article and metadata from current context/local files first.
- LLM-native generation: generate missing metadata and summary directly in-session.
- Do not call external model APIs, proxy scripts, or sub-agent model commands.
- Use CLI only for fetch fallback, write/sync, and verification.
- Keep intermediate artifacts under
/tmp/, not in the project root directory. - Never run destructive operations unless explicitly requested.
- Treat duplicate-key, merge-ambiguity, and scalar-index errors as storage-integrity incidents, not routine publish failures.
- On a live production DB with a running backend, do not improvise repair by chaining
delete-rows,drop-index,ensure-indexes,optimize --all --prune-now,cleanup-orphans, orrebuild-table-stable. - If storage maintenance or table repair is the main task, switch to
lancedb-optimizeor an explicit repair workflow instead of continuing this skill.
Load Extra Context
- Required:
references/publish-checklist.md - If summary generation is needed:
../article-summary-architect/SKILL.md - Optional docs:
README.md,docs/cli-user-guide.zh.md
Preconditions
- Resolve CLI in this order:
./target/release/sf-cli./target/debug/sf-cli../target/release/sf-clisf-clifromPATH
- Verify CLI works:
<cli> --help- Build if needed:
cargo build -p sf-cli --release
- Build if needed:
- If the checkout is newer than the chosen binary, rebuild before use.
- Do not prefer legacy
./bin/sf-clisnapshots for storage-format-sensitive writes. - Verify DB path exists.
- Verify DB tables:
<cli> db --db-path <db_path> list-tables- required:
articles,images,taxonomies - current content DB may also include runtime tables such as
article_views,api_behavior_events,article_requests*, andinteractive_*
- If DB is uninitialized, ask user before:
<cli> init --db-path <db_path>
Hard Stop Conditions (Mandatory)
Stop the normal publish workflow immediately if any of these appear:
Ambiguous merge insertsRowAddrTreeMap::from_sorted_iter called with non-sorted input- Duplicate taxonomy/article key errors that persist after input-side dedupe
- Full-list reads succeed but filtered single-row reads fail on a long-running backend
- Any sign that the target table/index layout is already unhealthy
Required response:
- Stop retries and stop mutating the affected tables.
- Capture diagnostics first:
<cli> db --db-path <db_path> audit-storage --table <table><cli> db --db-path <db_path> list-indexes <table> --with-stats- targeted
query-rows/count-rows
- Preserve rollback state before repair.
- Escalate to a stable-row-id rebuild / temp-DB rewrite workflow.
- If a table directory is rebuilt or swapped while backend is still running, assume the old backend may keep a stale manifest/index view; validate with a fresh process and plan blue-green restart before switching traffic.
Publication Workflow
A) Single Article (write-article)
- Read Markdown body/frontmatter.
- Ensure required metadata in final payload:
summarytagscategorycategory_description- when bilingual publish is requested:
content_enanddetailed_summary.zh/en
- Metadata priority:
- frontmatter
- explicit user CLI args
- skill inference from content + existing taxonomy records
- Preserve source date:
- use
--datewhen user provides it - else keep frontmatter
date - else derive from file birth time/mtime (
YYYY-MM-DD) and pass--date
- use
- Summary gate (before publish):
- regenerate
detailed_summary.zh/enwhen missing/stale/unstructured - follow
article-summary-architectquality contract
- regenerate
- Publish command:
- frontmatter complete:
<cli> write-article --db-path <db_path> --file <post.md>
- frontmatter incomplete:
<cli> write-article --db-path <db_path> --file <post.md> --summary "..." --tags "a,b" --category "..." --category-description "..."
- with custom id:
--id <custom_id>(defaults to markdown file stem)
- with explicit date:
--date YYYY-MM-DD
- explicit bilingual files (preferred for non-frontmatter workflow):
<cli> write-article --db-path <db_path> --file <post.md> --summary "..." --tags "a,b" --category "..." --category-description "..." --content-en-file <content_en.md> --summary-zh-file <summary_zh.md> --summary-en-file <summary_en.md>
- with pre-computed vectors:
--vector <json_array>/--vector-en <json_array>/--vector-zh <json_array>
- with auto-embedding language hint:
--language en|zh
- disable auto-optimize after write:
--no-auto-optimize
--no-auto-optimizeis only for healthy-table publish batching; it is not a repair switch
- frontmatter complete:
- Local image import (optional):
--import-local-images- optional
--media-root <path>(repeatable) - optional
--generate-thumbnail --thumbnail-size <n> - supports
,![[path]],![[path|alias]]
- Verify publication:
- article row exists
- taxonomy rows updated
- images imported when expected
sf-cli api get-article <id>returns the updated row on a fresh CLI connection- if any verification step throws merge/index integrity errors, stop instead of attempting ad-hoc maintenance
- Report:
- article id
- inferred metadata (if any)
- summary generated/reused
- bilingual fields generated/reused (
content_en,detailed_summary.zh/en) - image import count and warnings
B) Image Batch (write-images)
<cli> write-images --db-path <db_path> --dir <image_dir> [--recursive] [--generate-thumbnail] [--thumbnail-size <n>] [--no-auto-optimize]
Storage note:
images.datais blob v2 in current production layoutimages.thumbnailremains regularBinary- prefer verifying image readability through
<cli> api get-image ...instead of assuming raw ArrowBinary
C) Notes Sync (sync-notes)
<cli> sync-notes --db-path <db_path> --dir <notes_dir> [--recursive] [--generate-thumbnail] [--thumbnail-size <n>] [--language <en|zh>] [--default-category <name>] [--default-author <name>] [--no-auto-optimize]
DB and API Quick Map
- Safe publish/debug ops:
<cli> db --db-path <db_path> <subcommand>- table info:
list-tables,describe-table <table>,count-rows <table> [--where ...] - targeted data checks:
query-rows,update-rows,list-indexes <table> [--with-stats] - upsert:
upsert-article --json <json>,upsert-image --json <json> - bilingual:
update-article-bilingual --id <id> [--content-en-file ...] [--summary-zh-file ...] [--summary-en-file ...] - vectors:
backfill-article-vectors [--limit N] [--dry-run] - special:
reembed-svg-images [--limit N] [--dry-run] - schema:
create-table <table>
- table info:
- Escalation-only repair/maintenance ops:
delete-rowsensure-indexes,drop-index <name>optimize,cleanup-orphans [--table <table>]rebuild-table-stable <table>,migrate-images-blob-v2,drop-table <table> --yes- only use these when the user explicitly asked for DB repair/maintenance and you have a rollback and verification plan
- API-equivalent ops:
<cli> api --db-path <db_path> <subcommand>- articles:
list-articles [--tag ...] [--category ...],get-article <id>,related-articles <id> - search:
search --q "...",semantic-search --q "..." - taxonomy:
list-tags,list-categories - images:
list-images,get-image <id-or-filename>,search-images --id <id>,search-images-text --q "..."
- articles:
- Legacy query shortcut:
<cli> query --table <table> [--where ...] [--columns ...] [--limit N] [--offset N] [--format table|vertical]
Healthy-Table Post-Batch Maintenance
Only after the writes have already succeeded and the affected tables are healthy:
- If you intentionally used
--no-auto-optimizefor batching, finish with:<cli> db --db-path <db_path> optimize articles<cli> db --db-path <db_path> optimize images
- Use
cleanup-orphans/optimize --all --prune-nowonly as explicit storage maintenance, not as write-failure recovery. - If compaction/prune is the main task, use the
lancedb-optimizeskill.
Error Handling
- Missing metadata: infer and continue, but report inferred fields explicitly.
- Image resolution warnings: rerun with
--media-root. - Partial success: rerun only failed steps, then verify again.
- Integrity symptoms (
Ambiguous merge inserts,non-sorted input, repeated duplicate keys, stale-backend manifest mismatch) are stop conditions, not retry conditions. - Never use
delete-rows,drop-index,ensure-indexes,optimize,cleanup-orphans, orrebuild-table-stableas an ad-hoc response to a failed write on a live production DB. - Never run
drop-tableordelete-rows --allunless user explicitly requests it.