Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 2.85 KB

CLAUDE.md

File metadata and controls

59 lines (39 loc) · 2.85 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Deleterious is a Go CLI tool that finds AWS resources orphaned by CloudFormation stacks with retention policies. It also analyzes IAM access key usage. Built with Cobra/Viper, distributed via Homebrew, Scoop, and direct binary downloads.

Build System

This project uses Bazel (via Bazelisk) as the primary build system. Do not use go build directly.

bazel run :install          # Build and install platform binaries to bdist/
bazel test //...            # Run all tests
bazel coverage //...        # Generate coverage reports
bazel run //:vendor         # Sync Go dependencies and regenerate BUILD files (runs gazelle)

After modifying go.mod or adding/removing Go files, run bazel run //:vendor to update BUILD files and vendored dependencies.

Linting

golangci-lint run           # Go linting (config in .golangci.yml)
yamllint .                  # YAML linting
shellcheck scripts/*.sh     # Shell script linting

Key golangci-lint settings: 120-char line limit, funlen max 100 lines/50 statements, gocyclo min complexity 10.

Testing

bazel test //...                        # Run all tests
bazel test //cmd:orphaned_test          # Run a specific test target

Tests use testify/mock with interface-based mocks generated by Mockery (cmd/mocks/). To regenerate mocks: go generate ./cmd/...

Architecture

  • main.go — Entry point, calls cmd.Execute(version) with version injected by Bazel linker flags
  • cmd/root.go — Root Cobra command, sets up global flags (--config, --profile, --debug), initializes Zerolog logging and Viper config (~/.deleterious.yaml)
  • cmd/orphaned.go — orphaned subcommand: queries CloudFormation for all stack resources via getRootedResources(), then compares against all resources of a given AWS type (DynamoDB, KMS, Kinesis, CloudWatch Logs, S3) to find orphans. Output as JSON or CSV.
  • cmd/keys.go — apikeys subcommand: finds IAM access keys filtered by age and usage status
  • cmd/mocks/ — Mockery-generated mocks for AWS service interfaces (CloudformationAPI, DynamoDBAPI, etc.)

AWS service calls are abstracted behind interfaces defined in cmd/orphaned.go to enable testing without credentials.

Cross-Platform Builds

Bazel builds native binaries for five targets: linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64. Platform targets are defined in the root BUILD.bazel. GoReleaser (.goreleaser.yml) handles release packaging using pre-built binaries from bdist/.

Dependencies

  • Uses AWS SDK v1 (github.com/aws/aws-sdk-go), not v2
  • Go modules with vendoring (vendor/ directory is checked in)
  • Renovate bot manages dependency update PRs; CI auto-commits vendor changes for bot PRs