agentleFS
89jobrien89jobrien/godmode/skills/dead-code/SKILL.md

godmode:dead-code

Skill1 starsChanged 56 days agoMITView on GitHub

Dead code detector for Rust workspaces. Finds unused public API surface, orphaned test helpers, stale feature flags, and plugin artifacts referencing removed CLI subcommands. Cross-references pub exports against call sites across the workspace.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before removing a crate or module — check for orphaned references

    line 20
  2. Distinctive:

    Only test callers → test utility, consider test-module-only visibility

    line 39
  3. Distinctive:

    Only macro-expanded callers → higher risk of false negatives

    line 40
  4. Distinctive:

    If a public export appears unused but you suspect dynamic dispatch, manually review the call site.

    line 143
  5. Very specific:

    Use -w (word boundary) and --type rs (language filtering) to reduce noise.

    line 152
  6. Distinctive:

    Delete functions or types

    line 158
  7. Very specific:

    Remove feature gates or feature flags from Cargo.toml

    line 160
  8. Very specific:

    Run cargo remove or edit Cargo.toml programmatically

    line 162
  9. Very specific:

    Use the introspection skill to audit plugin artifact integrity, or run godmode review agents for an agent-frontmatter conformance check

    line 170

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Dead Code Detection

Find unused public API surface, test helpers, feature flags, and stale references without relying solely on compiler warnings.

When to Use

  • Asked to "find dead code", "unused exports", "clean up API surface", "find unused"
  • Preparing a breaking change or major refactor
  • Before removing a crate or module — check for orphaned references
  • Auditing plugin integrity (skills/agents referencing removed subcommands)
  • Periodic hygiene sweep to identify candidates for removal or visibility change

Detection Categories

Public API Surface

Enumerates all pub fn, pub struct, pub enum, pub trait, pub const, and pub static in a crate or workspace. For each, cross-references via Grep to find:

  • Direct callers outside the defining crate
  • Type constructor sites
  • Trait implementations
  • Module re-exports

Reports:

  • Zero external callers → candidate for pub(crate) or removal
  • Only test callers → test utility, consider test-module-only visibility
  • Only macro-expanded callers → higher risk of false negatives

Orphaned Test Helpers

Functions and macros defined in #[cfg(test)] modules that:

  • Are not called by any test
  • Are not re-exported for integration tests
  • Appear to be scaffolding from abandoned test patterns

Reports as Nitpick severity — may be kept for quick development debugging.

Feature Flags

Reads [features] in Cargo.toml. For each, searches the codebase for:

#[cfg(feature = "flag_name")]

Reports:

  • Feature declared but no cfg(feature) usage → dead feature gate
  • Feature guard protecting code that's never called anyway → nested dead code

Plugin Artifacts

For godmode plugin skills and agents:

  • Scan agents/*.md and skills/**/*.md for godmode <subcommand> references
  • Cross-reference against the CLI help/CLAUDE.md reference
  • Flag references to nonexistent subcommands as Blocking

Example: skill references godmode task pull --github but that flag was removed in v0.4.0.

Output Format

Blocking

Definite problems — code/references broken by removal or mutation:

  • Public function only called by code in a deleted module
  • Trait implementation for a type that no longer exists
  • Agent/skill referencing a nonexistent godmode subcommand
  • Feature gate protecting imported-but-removed dependency

Suggestion

Candidates for cleanup — unused but not broken:

  • Pub function with zero external callers (keep if part of intended API contract)
  • Feature flag with zero cfg usage (may be vestigial from earlier design)
  • Pub type never instantiated outside tests (visibility could be reduced)

Nitpick

Minor hygiene — does not block anything, low priority:

  • Unused test helpers (kept for quick prototyping, low signal)
  • Code behind always-false cfg gates (benign but can be cleaned up)
  • Orphaned re-exports
  • Deprecated functions without removal timeline

Example Detection Workflow

1. List all pub exports in crates/foo/src/lib.rs
   → [Line 42] pub fn process_item(...)
   → [Line 18] pub struct Config { ... }

2. Grep for "process_item" across workspace
   → 0 results outside crates/foo
   → 2 results in crates/foo/tests/
   → Verdict: test-only, suggest pub(crate) or move to test module

3. Grep for "Config" across workspace
   → 5 callers in crates/bar
   → 3 callers in crates/baz
   → Verdict: actively used external API

4. List features in crates/foo/Cargo.toml
   → [features] default = [], experimental, vendored

5. Grep for cfg(feature = "experimental")
   → 0 results
   → Verdict: dead feature flag, candidate for removal

6. Check agents/ for subcommand refs
   → agents/example.md: "godmode task pull-github"
   → CLAUDE.md: no "task pull-github" subcommand
   → Verdict: Blocking — agent references nonexistent subcommand

Limitations and Caveats

False Negatives — Grep may miss:

  • Calls via dynamic dispatch (HashMap of function pointers, vtables)
  • Calls via reflection or macro-generated code
  • Calls from FFI or other language bindings
  • Calls where the function is aliased (let f = process_item; f())

If a public export appears unused but you suspect dynamic dispatch, manually review the call site.

False Positives — Grep may report:

  • String literal matches (e.g., function name in a log message or doc example)
  • Comments referencing the function
  • Matches in generated or vendored code (bindings, test fixtures)

Use -w (word boundary) and --type rs (language filtering) to reduce noise.

No Fix Mode

This skill is read-only. Never:

  • Delete functions or types
  • Modify visibility (change pub to pub(crate))
  • Remove feature gates or feature flags from Cargo.toml
  • Edit agent/skill files to fix subcommand references
  • Run cargo remove or edit Cargo.toml programmatically

Report findings with context (last commit, usage pattern, confidence level) and let the user decide what to remove.

See Also

  • gm-code-review-agent — detects dead code as part of multi-dimensional review
  • Use the introspection skill to audit plugin artifact integrity, or run godmode review agents for an agent-frontmatter conformance check
  • Rust compiler warning: #[warn(dead_code)] — catches some unused functions (this skill finds unused public surface the compiler allows)

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.