SLOPSHOPPER

skogai-core

Acts upon Claude Code hook events with one script per event, logs each one to log.jsonl, journals and stages every turn, and shows the last logged event in the…

statusprocess
v0.8.0no licenseupdated 2026-10-26skogai2/marketplace/plugins/skogai-core
A shopper browsing a rack in a slop shop
README

skogai-core

A Claude Code plugin for acting upon hook events. Each event we act upon has its own script, every action is logged, and the status line shows the event being acted upon. What it does and why is in FEATURES.md:

  • Event log: one JSON row per event we act upon in .skogai/logs/skogai-core/log.jsonl at the git root.
  • Diff as handover: on Stop, appends the turn (prompt, reply, tool uses) to .skogai/journal.md at the git root. SKOGAI_{STAGE,COMMIT,MERGE}_ON_{STOP,USER_PROMPT_SUBMIT} switch on git add -A, wt step commit and wt merge; all are off unless set to true.
  • Status line: shows hook: <event> from the log's last row.

Installing it

/plugin install skogai-core --marketplace skogai2/marketplace

Running it

cd ~/marketplace
claude --plugin-dir plugins/skogai-core

The scripts need bash, jq, git and flock. Check the plugin without a session:

claude plugin validate plugins/skogai-core

Test the scripts without a session (needs nothing but the tools above):

plugins/skogai-core/tests/run.sh

Tail the log while you use Claude:

tail -f .skogai/logs/skogai-core/log.jsonl | jq -c '{event, action}'

Settings

Per project, in .claude/skogai-core.local.md at the git root (gitignored). Start from the example and check it:

cp plugins/skogai-core/examples/skogai-core.local.md .claude/
plugins/skogai-core/scripts/validate-settings.sh
KeyDefaultWhat it does
enabledtruefalse switches everything off: log, journal, git steps, status line
eventsallHook events to log, as a list; globs such as "Post*" work. The journal needs UserPromptSubmit and PostToolUse*
log-path.skogai/logs/skogai-core/log.jsonlWhere the log goes, relative to the git root
status-linetruefalse hides hook: <event>

Keys may also be written with _ (log_path). Scripts read the file on every event and so does the status line, so edits apply without a restart.

With dash's skogai config on PATH (one that knows --file), the file is one layer of it: the same keys can come from ~/.skogai/config or a repo's .skogai/config as skogai-core.<key>, or from env as SKOGAI_SKOGAICORE_<KEY>. skogai config list --show-origin --file .claude/skogai-core.md --scope skogai-core shows where each value came from. Without it, only the file is read. The git-step switches are unscoped keys (stage.on-stop, ...), see diff as handover.

Files

.claude-plugin/plugin.json   manifest
hooks/hooks.json             the events we act upon, plus the status-line module
hooks/register.ts            the status-line mod: shows the log's last event
scripts/events/<Event>.sh    one script per event, run with the event's JSON on stdin
scripts/append-json.sh       appends one row to the log: <json> | append-json.sh [action]
scripts/git-steps.sh         runs the switched-on git steps: git-steps.sh <EVENT> <root>
scripts/write-state.sh       writes git-diff, git-diff-cached, wt-step-diff to .skogai/tmp/
scripts/settings.sh          sourced by the scripts: reads .claude/skogai-core.local.md
scripts/validate-settings.sh checks a settings file: validate-settings.sh [path]
examples/skogai-core.local.md  settings to copy into a project
tests/run.sh                 tests the scripts in a throwaway git repo

Acting upon another event

  1. Add the event to hooks/hooks.json, pointing at scripts/events/<Event>.sh. The events are listed in the hooks reference.
  2. Write the script. Do the work, then pipe the input to append-json.sh with a short description of what you did. A script that only logs is one line:
   exec "$(dirname "$0")/../append-json.sh"

A script can also answer back the way any command hook can, with exit code 2 or JSON on stdout.

Config

Reading settings through dash's skogai config, with frontmatter files as extra layers, is proposed in CONFIG.md.

Learnings

See LEARNINGS.md.

Source 1 files
hooks/register.ts 66 lines
1import type { Register } from 'claude-code'
2
3// The plain hooks in hooks.json do the acting, and each one writes a row to
4// the log with scripts/append-json.sh. This module only shows the event of
5// the log's last row in the status line.
6const LOG = '.skogai/logs/skogai-core/log.jsonl'
7// Per-project settings, read the same way as scripts/settings.sh.
8const SETTINGS = '.claude/skogai-core.local.md'
9
10// The git root, found once per load. The scripts resolve the log against it
11// too, so both agree wherever the session's working directory is.
12let root: string | null = null
13
14// One scalar from `skogai config list` output, for a skogai-core key.
15function resolved(list: string, key: string): string | undefined {
16  const prefix = `skogai-core.${key}=`
17  const line = list.split('\n').find(l => l.startsWith(prefix))
18  return line === undefined ? undefined : line.slice(prefix.length)
19}
20
21// One scalar from the settings file's frontmatter, unquoted, or undefined.
22// `log-path` also matches `log_path`.
23function setting(text: string, key: string): string | undefined {
24  const lines = text.split('\n')
25  if (lines[0] !== '---') return undefined
26  for (const line of lines.slice(1)) {
27    if (line === '---') return undefined
28    if (line.startsWith(key + ':') || line.startsWith(key.replace(/-/g, '_') + ':')) {
29      return line.slice(key.length + 1).replace(/\s+#.*$/, '').trim().replace(/^(["'])(.*)\1$/, '$2')
30    }
31  }
32  return undefined
33}
34
35export const register: Register = on => {
36  // classic.* matches every settings hook event (Stop, PreToolUse, ...).
37  on('classic.*', async ($, e, next) => {
38    // Let the plain hooks run, and write their row, before reading the log.
39    const result = await next(e)
40    try {
41      if (root === null) {
42        const git = await $.process.run(['git', 'rev-parse', '--show-toplevel'])
43        root = git.exitCode === 0 ? git.stdout.trim() : '.'
44      }
45      // Read on every event, so edits to the settings apply without a reload.
46      // dash's `skogai config` folds every layer, the settings file among
47      // them; without one that knows --file, read the file alone.
48      const path = `${root}/${SETTINGS}`
49      const config = await $.process.run(['skogai', 'config', 'list', '--file', path.replace(/\.local\.md$/, '.md'), '--scope', 'skogai-core']).catch(() => null)
50      let get: (key: string) => string | undefined
51      if (config !== null && config.exitCode === 0) {
52        get = key => resolved(config.stdout, key)
53      } else {
54        const text = (await $.fs.exists(path)) ? await $.fs.read(path) : ''
55        get = key => setting(text, key)
56      }
57      if (get('enabled') === 'false' || get('status-line') === 'false') return result
58      // tail reads only the last row, so the log can grow past $.fs.read's 4 MiB.
59      const last = await $.process.run(['tail', '-n1', `${root}/${get('log-path') || LOG}`])
60      const event = JSON.parse(last.stdout).event
61      if (typeof event === 'string') $.ui.status('hook: ' + event)
62    } catch {}
63    return result
64  })
65}
66