← ClaudeAtlas

rnd-lib-sh-patternslisted

Use when writing hooks or lib scripts — covers lib.sh shared utilities, path predicates, response functions, stdin parsing, and the active_session_dir caching pattern
oleksify/rnd-framework · ★ 0 · AI & Automation · score 75
Install: claude install-skill oleksify/rnd-framework
# lib.sh Patterns ## Overview `hooks/lib.sh` is the foundation sourced by every hook script. It provides path predicates, hook response output, stdin parsing, RND directory resolution with caching, and timestamps. Use these functions instead of reimplementing — they handle edge cases (malformed JSON, empty input, missing fields) that raw `jq` calls do not. ## Path Predicates ### is_plugin_artifact_path Returns 0 if path is under `.rnd/` within a recognized config directory. ```bash is_plugin_artifact_path "/home/user/.claude/.rnd/proj-abc123/sessions/20260101-120000-abcd/plan.md" # true is_plugin_artifact_path "/home/user/project/src/main.ts" # false ``` Regex: `\.claude[^/]*/.*\.rnd/` ### is_plugin_cache_path Returns 0 if path contains `plugins/cache/` under a config directory. Used for auto-allowing reads from cached plugin files. ### is_learnings_path Returns 0 if path contains `learnings/` under a config directory. Used for auto-allowing reads from the cross-session learning library. ### is_code_file Returns 0 if path has a recognized source code extension (ts, js, py, rb, go, rs, sh, ex, etc.). ## Hook Response Output ### allow_json Prints the auto-allow JSON. No arguments needed. ```bash allow_json # Output: {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}} ``` ### advisory_json Prints advisory JSON with a properly JSON-escaped message. ```bash advisory_json "Warning: output was 150 lines." ``` Uses `jq -Rs` intern