Claude Code Skills

Posted on Friday, April 24, 2026


 

What are Claude Code Skills?  Think of them as reusable workflows that Claude code can use.  It follows the Agent Skills open Standard. See https://agentskills.io/home [1]

 

 

Let’s just make one.

 

Where can skills be placed?
If you want them to be accessible everywhere on your system you can place them in you ~/.claude folder by creating a skills folder there then creating sub folders named by there skill.


Alternatively you can also make a project level skill.  For example in the base of a git repo you can make a .claude/skills folder.

 

(It is preferred to be more generic and rather than use .claude to use .agent … but for this document I will stick with .claude.


Let me try something simple.
I want to create a skill that will create an html page that contains the last 10 cmd line commands I ran and puts the file in the /tmp director  and uses the open command to open it in a web browser

 

 

  > cd ~/.claude
  > mkdir skills
  > cd skills
  > mkdir command-history-html
  > cd command-history-html
  > vi SKILL.md

 

 

Place the following in the file

 

---
name: command-history-html
description: |
  When asked to show recent commands as HTML, create an HTML page in /tmp with the last 10 shell commands and open it in the default browser using the `open` command.
--- 

# Command History → HTML Viewer

## Purpose

Generate a clean HTML report of the **last 10 commands** from shell history, save it to `/tmp`, and open it automatically.

## How to Trigger
- "Show my last commands as HTML"
- "Open recent terminal history in browser"
- "Make HTML page of last 10 cmds" 

## Execution Steps (Follow Exactly)

1. **Get last 10 commands** (works for both bash and zsh):
   ```bash
   history 10 | tail -n 10

 

 

Save it and open claude

 

  > claude

 

 


It checks to see if I can trust this folder

 


Type in / then start typing the command.
You can use the up/down arrow keys to choose a skill or command, or you can also use tab-completion.


If I run it…

 


Click yes to run it

 


And it worked!

You will notice it does not include the claude command itself.
This is because it pulled from the ~/.history file vs the history command (and the .history file just did not have all the details from this exact terminal I was on)

Let me see if I can fix the skill to account for that.

 

 

   > vi ~/.claude/skills/command-history-html/SKILL.md

 

 

Place the following in the file


 

---
name: command-history-html
description: |
  When asked to show recent commands as HTML, create an HTML page in /tmp with the last 10 shell commands and open it in the default browser using the `open` command.
--- 

# Command History → HTML Viewer

## Purpose
Generate a clean HTML report of the **last 10 commands** from shell history, save it to `/tmp`, and open it automatically.

 ## How to Trigger
- "Show my last commands as HTML"
- "Open recent terminal history in browser"
- "Make HTML page of last 10 cmds" 

## Execution Steps (Follow Exactly)

1. **Get last 10 commands** (works for both bash and zsh):
     ```bash
   history 10 | tail -n 10

 

 

Hmm this looks correct… So why did it rely on the .history file?

 



After another test it did it again.

Oh nevermind due to the claude running in its own persistent bash shell it can’t run commands like this… It would have to kill itself to get the info and magically run. 
With that in mind though the skill should be changed to read the .bash_history fil

 

 

---
name: last-commands-html
description: |
  Creates /tmp/recent-commands.html with the last 10 real shell commands (from ~/.zsh_history or ~/.bash_history)
  and opens it in the default browser. Works on macOS (open), WSL (wslview/explorer), and Linux (xdg-open).
--- 

# Last Commands → HTML (Cross-Platform)

## Trigger
"Show last 10 commands as HTML" / "Use last-commands-html" / "Open recent history in browser" 

## Execution Script (Copy-Paste This Whole Block)

```bash
#!/bin/bash
set -e 

HTML_FILE="/tmp/recent-commands.html"
# === 1. Get last 10 commands from real user history ===
if [ -f ~/.zsh_history ]; then
  # zsh extended history format: ": timestamp:elapsed;command"
  tail -n 50 ~/.zsh_history | sed 's/^: [0-9]*:[0-9]*;//' | grep -v '^$' | tail -n 10 > /tmp/raw_history.txt
elif [ -f ~/.bash_history ]; then
  # bash HISTTIMEFORMAT inserts "#timestamp" lines before each command — strip them
  tail -n 50 ~/.bash_history | grep -vE '^#[0-9]{8,}$' | tail -n 10 > /tmp/raw_history.txt
else
  echo "No history file found" > /tmp/raw_history.txt
fi 

# === 2. Build nice HTML ===
cat > "$HTML_FILE" << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Last 10 Commands - $(date '+%Y-%m-%d %H:%M:%S')</title>
    <style>
        body { font-family: 'Segoe UI', monospace; background: #1e1e1e; color: #ddd; margin: 30px; }
        h1 { color: #0a84ff; }
        table { width: 100%; border-collapse: collapse; }
        th, td { padding: 10px; border: 1px solid #444; text-align: left; }
        tr:nth-child(even) { background: #2a2a2a; }
        .timestamp { color: #888; font-size: 0.9em; }    </style>
</head>
<body>
    <h1>Last 10 Commands</h1>
    <p class="timestamp">Generated on $(date)</p>
    <table>
          <tr><th>#</th><th>Command</th></tr>
EOF 

# Add rows
nl -ba /tmp/raw_history.txt | while read -r line; do
  num=$(echo "$line" | awk '{print $1}')
  cmd=$(echo "$line" | cut -d' ' -f2- | sed 's/"/&quot;/g')
  echo "        <tr><td>$num</td><td><pre>$cmd</pre></td></tr>" >> "$HTML_FILE"
done 

cat >> "$HTML_FILE" << 'EOF'
    </table>
</body>
</html>
EOF 

echo " HTML created at $HTML_FILE"

# === 3. Open with the right tool (auto-detect) ===
if command -v wslview >/dev/null 2>&1; then
    wslview "$HTML_FILE"
elif [[ $(uname -r) == *microsoft* ]] || [[ $(uname -r) == *WSL* ]] || grep -qi microsoft /proc/version 2>/dev/null; then
    # WSL fallback — must convert to Windows path before passing to Windows tools
    WIN_PATH="$(wslpath -w "$HTML_FILE")"
    explorer.exe "$WIN_PATH" || powershell.exe -c "start '$WIN_PATH'"
elif command -v open >/dev/null 2>&1; then
    # macOS
    open "$HTML_FILE"
elif command -v xdg-open >/dev/null 2>&1; then
    # Linux
    xdg-open "$HTML_FILE"
else
    echo "Could not detect opener. File is ready at $HTML_FILE"
fi

 

 

Now lets try it

 


OK close … I think I need a few more tweaks but the idea is there

 

References

 

[1]       Agent Skills overview

https://agentskills.io/home  
Accessed 04/2026

 

 

 


No comments:

Post a Comment