summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-22 13:28:20 +0200
committerPaul Buetow <paul@buetow.org>2026-02-22 13:28:20 +0200
commit120764ad8f11d354725fff6583ee66453167ec51 (patch)
tree17fc9f46c772426ec80207056a4f898a92330ea3
parent33bfffd1392348ab53b3f93db7d3849563b32608 (diff)
wire codex slash commands into home_prompts
-rw-r--r--README.md10
-rw-r--r--Rexfile42
2 files changed, 45 insertions, 7 deletions
diff --git a/README.md b/README.md
index 6fdd2c2..3e71559 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,13 @@
These are all my dotfiles. I can install them locally on my laptop and/or workstation as well as remotely on any server.
For local installation, also have a read through https://blog.ferki.it/2023/08/11/local-management-with-rex/
+
+## AI prompts
+
+Prompts are managed from `~/Notes/Prompts` and linked by `home_prompts` into each tool config directory.
+
+- Commands source of truth: `~/Notes/Prompts/commands`
+- Skills source of truth: `~/Notes/Prompts/skills`
+- Codex CLI slash command path: `~/.codex/prompts`
+- Shared agent prompt paths: `~/.agents/{commands,skills}`
+- Codex CLI runtime config: `~/.codex/config.toml`
diff --git a/Rexfile b/Rexfile
index c29bcea..ae5eb6c 100644
--- a/Rexfile
+++ b/Rexfile
@@ -150,19 +150,47 @@ task 'home_prompts', sub {
if ( -d "$HOME/Notes/Prompts/commands" ) {
Rex::Logger::info("Installing prompt links");
+ my $ensure_symlink = sub {
+ my ( $source, $target, $label ) = @_;
+
+ if ( -l $target ) {
+ my $existing = readlink $target;
+ if ( defined $existing && $existing eq $source ) {
+ return;
+ }
+ CORE::unlink($target) or die "Could not replace $label symlink at $target: $!";
+ }
+ elsif ( -d $target ) {
+ my ($leaf) = $target =~ m{([^/]+)$};
+ my $nested = "$target/$leaf";
+ if ( -l $nested && readlink($nested) eq $source ) {
+ CORE::unlink($nested) or die "Could not remove nested $label symlink at $nested: $!";
+ rmdir $target or die "Could not remove legacy $label directory at $target: $!";
+ }
+ else {
+ die "Refusing to overwrite existing directory at $target while linking $label";
+ }
+ }
+ elsif ( -e $target ) {
+ die "Refusing to overwrite existing path at $target while linking $label";
+ }
+
+ symlink $source => $target or die "Could not create $label symlink ($source -> $target): $!";
+ };
+
+ # For most agents, commands and skills live under ~/.<tool>/{commands,skills}.
my @tool_dirs = ( '.cursor', '.claude', '.agents', '.opencode' );
for my $tool_dir (@tool_dirs) {
file "$HOME/$tool_dir" => ensure => 'directory', mode => '0750';
- # Symlink commands directory
- symlink "$HOME/Notes/Prompts/commands" => "$HOME/$tool_dir/commands"
- or die "Could not create commands symlink for $tool_dir: $!";
-
- # Symlink skills directory
- symlink "$HOME/Notes/Prompts/skills" => "$HOME/$tool_dir/skills"
- or die "Could not create skills symlink for $tool_dir: $!";
+ $ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/$tool_dir/commands", "$tool_dir commands" );
+ $ensure_symlink->( "$HOME/Notes/Prompts/skills", "$HOME/$tool_dir/skills", "$tool_dir skills" );
}
+
+ # Codex CLI custom slash commands are loaded from ~/.codex/prompts.
+ file "$HOME/.codex" => ensure => 'directory', mode => '0750';
+ $ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/.codex/prompts", ".codex prompts" );
}
else {
Rex::Logger::info("Not installing prompt links");