ATmega 406

I am using an ATmega406 for a BMS. I would like to program it through the Arduino IDE rather than Atmel Studio, any insights on this? How difficult is it to right a board library? What does writing a board library entail? Any feedback is appreciated, I know the question is very general.

Are you sure that part is right for you?
It is very specialized for battery management, and has major limitations because of that - only 1 MHz, lots of specialized pins, etc.... (in case you only read the 40K flash and number of pin specs - if you're doing battery management applications, great)... oh, and no USART or SPI... it has I2C, but the datasheet doesn't document it either...

Depending on the part, writing the board library may be trivial (just writing the variant pins_arduino.h and boards.txt and stealing the MCUDude core) if all the peripherals are standard. The "core" is the part that provides the implementations of the Arduino API functions - stuff like digitalWrite().

Writing a board library for that part would be a real pain - it looks like it has a bunch of peripherals that are highly non-standard (ex: the ADC) so making analogRead() could require some real work... It's Timer1 is also non-standard (looks like the standard 16-bit timer, but with no WGM bits - only PWM mode is 16-bit, and only mode option is that or CTC)

Yeah, that part is seriously gimped, plus no real datasheet, only a garbage preliminary version that doesn't document the I2C interface... There's a reason nobody has written a hardware package for it. Kind of a shame - so much potential, but they didn't do anything with it... (if you want my guess, I'd say it was probably made for a small number of specific customers)

(There is also the AT_tiny_406. which is a relatively new chip with nice features, directly supported by DrAzzy's MegaTinyCore for Arduino. No "High Voltage Inputs", though.)

Here is the official Arduino Platform Specification:
a platform is the collection of software needed to add support to the Arduino development software (Arduino IDE, Arduino CLI, Arduino Pro IDE) for boards. Although some people use the term "library" for platforms, it's not officially encouraged, since this is likely to cause confusion.

You could consider the specific component of the platform known as the "core" to be a library. The specification doesn't provide any details about writing a core. You could consider the Arduino Language Reference to be somewhat of a specification for the core library:
Here's the core for the official Arduino AVR Boards platform:

and the MCUdude core mentioned by DrAzzy:

Platforms also often bundle hardware-specific Arduino libraries. You can see the libraries bundled with the Arduino AVR Boards platform here:

@DrAzzy, OP writes "I am using an ATmega406 for a BMS" (Battery Management System)

The ATtiny406 and ATmega406 are thoroughly different animals - m406 is 40k classic megaAVR with a bunch of wacky features for battery management applications - while the t406 is a 4k tinyAVR 0-series part with the standard suite of modern AVR peripherals (and a thoroughly uninteresting specimen of this family, seeing as there is a t1606 with the same peripherals, but 4 times the memory, and the t3216 with twice as much memory as that, plus a remapping option for I2C, the DAC and a second ADC and TCB - and the whole family is cheap)