Skip to content

code-yeongyu/oh-my-openagent / packages/shared-skills/skills/programming

programming

Flagged

Applies strict, modern language practice (typed errors, exhaustive match, tests that can fail) for Python, Rust, TypeScript, JavaScript, and Go. Use for work on .py, .rs, .ts, .js, or .go files, and whenever a test or spec file is written, reshaped, reviewed, or deleted: the four-question test authoring gate and the junk-test classes live here.

FileKindSize
SKILL.mdskill md33.3 KB
references/code-smells.mdmarkdown13.9 KB
references/go/README.mdmarkdown7.7 KB
references/go/backend-stack.mdmarkdown16.6 KB
references/go/bootstrap.mdmarkdown8.9 KB
references/go/bubbletea-v2.mdmarkdown11.3 KB
references/go/cobra-stack.mdmarkdown11.5 KB
references/go/concurrency.mdmarkdown10.9 KB
references/go/data-modeling.mdmarkdown12.0 KB
references/go/error-handling.mdmarkdown10.1 KB
references/go/golangci-strict.mdmarkdown10.0 KB
references/go/grpc-connect.mdmarkdown10.3 KB
references/go/libraries.mdmarkdown13.7 KB
references/go/one-liners.mdmarkdown5.5 KB
references/go/sqlc-pgx.mdmarkdown12.7 KB
references/go/testing.mdmarkdown14.2 KB
references/go/type-patterns.mdmarkdown9.5 KB
references/logging.mdmarkdown10.5 KB
references/python/README.mdmarkdown15.7 KB
references/python/async-anyio.mdmarkdown14.2 KB
references/python/data-modeling.mdmarkdown6.6 KB
references/python/data-processing.mdmarkdown4.2 KB
references/python/error-handling.mdmarkdown6.0 KB
references/python/fastapi-stack.mdmarkdown9.2 KB
references/python/httpx2-optimization.mdmarkdown12.0 KB
references/python/libraries.mdmarkdown10.6 KB
references/python/one-liners.mdmarkdown7.9 KB
references/python/orjson-stack.mdmarkdown13.3 KB
references/python/pydantic-ai.mdmarkdown8.2 KB
references/python/pyproject-strict.mdmarkdown9.0 KB
references/python/textual-tui.mdmarkdown5.1 KB
references/python/type-patterns.mdmarkdown4.1 KB
references/rust-ub/README.mdmarkdown9.9 KB
references/rust-ub/miri-sanitizers-loom.mdmarkdown11.5 KB
references/rust-ub/ub-taxonomy.mdmarkdown13.3 KB
references/rust/README.mdmarkdown16.6 KB
references/rust/api-design.mdmarkdown6.5 KB
references/rust/async-tokio.mdmarkdown12.6 KB
references/rust/axum-stack.mdmarkdown14.2 KB
references/rust/cargo-strict.mdmarkdown10.0 KB
references/rust/clap-stack.mdmarkdown12.1 KB
references/rust/concurrency.mdmarkdown14.3 KB
references/rust/libraries.mdmarkdown17.4 KB
references/rust/macros.mdmarkdown3.3 KB
references/rust/one-liners.mdmarkdown7.5 KB
references/rust/proptest-insta.mdmarkdown13.9 KB
references/rust/type-state.mdmarkdown13.1 KB
references/rust/unsafe-discipline.mdmarkdown12.9 KB
references/rust/zero-cost-safety.mdmarkdown16.9 KB
references/testing/README.mdmarkdown10.3 KB
references/testing/junk-classes.mdmarkdown6.2 KB
references/typescript/README.mdmarkdown10.6 KB
references/typescript/backend-hono.mdmarkdown21.2 KB
references/typescript/bootstrap.mdmarkdown6.9 KB
references/typescript/data-modeling.mdmarkdown5.0 KB
references/typescript/error-handling.mdmarkdown4.7 KB
references/typescript/oxc-lint.mdmarkdown7.6 KB
references/typescript/tsconfig-strict.mdmarkdown3.9 KB
references/typescript/type-patterns.mdmarkdown5.2 KB
scripts/go/check-no-excuse-rules.shexecutablescript7.1 KB
scripts/go/new-project.tsscript6.8 KB
scripts/go/templates/.editorconfigother206 B
scripts/go/templates/.golangci.ymlconfig1.5 KB
scripts/go/templates/AGENTS.md.tmplother845 B
scripts/go/templates/README.md.tmplother207 B
scripts/go/templates/Taskfile.ymlconfig706 B
scripts/go/templates/ci.ymlconfig863 B
scripts/go/templates/config.goscript643 B
scripts/go/templates/gitignoreother99 B
scripts/go/templates/main.go.tmplother329 B
scripts/go/templates/run.goscript350 B
scripts/python/check-no-excuse-rules.pyscript24.9 KB
scripts/python/new-project.tsscript6.7 KB
scripts/python/new-script.tsscript4.2 KB
scripts/rust/check-no-excuse-rules.shexecutablescript7.5 KB
scripts/rust/check-no-excuse-rules.test.tsscript3.4 KB
scripts/rust/new-project.tsscript6.1 KB
scripts/scaffolders.test.tsscript4.9 KB
scripts/shared/run-tool.tsscript855 B
scripts/typescript/check-no-excuse-rules.test.tsscript4.0 KB
scripts/typescript/check-no-excuse-rules.tsscript13.1 KB
scripts/typescript/check-test-junk-rules.tsscript5.5 KB
scripts/typescript/check-test-junk.test.tsscript4.9 KB
scripts/typescript/check-test-junk.tsscript5.4 KB
scripts/typescript/mutation-proof.test.tsscript1.9 KB
scripts/typescript/mutation-proof.tsscript6.4 KB
scripts/typescript/new-project.test.tsscript6.8 KB
scripts/typescript/new-project.tsscript3.1 KB
scripts/typescript/oxc/.oxfmtrc.jsonconfig256 B
scripts/typescript/oxc/.oxlintrc.jsonconfig1.7 KB
scripts/typescript/oxc/lint/oxlint-plugin/LICENSEother1.0 KB
scripts/typescript/oxc/lint/oxlint-plugin/index.jsscript288 B
scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.jsscript785 B
scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.jsscript2.3 KB
scripts/typescript/oxc/tsconfig.jsonconfig794 B

scripts/rust/check-no-excuse-rules.sh

View on GitHub
#!/usr/bin/env bash
# No-excuse rule checker for Rust files.
# Only rules that can be enforced via pure text matching live here.
# Everything semantic is on clippy + miri + nextest.
#
# Rules:
#   unwrap / expect         outside tests, unless the previous line carries
#                           #[expect(clippy::unwrap_used|expect_used, reason = "...")]
#   placeholder-macro       todo!/unimplemented!/unreachable! in committed code
#   box-dyn-error           Box<dyn Error> in non-test code
#   lib-panic               panic!() in library code
#   discarded-result        `let _ = call(...)`, unless the previous line carries
#                           #[expect(clippy::let_underscore_must_use, reason = "...")]
#   blocking-in-async       std::thread::sleep / std::fs / reqwest::blocking /
#                           .blocking_*() inside an async fn or async block
#   unsafe-no-safety        unsafe { without // SAFETY: in the preceding 5 lines
#   allow-attribute         #[allow(...)] - silence lints with #[expect(lint, reason)]
#   expect-without-reason   #[expect(...)] with no `reason = "..."`
#   narrowing-as-cast       possible narrowing numeric `as` cast

set -euo pipefail

if [ $# -eq 0 ]; then
    echo "Usage: $0 <file.rs> [file.rs ...]" >&2
    exit 2
fi

violations=0
report() {
    echo "::error file=$1,line=$2::[$3] $4" >&2
    violations=$((violations + 1))
}

is_test_path() {
    case "$1" in
        */tests/*|*/benches/*|*/examples/*|*/build.rs|*_test.rs|tests/*|benches/*|examples/*) return 0 ;;
    esac
    return 1
}

count_char() {
    local only="${1//[^$2]/}"
    echo "${#only}"
}

for file in "$@"; do
    [ -f "$file" ] || continue
    case "$file" in
        *.rs) ;;
        *) continue ;;
    esac

    in_test_file=0
    is_test_path "$file" && in_test_file=1

    lines=()
    while IFS= read -r raw || [ -n "$raw" ]; do lines+=("$raw"); done < "$file"
    total=${#lines[@]}

    # Brace-tracked regions: a region starts at its marker line and ends when the
    # braces opened after the marker are closed again.
    in_cfg_test=0; cfg_depth=0; cfg_opened=0
    in_async=0; async_depth=0; async_opened=0

    for ((i = 0; i < total; i++)); do
        line_no=$((i + 1))
        line="${lines[$i]}"
        prev=""
        [ "$i" -gt 0 ] && prev="${lines[$((i - 1))]}"
        code_only="${line%%//*}"
        opens=$(count_char "$code_only" "{")
        closes=$(count_char "$code_only" "}")

        if [[ "$line" =~ \#\[cfg\(test\)\] ]]; then
            in_cfg_test=1; cfg_depth=0; cfg_opened=0
        fi
        if [ "$in_cfg_test" -eq 1 ]; then
            cfg_depth=$((cfg_depth + opens - closes))
            [ "$opens" -gt 0 ] && cfg_opened=1
            if [ "$cfg_opened" -eq 1 ] && [ "$cfg_depth" -le 0 ]; then in_cfg_test=0; fi
        fi

        if [ "$in_async" -eq 0 ] && [[ "$code_only" =~ (^|[^[:alnum:]_])async([[:space:]]+(move[[:space:]]*)?\{|[[:space:]]+(unsafe[[:space:]]+)?fn[[:space:]]) ]]; then
            in_async=1; async_depth=0; async_opened=0
        fi
        async_line=$in_async
        if [ "$in_async" -eq 1 ]; then
            async_depth=$((async_depth + opens - closes))
            [ "$opens" -gt 0 ] && async_opened=1
            if [ "$async_opened" -eq 1 ] && [ "$async_depth" -le 0 ]; then in_async=0; fi
        fi

        exempt=0
        [ "$in_test_file" -eq 1 ] && exempt=1
        [ "$in_cfg_test" -eq 1 ] && exempt=1

        if [ "$exempt" -eq 0 ]; then
            if [[ "$code_only" =~ \.unwrap\(\) ]] && [[ ! "$prev" =~ \#\[expect\(clippy::unwrap_used,.*reason ]]; then
                report "$file" "$line_no" "unwrap" ".unwrap() outside tests - use ? / ok_or / let-else, or for a proven invariant use .expect() behind #[expect(clippy::expect_used, reason = \"...\")]"
            fi

            if [[ "$code_only" =~ \.expect\( ]] && [[ ! "$prev" =~ \#\[expect\(clippy::expect_used,.*reason ]]; then
                report "$file" "$line_no" "expect" ".expect() outside tests - use ?, or for a proven invariant annotate the previous line with #[expect(clippy::expect_used, reason = \"...\")]"
            fi

            if [[ "$code_only" =~ (todo!|unimplemented!|unreachable!|unreachable_unchecked!) ]]; then
                report "$file" "$line_no" "placeholder-macro" "todo!/unimplemented!/unreachable! in committed code"
            fi

            if [[ "$code_only" =~ Box\<dyn[[:space:]]+Error ]]; then
                report "$file" "$line_no" "box-dyn-error" "Box<dyn Error> in non-test code - use anyhow::Error (apps) or thiserror enum (libs)"
            fi

            if [[ "$file" == */src/lib.rs || "$file" == */src/*/mod.rs || ( "$file" == */src/*.rs && "$file" != */src/main.rs && "$file" != */src/bin/* ) ]]; then
                if [[ "$code_only" =~ panic!\( ]]; then
                    report "$file" "$line_no" "lib-panic" "panic!() in library code - return Result"
                fi
            fi

            if [[ "$code_only" =~ let[[:space:]]+_[[:space:]]*=[[:space:]]*[^\;]*\( ]] && [[ ! "$prev" =~ \#\[expect\(clippy::let_underscore_must_use,.*reason ]]; then
                report "$file" "$line_no" "discarded-result" "let _ = call() drops its result - propagate or handle the error; log it on a best-effort path"
            fi

            if [ "$async_line" -eq 1 ] && [[ "$code_only" =~ (thread::sleep\(|std::fs::|reqwest::blocking::|\.blocking_(recv|send|lock|read|write)\() ]]; then
                report "$file" "$line_no" "blocking-in-async" "blocking call inside async code - use tokio::time::sleep / tokio::fs / the async client, or move it into spawn_blocking"
            fi
        fi

        if [[ "$code_only" =~ unsafe[[:space:]]*\{ ]]; then
            start=$((i > 5 ? i - 5 : 0))
            window=$(printf '%s\n' "${lines[@]:$start:$((i - start + 1))}")
            if [[ ! "$window" =~ //[[:space:]]*SAFETY: ]]; then
                report "$file" "$line_no" "unsafe-no-safety-comment" "unsafe block without // SAFETY: comment in preceding 5 lines"
            fi
        fi

        if [[ "$code_only" =~ \#!?\[allow\( ]]; then
            report "$file" "$line_no" "allow-attribute" "#[allow(...)] - use #[expect(lint, reason = \"...\")] so the exception fails once the lint stops firing"
        fi

        if [[ "$code_only" =~ \#!?\[expect\( ]]; then
            attr=$(printf '%s\n' "${lines[@]:$i:4}")
            if [[ ! "$attr" =~ reason[[:space:]]*= ]]; then
                report "$file" "$line_no" "expect-without-reason" "#[expect(...)] needs reason = \"...\" naming why the lint does not apply"
            fi
        fi

        # Heuristic flag for human review; exact analysis belongs to clippy::cast_possible_truncation.
        if [[ "$code_only" =~ (u16|u32|u64|u128|usize|i16|i32|i64|i128|isize)[[:space:]]+as[[:space:]]+(u8|u16|u32|i8|i16|i32)([^[:alnum:]_]|$) ]]; then
            report "$file" "$line_no" "narrowing-as-cast" "possible narrowing 'as' cast - use TryFrom / try_into() for fallible conversion"
        fi
    done
done

if [ "$violations" -gt 0 ]; then
    echo "" >&2
    echo "rust-programmer: ${violations} violation(s). Fix before declaring work done." >&2
    echo "" >&2
    echo "Then run the full toolchain gate:" >&2
    echo "  cargo fmt --all -- --check" >&2
    echo "  cargo clippy --all-targets --all-features -- -D warnings" >&2
    echo "  cargo nextest run --all-targets --all-features && cargo test --doc" >&2
    echo "  cargo +nightly miri nextest run --all-features    # if unsafe touched" >&2
    echo "  cargo machete" >&2
    echo "  cargo deny check" >&2
    exit 1
fi

echo "rust-programmer: no-excuse rules passed for $# file(s)."
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 321kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 321kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 321kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall