Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,30 @@ The Slack CLI is a command-line interface for building apps on the Slack Platfor
## Development Commands

### Building

```bash
make build # Build the CLI (includes linting and cleaning)
make build-ci # Build for CI (skips lint and tests)
./bin/slack --version # Run the compiled binary
```

### Testing

```bash
make test # Run all unit tests
make test testdir=cmd/auth testname=TestLoginCommand # Run specific test
make coverage # View test coverage report
```

### Linting

```bash
make lint # Run golangci-lint
golangci-lint --version # Verify linter version
```

### Other Commands

```bash
make init # Initialize project (fetch tags, dependencies)
make clean # Remove build artifacts (bin/, dist/)
Expand Down Expand Up @@ -63,11 +67,13 @@ main.go Entry point with tracing and context setup
### Key Architectural Patterns

**Command Aliases**: Many commands have shortcut aliases defined in `cmd/root.go`'s `AliasMap`:

- `slack login` → `slack auth login`
- `slack deploy` → `slack platform deploy`
- `slack create` → `slack project create`

**Client Factory Pattern**: `internal/shared/clients.go` provides a `ClientFactory` that manages shared clients and configurations across commands:

- `API()` - Slack API client
- `Auth()` - Authentication client
- `AppClient()` - App management client
Expand All @@ -84,6 +90,7 @@ Commands receive the `ClientFactory` and use it to access functionality.
**Hook System**: `internal/hooks/` implements a lifecycle hook system that allows SDK projects to inject custom behavior at key points. The specification exists in `docs/reference/hooks` files.

**Experiment System**: Features can be gated behind experiments defined in `internal/experiment/experiment.go`:

- Add new experiments as constants
- Register in `AllExperiments` slice
- Enable permanently via `EnabledExperiments`
Expand All @@ -92,13 +99,15 @@ Commands receive the `ClientFactory` and use it to access functionality.
### Command Structure

Commands follow this pattern:

1. Define in `cmd/<category>/<command>.go`
2. Create a Cobra command with use/short/long descriptions
3. Add flags specific to that command
4. Implement `RunE` function that receives clients
5. Add unit tests in `*_test.go` alongside

Example command structure:

```go
func NewExampleCommand(clients *shared.ClientFactory) *cobra.Command {
return &cobra.Command{
Expand All @@ -125,6 +134,7 @@ func NewExampleCommand(clients *shared.ClientFactory) *cobra.Command {
### Table-Driven Test Conventions

**Preferred: Map pattern** - uses `tc` for test case variable:

```go
tests := map[string]struct {
input string
Expand All @@ -137,30 +147,18 @@ for name, tc := range tests {
}
```

**Legacy: Slice pattern** - uses `tc` for test case variable (do not use for new tests):
```go
tests := []struct {
name string
input string
expected string
}{...}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
// use tc.field
})
}
```

## Version Management

Versions use semantic versioning with git tags (format: `v*.*.*`).

Version is generated dynamically using `git describe` and injected at build time:

```bash
LDFLAGS=-X 'github.com/slackapi/slack-cli/internal/pkg/version.Version=`git describe --tags --match 'v*.*.*'`'
```

**Versioning Rules**:

- `semver:patch` - Bug fixes and changes behind experiment flags
- `semver:minor` - New features (once experiments are removed)
- `semver:major` - Breaking changes
Expand All @@ -186,6 +184,7 @@ When deprecating features, commands, or flags:
## Commit Message Format

When creating commits and PRs, append to the end of the commit message:

```
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
```
Expand All @@ -212,6 +211,7 @@ Use conventional commit format (feat:, fix:, chore:, etc.) for commit titles.
### Understanding API Calls

All Slack API interactions go through `internal/api/`:

- `client.go` - HTTP client setup
- `app.go` - App management API calls
- `auth.go` - Authentication API calls
Expand Down
23 changes: 22 additions & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@
"allow": [
"Bash(go mod tidy:*)",
"Bash(gofmt:*)",
"Bash(gh issue view:*)",
"Bash(gh label list:*)",
"Bash(gh pr checks:*)",
"Bash(gh pr diff:*)",
"Bash(gh pr list:*)",
"Bash(gh pr status:*)",
"Bash(gh pr update-branch:*)",
"Bash(gh pr view:*)",
"Bash(gh search code:*)",
"Bash(git diff:*)",
"Bash(git grep:*)",
"Bash(git log:*)",
"Bash(git status:*)",
"Bash(go mod graph:*)",
"Bash(go mod tidy:*)",
"Bash(grep:*)",
"Bash(ls:*)",
"Bash(make build:*)",
"Bash(make build-ci:*)",
"Bash(make lint:*)"
"Bash(make lint:*)",
"Bash(make test:*)",
"Bash(tree:*)",
"WebFetch(domain:github.com)",
"WebFetch(domain:docs.slack.dev)"
Comment on lines 5 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🤩

]
}
}
Loading