credo-custom-checks
$
npx mdskill add TheBushidoCollective/han/credo-custom-checksImplement project-specific code quality rules by creating custom Credo checks for Elixir projects.
- Enforces unique coding standards and best practices across a codebase.
- Integrates directly with the Credo linting tool for Elixir development.
- Executes custom AST traversal logic to detect specific code patterns.
- Outputs structured linting reports detailing identified code violations.
SKILL.md
.github/skills/credo-custom-checksView on GitHub ↗
---
name: credo-custom-checks
user-invocable: false
description: Use when creating custom Credo checks for project-specific code quality rules and standards in Elixir.
allowed-tools: []
---
# Credo Custom Checks
Creating custom Credo checks for project-specific rules.
## Creating a Custom Check
```elixir
defmodule MyApp.Credo.Check.NoHardcodedSecrets do
use Credo.Check,
category: :warning,
base_priority: :high,
explanations: [
check: """
Detects hardcoded secrets in code.
"""
]
@impl true
def run(%SourceFile{} = source_file, params) do
issue_meta = IssueMeta.for(source_file, params)
Credo.Code.prewalk(source_file, &traverse(&1, &2, issue_meta))
end
defp traverse(
{:@, _, [{:secret_key, _, [value]}]} = ast,
issues,
issue_meta
)
when is_binary(value) do
new_issue = issue_for(issue_meta, value)
{ast, [new_issue | issues]}
end
defp traverse(ast, issues, _issue_meta) do
{ast, issues}
end
defp issue_for(issue_meta, value) do
format_issue(
issue_meta,
message: "Hardcoded secret found: #{String.slice(value, 0..5)}...",
trigger: value
)
end
end
```
## Using Custom Checks
```elixir
# .credo.exs
%{
configs: [
%{
name: "default",
requires: ["./lib/my_app/credo/check/*.ex"],
checks: %{
enabled: [
{MyApp.Credo.Check.NoHardcodedSecrets, []}
]
}
}
]
}
```
More from TheBushidoCollective/han
- absinthe-resolversUse when implementing GraphQL resolvers with Absinthe. Covers resolver patterns, dataloader integration, batching, and error handling.
- absinthe-schemaUse when designing GraphQL schemas with Absinthe. Covers type definitions, interfaces, unions, enums, and schema organization patterns.
- absinthe-subscriptionsUse when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
- act-docker-setupUse when configuring Docker environments for act, selecting runner images, managing container resources, or troubleshooting Docker-related issues with local GitHub Actions testing.
- act-local-testingUse when testing GitHub Actions workflows locally with act. Covers act CLI usage, Docker configuration, debugging workflows, and troubleshooting common issues when running workflows on your local machine.
- act-workflow-syntaxUse when creating or modifying GitHub Actions workflow files. Provides guidance on workflow syntax, triggers, jobs, steps, and expressions for creating valid GitHub Actions workflows that can be tested locally with act.
- ameba-configurationUse when configuring Ameba rules and settings for Crystal projects including .ameba.yml setup, rule management, severity levels, and code quality enforcement.
- ameba-custom-rulesUse when creating custom Ameba rules for Crystal code analysis including rule development, AST traversal, issue reporting, and rule testing.
- ameba-integrationUse when integrating Ameba into development workflows including CI/CD pipelines, pre-commit hooks, GitHub Actions, and automated code review processes.
- analyze-performanceAnalyze performance metrics and identify slow transactions in Sentry