Skill: Shell Lint ve Test

> ShellCheck + shfmt + BATS test çalıştırma ve hata düzeltme

6 stars

Best use case

Skill: Shell Lint ve Test is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

> ShellCheck + shfmt + BATS test çalıştırma ve hata düzeltme

Teams using Skill: Shell Lint ve Test should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/shell-lint-and-test/SKILL.md --create-dirs "https://raw.githubusercontent.com/CalmKernelTR/bigfive-updater/main/.agents/skills/shell-lint-and-test/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/shell-lint-and-test/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Skill: Shell Lint ve Test Compares

Feature / AgentSkill: Shell Lint ve TestStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

> ShellCheck + shfmt + BATS test çalıştırma ve hata düzeltme

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Skill: Shell Lint ve Test

> ShellCheck + shfmt + BATS test çalıştırma ve hata düzeltme

---

## Ön Koşullar

- `shellcheck` kurulu olmalı (`apt install shellcheck` veya `brew install shellcheck`)
- `shfmt` kurulu olmalı (`go install mvdan.cc/sh/v3/cmd/shfmt@latest` veya `snap install shfmt`)
- `bats` kurulu olmalı (`apt install bats` veya `npm install -g bats`)
- `kcov` (opsiyonel, coverage için)

---

## Adım 1: Bash Syntax Kontrolü

Tüm script'lerin sözdizimi geçerliliğini kontrol et:

```bash
bash -n guncel
bash -n install.sh
bash -n release.sh
bash -n lang/tr.sh
bash -n lang/en.sh
```

Hata durumunda: Belirtilen satır numarasına git, genellikle eşleşmeyen parantez/tırnak/fi/done sorunudur.

---

## Adım 2: ShellCheck Lint

```bash
shellcheck -S warning guncel install.sh release.sh
```

### Önemli Notlar

- `guncel` dosyasının başında `# shellcheck disable=SC2059` var — bu **bilerek** yapılmıştır (i18n printf format değişkenleri)
- ShellCheck uyarıları `warning` seviyesinde kontrol edilir (CI ile aynı)
- Yeni disable eklemeden önce gerçekten gerekli olduğundan emin ol

### Yaygın ShellCheck Hataları ve Çözümleri

| Kod | Açıklama | Çözüm |
|-----|----------|-------|
| SC2059 | printf format değişkeni | i18n için disable gerekli (dosya başında mevcut) |
| SC2086 | Tırnak içine alınmamış değişken | `"$var"` şeklinde tırnak ekle |
| SC2155 | declare ve atama tek satırda | `local var; var=$(...)` olarak ayır |
| SC2034 | Kullanılmayan değişken | Gerçekten kullanılmıyorsa kaldır |
| SC2153 | Yazım hatası şüphesi | Değişken adını kontrol et |

---

## Adım 3: shfmt Stil Kontrolü

```bash
# Fark göster (düzeltme yapmaz)
shfmt -d -i 2 -ci -sr guncel install.sh release.sh

# Otomatik düzeltme
shfmt -w -i 2 -ci -sr guncel install.sh release.sh
```

### shfmt Parametreleri

| Parametre | Açıklama |
|-----------|----------|
| `-i 2` | 2 boşluk indent |
| `-ci` | Switch-case indent |
| `-sr` | Redirect operatörleri boşlukla ayrılır |
| `-d` | Fark göster (dry-run) |
| `-w` | Dosyaya yaz (düzelt) |

---

## Adım 4: BATS Testleri

```bash
# Tüm testleri çalıştır
bats tests/guncel.bats tests/install.bats

# Tek test dosyası
bats tests/guncel.bats

# Belirli test (filtre)
bats tests/guncel.bats --filter "safe_source"

# TAP formatında çıktı
bats --tap tests/guncel.bats
```

### Test Yapısı

- `tests/test_helper.bash` — ortak değişkenler ve helper fonksiyonlar
  - `$GUNCEL_SCRIPT` → ana script yolu
  - `$PROJECT_ROOT` → proje kök dizini
  - `$MOCK_DIR` → mock dizini (setup/teardown'da oluşturulur/silinir)
- `tests/guncel.bats` — ~160 test (~816 satır)
- `tests/install.bats` — kurulum testleri

### Yeni Test Ekleme

```bash
@test "yeni fonksiyon açıklaması" {
    # Fonksiyon varlık kontrolü
    grep -qE '^yeni_fonksiyon\(\)' "$GUNCEL_SCRIPT"
}

@test "--yeni-flag help'te görünür" {
    run bash "$GUNCEL_SCRIPT" --help
    [ "$status" -eq 0 ]
    [[ "$output" == *"--yeni-flag"* ]]
}
```

---

## Adım 5: Coverage (Opsiyonel)

```bash
# kcov ile coverage
kcov --include-path=. coverage/ bats tests/guncel.bats

# Rapor görüntüle
open coverage/bats/index.html
```

---

## Tam Lint Pipeline (CI İle Aynı)

```bash
# 1. Syntax
bash -n guncel && bash -n install.sh && bash -n release.sh

# 2. ShellCheck
shellcheck -S warning guncel install.sh release.sh

# 3. shfmt
shfmt -d -i 2 -ci -sr guncel install.sh release.sh

# 4. BATS
bats tests/guncel.bats tests/install.bats
```

Tüm adımlar başarılıysa commit atmaya hazırsın.

---

## Hata Ayıklama İpuçları

1. **ShellCheck false positive** → `# shellcheck disable=SCXXXX` ekle (tek satır veya dosya başı)
2. **shfmt ile ShellCheck çakışması** → Önce shfmt, sonra ShellCheck çalıştır
3. **BATS test başarısız** → `bats --tap tests/guncel.bats` ile detaylı çıktı al
4. **Alpine uyumsuzluk** → `grep -P` yerine `grep -E` kullan (Alpine'da PCRE yok)
5. **Timeout sorunları** → CI'da multi-distro testleri network erişimi gerektirir

Related Skills

Skill: Multi-Distro Testing

6
from CalmKernelTR/bigfive-updater

> Docker container'larda 5 dağıtım test matrisi çalıştırma ve hata çözümleme

Skill: Paket Build ve Doğrulama

6
from CalmKernelTR/bigfive-updater

> AUR, Alpine APK ve RPM paket build süreçleri ve doğrulama adımları

Skill: i18n Senkronizasyon

6
from CalmKernelTR/bigfive-updater

> TR/EN dil dosyaları arasında mesaj senkronizasyonu ve tutarlılık kontrolü

swift-protocol-di-testing

144923
from affaan-m/everything-claude-code

基于协议的依赖注入,用于可测试的Swift代码——使用聚焦协议和Swift Testing模拟文件系统、网络和外部API。

DevelopmentClaude

perl-testing

144923
from affaan-m/everything-claude-code

使用Test2::V0、Test::More、prove runner、模拟、Devel::Cover覆盖率和TDD方法的Perl测试模式。

DevelopmentClaude

ai-regression-testing

144923
from affaan-m/everything-claude-code

AI辅助开发的回归测试策略。沙盒模式API测试,无需依赖数据库,自动化的缺陷检查工作流程,以及捕捉AI盲点的模式,其中同一模型编写和审查代码。

Software TestingClaudeCursorCodex

rust-testing

144923
from affaan-m/everything-claude-code

Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology.

DevelopmentClaude

kotlin-testing

144923
from affaan-m/everything-claude-code

Kotest, MockK, coroutine testi, property-based testing ve Kover coverage ile Kotlin test kalıpları. İdiomatic Kotlin uygulamalarıyla TDD metodolojisini takip eder.

DevelopmentClaude

cpp-testing

144923
from affaan-m/everything-claude-code

C++ テストの作成/更新/修正、GoogleTest/CTest の設定、失敗またはフレーキーなテストの診断、カバレッジ/サニタイザーの追加時にのみ使用します。

DevelopmentClaude

python-testing

144923
from affaan-m/everything-claude-code

Python testing best practices using pytest including fixtures, parametrization, mocking, coverage analysis, async testing, and test organization. Use when writing or improving Python tests.

DevelopmentClaude

golang-testing

144923
from affaan-m/everything-claude-code

Go testing best practices including table-driven tests, test helpers, benchmarking, race detection, coverage analysis, and integration testing patterns. Use when writing or improving Go tests.

DevelopmentClaude

e2e-testing

144923
from affaan-m/everything-claude-code

Playwright E2E testing patterns, Page Object Model, configuration, CI/CD integration, artifact management, and flaky test strategies.

Software TestingClaude