SuperAPI AI Directory

lx-git

General & other

View repository

Updated 10-16 08:43

About this skill

Git-style knowledge base workflow

Prerequisites: Requires the lx CLI to be configured and logged in.

⚡ When should this skill be used?

Enter scenario:

  • User says "clone the knowledge base to local"/"push local changes"
  • User says "roll back the version"/"view what was changed locally"
  • User says "create a checkpoint"/"rollback-able changes"
  • User wants to perform multi-step editing, batch modifications, or needs rollback-able change management

Prohibited in this skill:

  • Do not edit content directly locally: User says "edit the content of a page" → Switch immediately to the lx-entry or lx-block skill
  • Do not browse knowledge base content (read-only): User says "browse the knowledge base"/"look at the structure" → Switch immediately to the lx-sh skill(virtual Shell)

⚡ How to choose a command? (decision tree)

识别场景 →
├── 把远程知识库拉到本地编辑? → lx git clone
├── 查看本地改了什么? → lx git status / lx git diff
├── 暂存 + 提交本地修改? → lx git add + lx git commit
├── 推送本地修改到远程? → lx git push
├── 拉取远程最新内容? → lx git pull
├── 查看提交历史? → lx git log
├── 回退本地版本? → lx git reset
├── 回退远程版本? → lx git revert(危险操作)
├── 查看远程信息? → lx git remote
├── 管理多个本地工作区? → lx worktree add/list/remove
└── 用 Shell 浏览知识库? → 切换到 lx-sh skill

⚠️ High-risk operations and default priority paths

A checkpoint must be created for multi-step modifications:

  • User wants to perform multi-step editing, batch modifications → Must first lx git clone create a local workspace
  • At each important milestone, execute lx git commit, ensuring rollback-ability
  • Pure online editing has no version record; once overwritten, rollback is impossible

Default priority paths:

  1. Commit before pushing → when there are uncommitted changes, lx git push will report an error
  2. Preview with dry-run first → for push and rollback operations, it is recommended to first add --dry-run to preview
  3. force push requires confirmation → --force will overwrite remote conflicts, and the user's intent must be confirmed

revert rolls back the remote (dangerous operation):

  • lx git revert rolls back the remote content to the state of the specified commit
  • It directly modifies the remote—this is a dangerous operation
  • Must first use --dry-run to preview, and execute only after confirming the user's intent

Available tools

lx git — core version control

Command Description
lx git clone Clone the remote knowledge base to local
lx git add Stage files
lx git commit Commit local changes
lx git status View working tree status
lx git diff View change differences
lx git log View commit history
lx git pull Pull the latest content from remote
lx git push Push local changes to remote
lx git reset Reset local HEAD
lx git revert Roll back remote to a specified commit
lx git remote View remote repository information

Detailed parameters:lx git --help

lx worktree — multi-workspace management

Command Description
lx worktree add Create a new worktree
lx worktree list List all worktrees
lx worktree remove Delete a worktree
lx worktree status View worktree status
lx worktree diff View worktree differences
lx worktree commit Commit worktree changes
lx worktree log View worktree commit history
lx worktree push Push the worktree to remote
lx worktree pull Pull remote to worktree
lx worktree reset Reset worktree HEAD
lx worktree revert Revert worktree to remote version

Detailed parameters:lx worktree --help

🎯 Execution rules

  1. Must clone first: All lx git commands need to be executed in the worktree directory (containing .lxworktree). If the user does not yet have a local workspace, first guide them to lx git clone。
  2. space_id supports URL:lx git clone of <space_id> You can pass the complete knowledge base URL, and the CLI will automatically extract the space_id.
  3. Commit before push: When there are uncommitted changes, lx git push will report an error, and you must first lx git add . && lx git commit -m "..."。
  4. Preview with dry-run first: For push and revert operations, it is recommended to first add --dry-run to preview, and after confirming it is correct, execute it formally.
  5. Force push requires confirmation:--force will overwrite remote conflicts, so the user's intent must be confirmed.
  6. Revert remote:lx git revert reverts the remote content to the state of the specified commit, which directly modifies the remote—this is a dangerous operation.
  7. Markdown file = page:.md files are treated as knowledge base pages, and other files are handled as attachments. During push, the creation method is automatically selected based on the file type.
  8. worktree vs git:lx worktree is used to manage multiple independent local workspaces (similar to git worktree), suitable for operating multiple knowledge bases at the same time.lx git operates within the current worktree.

Typical combined workflow

First clone and edit

# 克隆知识库到本地
lx git clone sp_xxx ./my-kb

# 进入目录
cd my-kb

# 查看本地文件结构
ls -la

# 编辑 .md 文件...(用编辑器修改)

# 查看改了什么
lx git status
lx git diff

# 暂存 + 提交 + 推送
lx git add .
lx git commit -m "更新了项目计划"
lx git push

Pull remote updates

cd my-kb
lx git pull
# → 自动拉取最新内容并创建 commit

Preview before push

lx git push --dry-run
# → 显示哪些文件会被创建/更新,不实际执行

# 确认无误后正式推送
lx git push

Revert remote version

# 查看历史
lx git log

# 先预览回退效果
lx git revert abc1234 --dry-run

# 确认后执行
lx git revert abc1234