agentleFS
DespensativoDespensativo/OpenWrt-Skills/skills/posix-shell/SKILL.md

posix-shell

Skill0 starsChanged 2 months agoMITView on GitHub

Enforce strict POSIX compliance and BusyBox ash compatibility for OpenWrt scripts. Forbids bashisms, ensures safe variable quoting, efficient resource usage, and clean UCI interactions.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use a flag -q (quiet) quando o valor puder não existir: uci -q get "system.@system[0].hostname".

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

POSIX Shell & BusyBox Ash Guidelines (ARK Router)

Objetivo

Garantir que todo script de shell desenvolvido para o ARK Router execute de forma confiável e leve sob o BusyBox ash (/bin/sh), sem dependências do GNU Bash e com consumo mínimo de recursos (RAM e Flash).


Regras Fundamentais (Invioláveis)

1. Zero Bash-ismos (Strict POSIX)

  • Shebang Obrigatório: #!/bin/sh (nunca #!/bin/bash).
  • ❌ Proibido [[ ... ]]: Use sempre [ ... ] ou test.
    • Correto: [ -n "$var" ] && [ "$var" = "val" ]
    • Incorreto: [[ -n $var && $var == "val" ]]
  • ❌ Proibido arrays: arr=(a b c) não existe no POSIX ash. Use listas separadas por espaço ou processe com set --.
  • ❌ Proibido substituições não-POSIX:
    • Incorreto: ${var//foo/bar}, ${var^^}.
    • Correto: Use sed, awk, ou cut de forma enxuta.
  • ❌ Proibido function foo(): No POSIX, a sintaxe de função é apenas foo() { ... }.
  • ❌ Proibido read -a ou read -p: Use printf "Prompt: " && read -r line.

2. Tratamento Seguro de Variáveis e Aspas

  • Sempre citar variáveis de expansão: "$var" para evitar quebras por espaços ou expansão de glob.
  • Citar caminhos do UCI:
    ip=$(uci -q get "network.lan.ipaddr")
  • Tratar saídas de comandos e verificar códigos de retorno:
    if ! output=$(some_command); then
        logger -t ark-router "Erro ao executar some_command"
        return 1
    fi

3. Eficiência em Sistemas Embarcados (128 MB / 256 MB RAM)

  • Evite criar subshells desnecessários $(...) dentro de loops intensivos.
  • Prefira comandos internos do BusyBox (built-ins) como case ... esac, test, echo, printf.
  • Evite tubulações excessivas (cat file | grep foo | awk ...). Use comandos compostos ou leia linha a linha com while read -r line; do ... done < file.

4. Boas Práticas com o UCI

  • Use a flag -q (quiet) quando o valor puder não existir: uci -q get "system.@system[0].hostname".
  • Sempre realize uci commit apenas ao final de um lote de alterações para poupar escritas na Flash SPI.
  • Reinicie serviços de rede ou firewall de forma condicional, nunca incondicionalmente em loops.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.