MCPcopy Index your code
hub / github.com/craftvscruft/tfrefactor

github.com/craftvscruft/tfrefactor @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
62 symbols 159 edges 17 files 10 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

tfrefactor

Version Documentation Tests License: MPL2

Automated refactoring for Terraform.

Currently supports:

  • Rename local / var / data / resource across all files in a config
  • Move items or categories of items to new files.
  • Diff preview of changes
  • Adding moved blocks for resource renames to avoid state mv in Terraform 1.1

See refactor.tf for more refactoring recipes.

Install

Requires Go 1.17

git clone git@github.com:craftvscruft/tfrefactor.git
cd tfrefactor
make

# Ensure ~/.local/bin is in your $PATH or copy to a directory that is.
cp bin/tfrefactor ~/.local/bin

Run without installing

make

./bin/tfrefactor

Usage Examples

Display CLI help with full usage information.

tfrefactor

Rename a var from acct_id to account_id in the current directory

tfrefactor rename var.acct_id var.account_id

Move the var account_id to the file variables.tf

tfrefactor mv var.account_id variables.tf

Move all data blocks to the file data.tf

tfrefactor mv data data.tf

Run tests

make test

Author

👤 Ray Myers

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

support us

Acknowledgements

Built on hclwrite, a component of HashiCorp Configuration Language (HCL).

Inspiration and test helper code from hcledit by Masayuki Morita.

📝 License

Copyright © 2022 Ray Myers.

This project is MPL2 licensed.

Core symbols most depended-on inside this repo

Shape

Function 54
Method 4
Struct 3
TypeAlias 1

Languages

Go100%

Modules by API surface

refactor/mv.go9 symbols
refactor/rename.go7 symbols
refactor/mv_test.go6 symbols
refactor/address.go6 symbols
cmd/mock.go5 symbols
refactor/update_plan.go4 symbols
cmd/rename.go4 symbols
refactor/parse.go3 symbols
cmd/version.go3 symbols
cmd/root.go3 symbols
cmd/mv.go3 symbols
cmd/doc.go3 symbols

For agents

$ claude mcp add tfrefactor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page