From dk
Initialize a Diakon workspace — auto-detect projects, create registry, setup secrets infrastructure. Use when the user says 'initialize workspace', 'setup diakon', or 'dk init'.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dk:initThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Source the helpers first:
Source the helpers first:
source "${CLAUDE_PLUGIN_ROOT}/scripts/dk-helpers.sh"
Use the current working directory as the workspace root. If an argument is provided, use it as the workspace name; otherwise use the directory basename.
Run dk_is_safe_init_dir on the current directory. If it returns failure (the directory is $HOME, /, /tmp, etc.), warn the user and abort. Do NOT initialize in these directories.
Check if .diakon/workspace.yaml already exists. If it does, read it, show the current workspace name and project count, and ask: "Workspace already initialized. Re-initialize? This will overwrite the registry. (y/N)". If the user says no, abort.
Check in this order:
pnpm-workspace.yaml exists → type is "pnpm". Read the pnpm version with pnpm --version.package.json exists and has a workspaces field → check for yarn.lock (yarn) or default to "npm".For pnpm workspaces: Read pnpm-workspace.yaml and parse the packages: array. For each glob pattern (e.g., "aether/*"), use Glob to find matching directories containing package.json. Group discovered directories by their top-level parent (e.g., aether/types and aether/ui both group under aether). The parent directory name becomes the project name, and the subdirectories become sub-packages.
For npm/yarn workspaces: Same approach using the workspaces field from package.json.
For no workspace: Scan top-level directories for package.json, .git, Gemfile, go.mod, Cargo.toml, or pyproject.toml.
For each discovered project:
package.json → node, Gemfile → rails, go.mod → go, Cargo.toml → rust, requirements.txt/pyproject.toml → pythonpackage.json name field (strip scope) or directory name@, extract the scope (e.g., @idl3)git -C <path> remote get-url origin 2>/dev/nullgit -C <path> symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||' — fallback to "main"package.json description fieldCheck if sops and age are installed using dk_check_deps sops age. If either is missing, print install instructions and set secrets backend to "none".
If both are available, ask the user to select a tier:
Secrets backend:
1. age (solo — single local key)
2. age (team — multiple public keys)
3. GCP KMS (cloud-managed)
4. GCP KMS + age fallback (hybrid)
For age tiers (1, 2, 4):
~/.config/sops/age/keys.txt existsmkdir -p ~/.config/sops/age && age-keygen -o ~/.config/sops/age/keys.txt and chmod 600 ~/.config/sops/age/keys.txtgrep 'public key:' ~/.config/sops/age/keys.txt | awk '{print $NF}'For GCP KMS tiers (3, 4):
dk_check_deps gcloudgcloud config get-value project as default), location (default: global), keyring name, key nameprojects/{project}/locations/{location}/keyRings/{ring}/cryptoKeys/{key}gcloud kms keyrings create and gcloud kms keys create --purpose=encryptionCreate the .diakon/ directory with mkdir -p .diakon.
workspace.yaml — Generate YAML content with all discovered projects and write using dk_safe_write. Structure:
diakon: "0.1.0"
workspace:
name: "<workspace-name>"
type: "<detected-type>"
package_manager: "<detected-pm>"
projects:
<project-name>:
path: "./<path>"
enabled: true
type: "<detected-type>"
packages: [<sub-packages>]
mode: "<submodule|symlink|directory>"
git:
url: "<remote-url>"
default_branch: "<branch>"
meta:
description: "<description>"
scope: "<scope>"
secrets:
backend: "<backend>"
file: ".diakon/secrets.enc.yaml"
.sops.yaml — Write creation rules based on selected tier. For age: list all public keys. For GCP KMS: include resource ID.
secrets.enc.yaml — Create initial empty encrypted file:
echo '{}' | SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt sops --encrypt --input-type yaml --output-type yaml --config .diakon/.sops.yaml /dev/stdin > .diakon/secrets.enc.yaml
If this fails, write a placeholder comment file.
.diakon/.gitignore:
*.key
*.age-key
keys.txt
*.tmp.yaml
Read .gitignore (or create if missing). Append these entries if not already present:
# Diakon secrets (never commit)
.diakon/*.key
.diakon/*.age-key
Show the workspace name, type, package manager, secrets backend, number of projects discovered, and list each project with its type and sub-package count. Then show next steps:
Next steps:
/dk:list — review registered projects
/dk:info <name> — inspect a project
/dk:secret-set — store your first secret
Provides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.
npx claudepluginhub pleri/diakon --plugin dk