Skip to content

Fastest way to scaffold your LLM powered personal knowledge base - Obsidian, Claude Code, qmd, Github

feat: add GitHub repo creation prompt and fix piped-stdin readline hang

jessepinkman990000b888bc141b
diff --git a/.claude/skills/pack-test/SKILL.md b/.claude/skills/pack-test/SKILL.md
index 9c3f1b1..3e64687 100644
--- a/.claude/skills/pack-test/SKILL.md
+++ b/.claude/skills/pack-test/SKILL.md
@@ -23,10 +23,10 @@ Produces `claude-second-brain-<version>.tgz` in the repo root, where `<version>`
**Step 2 — Scaffold via npx**
```bash
-echo "" | npx -y claude-second-brain-$(node -p "require('./package.json').version").tgz test-vault
+printf '\n\n' | npx -y claude-second-brain-$(node -p "require('./package.json').version").tgz test-vault
```
-Use `npx` with the `file:` prefix — without it, npx tries to execute the tarball as a shell script and fails with "Permission denied". Pass `test-vault` as the target dir argument to skip the interactive folder name prompt. Pipe `echo ""` to accept the default qmd path (`~/.cache/qmd/index.sqlite`) without interactive input. The vault is created in the repo root and cleaned up in Step 4.
+Use `npx` with the `file:` prefix — without it, npx tries to execute the tarball as a shell script and fails with "Permission denied". Pass `test-vault` as the target dir argument to skip the interactive folder name prompt. Pipe `printf '\n\n'` to accept defaults for both the qmd path prompt and the GitHub repo prompt (`y/N` → defaults to `N`, skipping GitHub setup). The vault is created in the repo root and cleaned up in Step 4.
**Step 3 — Verify checklist**
diff --git a/.github/workflows/pack-test.yml b/.github/workflows/pack-test.yml
index ce58a44..fde68ad 100644
--- a/.github/workflows/pack-test.yml
+++ b/.github/workflows/pack-test.yml
@@ -56,8 +56,8 @@ jobs:
check "sources/pdfs/" test-vault/sources/pdfs
check "sources/personal/" test-vault/sources/personal
check ".claude/skills/setup" test-vault/.claude/skills/setup
- check ".claude/skills/ingest" test-vault/.claude/skills/ingest
- check ".claude/skills/query" test-vault/.claude/skills/query
+ check ".claude/skills/brain-ingest" test-vault/.claude/skills/brain-ingest
+ check ".claude/skills/brain-search" test-vault/.claude/skills/brain-search
check ".claude/skills/lint" test-vault/.claude/skills/lint
check ".claude/skills/qmd-cli" test-vault/.claude/skills/qmd-cli
check "scripts/qmd/setup.ts" test-vault/scripts/qmd/setup.ts
@@ -65,6 +65,24 @@ jobs:
check "scripts/qmd/package.json" test-vault/scripts/qmd/package.json
check "CLAUDE.md" test-vault/CLAUDE.md
check "mise.toml" test-vault/mise.toml
+ check "~/.claude/skills/brain-ingest/SKILL.md" "$HOME/.claude/skills/brain-ingest/SKILL.md"
+ check "~/.claude/skills/brain-search/SKILL.md" "$HOME/.claude/skills/brain-search/SKILL.md"
+
+ grep_check() {
+ local label="$1"
+ local pattern="$2"
+ local file="$3"
+ if grep -q "$pattern" "$file" 2>/dev/null; then
+ echo "PASS: $label"
+ else
+ echo "FAIL: $label — pattern '$pattern' not found in $file"
+ fail=1
+ fi
+ }
+
+ grep_check "CLAUDE.md INDEX_PATH is absolute" "INDEX_PATH=/" test-vault/CLAUDE.md
+ grep_check "setup.ts DB is hardcoded absolute path" 'const DB = "/' test-vault/scripts/qmd/setup.ts
+ grep_check "global brain-ingest INDEX_PATH is absolute" "INDEX_PATH=/" "$HOME/.claude/skills/brain-ingest/SKILL.md"
if [ "$fail" -ne 0 ]; then
echo ""
diff --git a/bin/create.js b/bin/create.js
index 969331c..9958b6b 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -61,13 +61,27 @@ async function installGlobalSkills(qmdPath) {
}
}
+// Wraps rl.question() so that if readline closes (e.g. piped stdin reaches EOF
+// before the question is answered), the promise resolves with '' rather than
+// hanging forever — which would leave no active handles and cause Node to exit.
+function ask(rl, prompt) {
+ return new Promise((resolve) => {
+ const onClose = () => resolve("")
+ rl.once("close", onClose)
+ rl.question(prompt).then(answer => {
+ rl.removeListener("close", onClose)
+ resolve(answer)
+ }).catch(() => resolve(""))
+ })
+}
+
async function main() {
const rl = createInterface({ input: process.stdin, output: process.stdout })
// 1. Folder name
let targetName = process.argv[2]
if (!targetName) {
- const answer = await rl.question("Where to create your brain? (my-brain) › ")
+ const answer = await ask(rl, "Where to create your brain? (my-brain) › ")
targetName = answer.trim() || "my-brain"
}
@@ -76,9 +90,19 @@ async function main() {
process.env.XDG_CACHE_HOME || join(homedir(), ".cache"),
"qmd", "index.sqlite"
)
- const qmdAnswer = await rl.question(`Where to store the qmd index? (${defaultQmdPath}) › `)
+ const qmdAnswer = await ask(rl, `Where to store the qmd index? (${defaultQmdPath}) › `)
const qmdPath = qmdAnswer.trim() || defaultQmdPath
+ // 3. GitHub repo
+ const ghAnswer = await ask(rl, "Create a GitHub repo for your brain? (y/N) › ")
+ const createGhRepo = ghAnswer.trim().toLowerCase() === "y"
+
+ let ghRepoName = null
+ if (createGhRepo) {
+ const ghNameAnswer = await ask(rl, `GitHub repo name? (${targetName}) › `)
+ ghRepoName = ghNameAnswer.trim() || targetName
+ }
+
rl.close()
const targetDir = join(process.cwd(), targetName)
@@ -143,7 +167,38 @@ async function main() {
console.error(" git init failed — run it manually inside your vault")
}
- // 8. Install global skills
+ // 8. GitHub repo (optional)
+ if (createGhRepo) {
+ if (!commandExists("gh")) {
+ console.error("\n gh CLI not found — install it from https://cli.github.com, then run:")
+ console.error(` gh repo create ${ghRepoName} --private --source=. --remote=origin --push`)
+ } else {
+ console.log("\nSetting up GitHub repo...")
+
+ const authCheck = spawnSync("gh", ["auth", "status"], { stdio: "pipe" })
+ let loggedIn = authCheck.status === 0
+
+ if (!loggedIn) {
+ console.log(" Not logged in to GitHub. Starting login...")
+ loggedIn = run(["gh", "auth", "login"], targetDir)
+ }
+
+ if (loggedIn) {
+ const ghOk = run(
+ ["gh", "repo", "create", ghRepoName, "--private", "--source=.", "--remote=origin", "--push"],
+ targetDir
+ )
+ if (ghOk) {
+ console.log(`✓ GitHub repo created and pushed: ${ghRepoName}`)
+ } else {
+ console.error(" gh repo create failed — run manually:")
+ console.error(` gh repo create ${ghRepoName} --private --source=. --remote=origin --push`)
+ }
+ }
+ }
+ }
+
+ // 9. Install global skills
console.log("\nInstalling global skills...")
await installGlobalSkills(qmdPath)
@@ -151,8 +206,10 @@ async function main() {
console.log("Next steps:")
console.log(` cd ${targetName}`)
console.log(" claude # open Claude Code, then run /setup")
- console.log(" git remote add origin <url> # connect to GitHub for sync + Obsidian Mobile")
- console.log(" git push -u origin main")
+ if (!createGhRepo) {
+ console.log(" git remote add origin <url> # connect to GitHub for sync + Obsidian Mobile")
+ console.log(" git push -u origin main")
+ }
}
main().catch(err => {