Skip to content
Back to skills

Capability Signature Detection

ASecurity

Code-scanning regex that looks for literal strings misses real usage:

  • 6 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 3, 2026
ai-agentsjavascriptgojavanodetestinggitapisecurity

Works with

  • api

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill capability-signature-detection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Capability Signature Detection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Capability Signature Detection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fabioc-aloha-capability-signature-detection/badge)](https://www.skillsdirectory.com/skills/fabioc-aloha-capability-signature-detection)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: capability-signature-detection
description: "Code-scanning regex that looks for literal strings misses real usage:"
lastReviewed: 2026-04-30
---

# Capability Signature Detection

## The Problem

Code-scanning regex that looks for literal strings misses real usage:

```javascript
// First attempt: find files that use ".github/muscles/"
grep -rn '\.github/muscles/' . // Misses most actual usage!

// Because real code uses variables:
const musclePath = path.join(brainDir, 'muscles', name);
execFileSync('node', [musclePath]); // No literal string!
```

## The Solution

Detect the **capability signature**, not the literal text.

```javascript
// Instead of: "files containing '.github/muscles/'"
// Detect: "files that import child_process AND call execFileSync/spawn"

const hasCapability = (content) => {
  const importsChildProcess = /require\(['"]child_process['"]\)|from ['"]child_process['"]/.test(content);
  const callsExec = /exec(File)?Sync|spawn(Sync)?/.test(content);
  return importsChildProcess && callsExec;
};
```

## Pattern Design

Ask: **"If a developer renames a path constant, would the test still find them?"**

| Approach | Survives Rename? | Use When |
|----------|------------------|----------|
| Literal string match | No | String IS the contract |
| Import + call pattern | Yes | Behavior IS the contract |
| AST parsing | Yes | Complex patterns |

## Examples

### Find Files That Execute Node Scripts

```javascript
// Bad: misses variable paths
const bad = /execFileSync\(['"]node['"],\s*\[['"]\.github/;

// Good: finds capability
const good = (content) => {
  const hasChildProcess = /child_process/.test(content);
  const executesNode = /exec(File)?Sync\(\s*['"]node['"]/.test(content);
  return hasChildProcess && executesNode;
};
```

### Find Files That Make HTTP Requests

```javascript
// Bad: misses axios, got, node-fetch, etc.
const bad = /fetch\(/;

// Good: covers common HTTP libraries
const good = (content) => {
  return /require\(['"](?:axios|got|node-fetch|undici)['"]\)|fetch\(|http\.request/.test(content);
};
```

## Verification

1. Rename a path variable → test still finds the file
2. Add new caller with different variable name → test finds it
3. False positives are acceptable if they're related capability

## When to Apply

- Finding callers of internal APIs
- Security audits (who can exec, who can write files)
- Contract enforcement
- Dependency analysis

## Tags

`quality` `testing` `regex` `code-analysis`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.