Skip to content

Commit 5d76dcd

Browse files
committed
update adding claude.md
1 parent 1633677 commit 5d76dcd

12 files changed

Lines changed: 1063 additions & 47 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
if grep -q "caliber" .git/hooks/pre-commit 2>/dev/null; then
3+
exit 0
4+
fi
5+
FLAG="/tmp/caliber-nudge-$(echo "$PWD" | shasum | cut -c1-8)"
6+
find /tmp -maxdepth 1 -name "caliber-nudge-*" -mmin +120 -delete 2>/dev/null
7+
if [ -f "$FLAG" ]; then
8+
exit 0
9+
fi
10+
touch "$FLAG"
11+
printf '{"decision":"block","reason":"Caliber agent config sync is not set up on this machine. Tell the user: This project uses Caliber to keep agent configs in sync — it is not set up yet. Want me to run /setup-caliber? (~30 seconds)"}'

.claude/settings.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"hooks": {
3+
"Stop": [
4+
{
5+
"matcher": "",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": ".claude/hooks/caliber-check-sync.sh",
10+
"description": "Caliber: offer setup if not configured"
11+
}
12+
]
13+
}
14+
],
15+
"PostToolUse": [
16+
{
17+
"matcher": "",
18+
"hooks": [
19+
{
20+
"type": "command",
21+
"command": "caliber learn observe",
22+
"description": "Caliber: recording tool usage for session learning"
23+
}
24+
]
25+
}
26+
],
27+
"PostToolUseFailure": [
28+
{
29+
"matcher": "",
30+
"hooks": [
31+
{
32+
"type": "command",
33+
"command": "caliber learn observe --failure",
34+
"description": "Caliber: recording tool failure for session learning"
35+
}
36+
]
37+
}
38+
],
39+
"UserPromptSubmit": [
40+
{
41+
"matcher": "",
42+
"hooks": [
43+
{
44+
"type": "command",
45+
"command": "caliber learn observe --prompt",
46+
"description": "Caliber: recording user prompt for correction detection"
47+
}
48+
]
49+
}
50+
],
51+
"SessionEnd": [
52+
{
53+
"matcher": "",
54+
"hooks": [
55+
{
56+
"type": "command",
57+
"command": "caliber learn finalize --auto",
58+
"description": "Caliber: finalizing session learnings"
59+
}
60+
]
61+
},
62+
{
63+
"matcher": "",
64+
"hooks": [
65+
{
66+
"type": "command",
67+
"command": "caliber refresh --quiet",
68+
"description": "Caliber: auto-refreshing docs based on code changes"
69+
}
70+
]
71+
}
72+
]
73+
},
74+
"permissions": {
75+
"allow": [
76+
"Bash(git *)"
77+
]
78+
}
79+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: find-skills
3+
description: Discovers and installs community skills from the public registry. Use when the user mentions a technology, framework, or task that could benefit from specialized skills not yet installed, asks 'how do I do X', 'find a skill for X', or starts work in a new technology area. Proactively suggest when the user's task involves tools or frameworks without existing skills.
4+
---
5+
6+
# Find Skills
7+
8+
Search the public skill registry for community-contributed skills
9+
relevant to the user's current task and install them into this project.
10+
11+
## Instructions
12+
13+
1. Identify the key technologies, frameworks, or task types from the
14+
user's request that might have community skills available
15+
2. Ask the user: "Would you like me to search for community skills
16+
for [identified technologies]?"
17+
3. If the user agrees, run:
18+
```bash
19+
caliber skills --query "<relevant terms>"
20+
```
21+
This outputs the top 5 matching skills with scores and descriptions.
22+
4. Present the results to the user and ask which ones to install
23+
5. Install the selected skills:
24+
```bash
25+
caliber skills --install <slug1>,<slug2>
26+
```
27+
6. Read the installed SKILL.md files to load them into your current
28+
context so you can use them immediately in this session
29+
7. Summarize what was installed and continue with the user's task
30+
31+
## Examples
32+
33+
User: "let's build a web app using React"
34+
-> "I notice you want to work with React. Would you like me to search
35+
for community skills that could help with React development?"
36+
-> If yes: run `caliber skills --query "react frontend"`
37+
-> Show the user the results, ask which to install
38+
-> Run `caliber skills --install <selected-slugs>`
39+
-> Read the installed files and continue
40+
41+
User: "help me set up Docker for this project"
42+
-> "Would you like me to search for Docker-related skills?"
43+
-> If yes: run `caliber skills --query "docker deployment"`
44+
45+
User: "I need to write tests for this Python ML pipeline"
46+
-> "Would you like me to find skills for Python ML testing?"
47+
-> If yes: run `caliber skills --query "python machine-learning testing"`
48+
49+
## When NOT to trigger
50+
51+
- The user is working within an already well-configured area
52+
- You already suggested skills for this technology in this session
53+
- The user is in the middle of urgent debugging or time-sensitive work
54+
- The technology is too generic (e.g. just "code" or "programming")
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
name: license-cli-script
3+
description: Creates a new CLI script in bin/ for Softaculous/Webuzo/Virtualizor/SiteMush license operations. Use when user says 'add CLI script', 'new bin command', 'create license tool', or 'add a script to bin/'. Do NOT use for src/ classes, test files, or Plugin hooks.
4+
---
5+
# License CLI Script
6+
7+
## Critical
8+
9+
- All CLI scripts go in `bin/` — never in `src/` or `tests/`.
10+
- Every script MUST start with `#!/usr/bin/env php` shebang line.
11+
- Require the parent MyAdmin bootstrap: `require_once __DIR__.'/../../../../include/functions.inc.php';`
12+
- Use credential constants `SOFTACULOUS_USERNAME` / `SOFTACULOUS_PASSWORD` (or `WEBUZO_USERNAME` / `WEBUZO_PASSWORD` for Webuzo-specific scripts). Never hardcode credentials.
13+
- CLI arguments come from `$_SERVER['argv']`, not `$argc`/`$argv`.
14+
- Never add argument parsing libraries or option parsers — keep scripts minimal.
15+
16+
## Instructions
17+
18+
1. **Determine the API method to call.** Check `src/SoftaculousNOC.php` for available methods. Common ones:
19+
- `licenses($key, $ip)` — list/search licenses
20+
- `cancel($key, $ip)` — cancel a license
21+
- `refund($actid)` — refund a license
22+
- `licenselogs($key)` — get license logs
23+
- `invoicedetails($invoid)` — get invoice details
24+
- `editips($lid, $ips)` — change license IP
25+
- `autorenewals()` / `addautorenewal($key)` / `removeautorenewal($key)`
26+
- Prefixed variants: `webuzo_*`, `virt_*`, `sitemush_*`
27+
28+
Verify the method exists and note its parameters before proceeding.
29+
30+
2. **Create the script file.** Name it `bin/<name>.php` using snake_case. Match the naming pattern of existing scripts:
31+
- `bin/cancel_by_ip.php`, `bin/cancel_by_key.php`, `bin/license_by_ip.php`
32+
- `bin/license_logs.php`, `bin/license_refund.php`, `bin/invoice_details.php`
33+
- `bin/licenses.php`, `bin/update_data.php`
34+
35+
Verify the filename does not already exist in `bin/`.
36+
37+
3. **Write the script** following this exact template:
38+
39+
```php
40+
#!/usr/bin/env php
41+
<?php
42+
43+
require_once __DIR__.'/../../../../include/functions.inc.php';
44+
45+
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD);
46+
47+
print_r($noc->methodName($_SERVER['argv'][1]));
48+
print_r($noc->response);
49+
50+
//$GLOBALS['tf']->session->destroy();
51+
```
52+
53+
Key rules:
54+
- Use fully-qualified class name `\Detain\MyAdminSoftaculous\SoftaculousNOC` (no `use` statement).
55+
- If the method returns the result directly (like `licenses()`), just `print_r()` the return value — skip `print_r($noc->response)`. See `bin/licenses.php` for this pattern.
56+
- If the method requires side-effect inspection, print both the return value AND `$noc->response` (see `bin/cancel_by_key.php`, `bin/license_refund.php`).
57+
- CLI arguments map positionally: `$_SERVER['argv'][1]` is the first arg, `$_SERVER['argv'][2]` is the second, etc.
58+
- Keep the commented-out `$GLOBALS['tf']->session->destroy();` line at the bottom — this is the project convention.
59+
60+
4. **Verify the script.** Run `php -l bin/<name>.php` to check for syntax errors.
61+
62+
## Examples
63+
64+
### User says: "Add a CLI script to check auto-renewals for a license key"
65+
66+
**Actions:**
67+
1. Confirm `autorenewals($key)` exists in `src/SoftaculousNOC.php`.
68+
2. Create a new file in `bin/` (e.g., `bin/auto_renewals.php`):
69+
70+
```php
71+
#!/usr/bin/env php
72+
<?php
73+
74+
require_once __DIR__.'/../../../../include/functions.inc.php';
75+
76+
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD);
77+
78+
print_r($noc->autorenewals($_SERVER['argv'][1]));
79+
print_r($noc->response);
80+
81+
//$GLOBALS['tf']->session->destroy();
82+
```
83+
84+
3. Run `php -l` on the new file — no errors.
85+
86+
**Result:** New script in `bin/` — usage: `php bin/auto_renewals.php <license_key>`
87+
88+
### User says: "Create a script to edit IPs on a Virtualizor license"
89+
90+
**Actions:**
91+
1. Confirm `virt_editips($lid, $ips)` exists in `src/SoftaculousNOC.php`.
92+
2. Create a new file in `bin/` (e.g., `bin/virt_edit_ips.php`):
93+
94+
```php
95+
#!/usr/bin/env php
96+
<?php
97+
98+
require_once __DIR__.'/../../../../include/functions.inc.php';
99+
100+
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD);
101+
102+
print_r($noc->virt_editips($_SERVER['argv'][1], $_SERVER['argv'][2]));
103+
print_r($noc->response);
104+
105+
//$GLOBALS['tf']->session->destroy();
106+
```
107+
108+
3. Run `php -l` on the new file — no errors.
109+
110+
**Result:** New script in `bin/` — usage: `php bin/virt_edit_ips.php <license_id> <new_ip>`
111+
112+
## Common Issues
113+
114+
- **`PHP Fatal error: Uncaught Error: Undefined constant "SOFTACULOUS_USERNAME"`**: The `functions.inc.php` path is wrong. The `bin/` scripts use `__DIR__.'/../../../../include/functions.inc.php'` because the package is installed at `vendor/detain/myadmin-softaculous-licensing/`. Count the directory levels: `bin/` → package root → `detain/``vendor/` → project root → `include/`. Verify with `ls $(dirname bin/new_script.php)/../../../../include/functions.inc.php`.
115+
116+
- **`Undefined offset: 1` when running the script**: The user forgot to pass a CLI argument. The existing scripts do not validate arguments — this is intentional to keep them minimal. Do not add argument validation unless the user specifically asks for it.
117+
118+
- **Script runs but prints empty output**: Check `$noc->response` — the API may have returned an error. Also verify the credential constants are defined and non-empty in the MyAdmin configuration.
119+
120+
- **Using Webuzo credentials for Webuzo methods**: If calling `webuzo_*` methods, use `WEBUZO_USERNAME` and `WEBUZO_PASSWORD` instead of the Softaculous constants. Check `tests/.env.example` for the full list of expected credential constants.

0 commit comments

Comments
 (0)