Kb register library

From SteveGJones/ai-first-sdlc-practices · View interactive version

Kb register library is an AI agent skill from the GitHub repository SteveGJones/ai-first-sdlc-practices. Register an external knowledge base library in the user-scope global registry at ~/.sdlc/global-libraries.json. Validates that the target path exists, contains a _shelf-index.md, and parses its format_version. Optional helper — hand-editing the JSON is also supported.

How to use this skill

Skill file

Register External Library

Add an external knowledge base to the user-scope global registry so it can be activated in any project's .sdlc/libraries.json.

Arguments

Preflight

Steps

1. Validate the target library path

Run the path validator:

python3 -c "
import sys, os, importlib.util
PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT', '')
SCRIPTS = os.path.join(PLUGIN_ROOT, 'scripts')
INIT = os.path.join(SCRIPTS, '__init__.py')
if os.path.isfile(INIT) and 'sdlc_knowledge_base_scripts' not in sys.modules:
    spec = importlib.util.spec_from_file_location(
        'sdlc_knowledge_base_scripts',
        INIT,
        submodule_search_locations=[SCRIPTS],
    )
    if spec and spec.loader:
        module = importlib.util.module_from_spec(spec)
        sys.modules['sdlc_knowledge_base_scripts'] = module
        spec.loader.exec_module(module)
from pathlib import Path
from sdlc_knowledge_base_scripts.registry import validate_library_path
ok, reason = validate_library_path(Path('<path>'))
if not ok:
    print(f'ERROR: {reason}')
    exit(1)
print('OK')
"

If the validator returns an error, surface the exact reason string to the user and stop. Common reasons:

2. Load or initialise the registry

If ~/.sdlc/global-libraries.json does not exist, initialise with:

{"version": 1, "libraries": []}

Otherwise load the existing file. If parsing fails, do not overwrite — error and recommend manual repair.

3. Add the new entry

Append to libraries:

{
  "name": "<name>",
  "type": "filesystem",
  "path": "<absolute-path>",
  "description": "<description or omitted>"
}

4. Write the registry atomically

Write to a temp file and rename to avoid partial writes.

5. Report success

Print a confirmation:

Registered '<name>' → <path>
format_version: <N>
Description: <description or "none">

To activate in a project, add to .sdlc/libraries.json:
  {"version": 1, "activated_sources": ["<name>"]}

What this skill does NOT do

Examples

Register a corporate library:

/sdlc-knowledge-base:kb-register-library corporate-semiconductor /Users/steve/corp/semi/library "Semiconductor engagement findings 2024-2026"

Register with no description:

/sdlc-knowledge-base:kb-register-library corp-health /Users/steve/corp/health/library

Errors

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.