You can configure where Forge looks for both dependencies and contracts using the --lib-paths and --contracts flags respectively. Alternatively you can configure it in foundry.toml
For automatic Hardhat support you can also pass the --hh flag, which sets the following flags: --lib-paths node_modules --contracts contracts.
forge build
compiles project
forge test
run all tests
creates two new directories
out -> contains contract artifacts, such as the ABI
cache -> used by forge to only recompile what is necessary